1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

code cleanup

mainly removes throw statements

automated using Android Studio, staged by hand

BUILD SUCCESSFUL in 52s
39 actionable tasks: 37 executed, 2 up-to-date
This commit is contained in:
BO41 2018-08-28 19:17:14 +02:00
parent 784e01347c
commit 27fbe69033
15 changed files with 37 additions and 37 deletions

View File

@ -106,7 +106,7 @@ public class App extends Application {
// https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling // https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() { RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override @Override
public void accept(@NonNull Throwable throwable) throws Exception { public void accept(@NonNull Throwable throwable) {
Log.e(TAG, "RxJavaPlugins.ErrorHandler called with -> : " + Log.e(TAG, "RxJavaPlugins.ErrorHandler called with -> : " +
"throwable = [" + throwable.getClass().getName() + "]"); "throwable = [" + throwable.getClass().getName() + "]");

View File

@ -58,7 +58,7 @@ public abstract class PlaylistDialog extends DialogFragment implements StateSave
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void readFrom(@NonNull Queue<Object> savedObjects) throws Exception { public void readFrom(@NonNull Queue<Object> savedObjects) {
streamEntities = (List<StreamEntity>) savedObjects.poll(); streamEntities = (List<StreamEntity>) savedObjects.poll();
} }

View File

@ -116,7 +116,7 @@ public class SubscriptionService {
public Completable updateChannelInfo(final ChannelInfo info) { public Completable updateChannelInfo(final ChannelInfo info) {
final Function<List<SubscriptionEntity>, CompletableSource> update = new Function<List<SubscriptionEntity>, CompletableSource>() { final Function<List<SubscriptionEntity>, CompletableSource> update = new Function<List<SubscriptionEntity>, CompletableSource>() {
@Override @Override
public CompletableSource apply(@NonNull List<SubscriptionEntity> subscriptionEntities) throws Exception { public CompletableSource apply(@NonNull List<SubscriptionEntity> subscriptionEntities) {
if (DEBUG) Log.d(TAG, "updateChannelInfo() called with: subscriptionEntities = [" + subscriptionEntities + "]"); if (DEBUG) Log.d(TAG, "updateChannelInfo() called with: subscriptionEntities = [" + subscriptionEntities + "]");
if (subscriptionEntities.size() == 1) { if (subscriptionEntities.size() == 1) {
SubscriptionEntity subscription = subscriptionEntities.get(0); SubscriptionEntity subscription = subscriptionEntities.get(0);

View File

@ -79,7 +79,7 @@ public class PlayQueueNavigator implements MediaSessionConnector.QueueNavigator
private void publishFloatingQueueWindow() { private void publishFloatingQueueWindow() {
if (callback.getQueueSize() == 0) { if (callback.getQueueSize() == 0) {
mediaSession.setQueue(Collections.<MediaSessionCompat.QueueItem>emptyList()); mediaSession.setQueue(Collections.emptyList());
activeQueueItemId = MediaSessionCompat.QueueItem.UNKNOWN_ID; activeQueueItemId = MediaSessionCompat.QueueItem.UNKNOWN_ID;
return; return;
} }

View File

@ -55,7 +55,7 @@ public class CustomTrackSelector extends DefaultTrackSelector {
/** @see DefaultTrackSelector#selectTextTrack(TrackGroupArray, int[][], Parameters) */ /** @see DefaultTrackSelector#selectTextTrack(TrackGroupArray, int[][], Parameters) */
@Override @Override
protected TrackSelection selectTextTrack(TrackGroupArray groups, int[][] formatSupport, protected TrackSelection selectTextTrack(TrackGroupArray groups, int[][] formatSupport,
Parameters params) throws ExoPlaybackException { Parameters params) {
TrackGroup selectedGroup = null; TrackGroup selectedGroup = null;
int selectedTrackIndex = 0; int selectedTrackIndex = 0;
int selectedTrackScore = 0; int selectedTrackScore = 0;

View File

@ -26,7 +26,7 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
transient Disposable fetchReactor; transient Disposable fetchReactor;
AbstractInfoPlayQueue(final U item) { AbstractInfoPlayQueue(final U item) {
this(item.getServiceId(), item.getUrl(), null, Collections.<StreamInfoItem>emptyList(), 0); this(item.getServiceId(), item.getUrl(), null, Collections.emptyList(), 0);
} }
AbstractInfoPlayQueue(final int serviceId, AbstractInfoPlayQueue(final int serviceId,

View File

@ -31,7 +31,7 @@ import org.schabi.newpipe.R;
public class AcraReportSender implements ReportSender { public class AcraReportSender implements ReportSender {
@Override @Override
public void send(@NonNull Context context, @NonNull CrashReportData report) throws ReportSenderException { public void send(@NonNull Context context, @NonNull CrashReportData report) {
ErrorActivity.reportError(context, report, ErrorActivity.reportError(context, report,
ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR,"none", ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR,"none",
"App crash, UI failure", R.string.app_ui_crash)); "App crash, UI failure", R.string.app_ui_crash));

View File

@ -89,7 +89,7 @@ public class SelectChannelFragment extends DialogFragment {
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.select_channel_fragment, container, false); View v = inflater.inflate(R.layout.select_channel_fragment, container, false);
recyclerView = (RecyclerView) v.findViewById(R.id.items_list); recyclerView = v.findViewById(R.id.items_list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
channelAdapter = new SelectChannelAdapter(); channelAdapter = new SelectChannelAdapter();
recyclerView.setAdapter(channelAdapter); recyclerView.setAdapter(channelAdapter);

View File

@ -75,7 +75,7 @@ public class SelectKioskFragment extends DialogFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.select_kiosk_fragment, container, false); View v = inflater.inflate(R.layout.select_kiosk_fragment, container, false);
recyclerView = (RecyclerView) v.findViewById(R.id.items_list); recyclerView = v.findViewById(R.id.items_list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
try { try {
selectKioskAdapter = new SelectKioskAdapter(); selectKioskAdapter = new SelectKioskAdapter();

View File

@ -183,7 +183,7 @@ public final class ExtractorHelper {
cache.removeInfo(serviceId, url); cache.removeInfo(serviceId, url);
load = loadFromNetwork; load = loadFromNetwork;
} else { } else {
load = Maybe.concat(ExtractorHelper.<I>loadFromCache(serviceId, url), load = Maybe.concat(ExtractorHelper.loadFromCache(serviceId, url),
loadFromNetwork.toMaybe()) loadFromNetwork.toMaybe())
.firstElement() //Take the first valid .firstElement() //Take the first valid
.toSingle(); .toSingle();

View File

@ -27,7 +27,7 @@ public class ImportExportJsonHelperTest {
} }
@Test @Test
public void testInvalidSource() throws Exception { public void testInvalidSource() {
List<String> invalidList = Arrays.asList( List<String> invalidList = Arrays.asList(
"{}", "{}",
"", "",

View File

@ -15,7 +15,7 @@ import static org.junit.Assert.assertNull;
*/ */
public class ErrorActivityTest { public class ErrorActivityTest {
@Test @Test
public void getReturnActivity() throws Exception { public void getReturnActivity() {
Class<? extends Activity> returnActivity; Class<? extends Activity> returnActivity;
returnActivity = ErrorActivity.getReturnActivity(MainActivity.class); returnActivity = ErrorActivity.getReturnActivity(MainActivity.class);
assertEquals(MainActivity.class, returnActivity); assertEquals(MainActivity.class, returnActivity);

View File

@ -45,7 +45,7 @@ public class ListHelperTest {
new VideoStream("", MediaFormat.MPEG_4, /**/ "1080p60", true)); new VideoStream("", MediaFormat.MPEG_4, /**/ "1080p60", true));
@Test @Test
public void getSortedStreamVideosListTest() throws Exception { public void getSortedStreamVideosListTest() {
List<VideoStream> result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true, videoStreamsTestList, videoOnlyStreamsTestList, true); List<VideoStream> result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true, videoStreamsTestList, videoOnlyStreamsTestList, true);
List<String> expected = Arrays.asList("144p", "240p", "360p", "480p", "720p", "720p60", "1080p", "1080p60", "1440p60", "2160p", "2160p60"); List<String> expected = Arrays.asList("144p", "240p", "360p", "480p", "720p", "720p60", "1080p", "1080p60", "1440p60", "2160p", "2160p60");
@ -67,7 +67,7 @@ public class ListHelperTest {
} }
@Test @Test
public void getSortedStreamVideosExceptHighResolutionsTest() throws Exception { public void getSortedStreamVideosExceptHighResolutionsTest() {
//////////////////////////////////// ////////////////////////////////////
// Don't show Higher resolutions // // Don't show Higher resolutions //
////////////////////////////////// //////////////////////////////////
@ -79,7 +79,7 @@ public class ListHelperTest {
} }
@Test @Test
public void getDefaultResolutionTest() throws Exception { public void getDefaultResolutionTest() {
List<VideoStream> testList = Arrays.asList( List<VideoStream> testList = Arrays.asList(
new VideoStream("", MediaFormat.MPEG_4, /**/ "720p"), new VideoStream("", MediaFormat.MPEG_4, /**/ "720p"),
new VideoStream("", MediaFormat.v3GPP, /**/ "240p"), new VideoStream("", MediaFormat.v3GPP, /**/ "240p"),
@ -130,7 +130,7 @@ public class ListHelperTest {
} }
@Test @Test
public void getHighestQualityAudioFormatTest() throws Exception { public void getHighestQualityAudioFormatTest() {
AudioStream stream = audioStreamsTestList.get(ListHelper.getHighestQualityAudioIndex(MediaFormat.M4A, audioStreamsTestList)); AudioStream stream = audioStreamsTestList.get(ListHelper.getHighestQualityAudioIndex(MediaFormat.M4A, audioStreamsTestList));
assertEquals(320, stream.average_bitrate); assertEquals(320, stream.average_bitrate);
assertEquals(MediaFormat.M4A, stream.getFormat()); assertEquals(MediaFormat.M4A, stream.getFormat());
@ -145,7 +145,7 @@ public class ListHelperTest {
} }
@Test @Test
public void getHighestQualityAudioFormatPreferredAbsent() throws Exception { public void getHighestQualityAudioFormatPreferredAbsent() {
////////////////////////////////////////// //////////////////////////////////////////
// Doesn't contain the preferred format // // Doesn't contain the preferred format //
@ -186,13 +186,13 @@ public class ListHelperTest {
} }
@Test @Test
public void getHighestQualityAudioNull() throws Exception { public void getHighestQualityAudioNull() {
assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, null)); assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, null));
assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, new ArrayList<AudioStream>())); assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, new ArrayList<AudioStream>()));
} }
@Test @Test
public void getLowestQualityAudioFormatTest() throws Exception { public void getLowestQualityAudioFormatTest() {
AudioStream stream = audioStreamsTestList.get(ListHelper.getMostCompactAudioIndex(MediaFormat.M4A, audioStreamsTestList)); AudioStream stream = audioStreamsTestList.get(ListHelper.getMostCompactAudioIndex(MediaFormat.M4A, audioStreamsTestList));
assertEquals(128, stream.average_bitrate); assertEquals(128, stream.average_bitrate);
assertEquals(MediaFormat.M4A, stream.getFormat()); assertEquals(MediaFormat.M4A, stream.getFormat());
@ -207,7 +207,7 @@ public class ListHelperTest {
} }
@Test @Test
public void getLowestQualityAudioFormatPreferredAbsent() throws Exception { public void getLowestQualityAudioFormatPreferredAbsent() {
////////////////////////////////////////// //////////////////////////////////////////
// Doesn't contain the preferred format // // Doesn't contain the preferred format //
@ -250,13 +250,13 @@ public class ListHelperTest {
} }
@Test @Test
public void getLowestQualityAudioNull() throws Exception { public void getLowestQualityAudioNull() {
assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, null)); assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, null));
assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, new ArrayList<AudioStream>())); assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, new ArrayList<AudioStream>()));
} }
@Test @Test
public void getVideoDefaultStreamIndexCombinations() throws Exception { public void getVideoDefaultStreamIndexCombinations() {
List<VideoStream> testList = Arrays.asList( List<VideoStream> testList = Arrays.asList(
new VideoStream("", MediaFormat.MPEG_4, /**/ "1080p"), new VideoStream("", MediaFormat.MPEG_4, /**/ "1080p"),
new VideoStream("", MediaFormat.MPEG_4, /**/ "720p60"), new VideoStream("", MediaFormat.MPEG_4, /**/ "720p60"),

View File

@ -11,25 +11,25 @@ public class QuadraticSliderStrategyTest {
private final SliderStrategy.Quadratic standard = private final SliderStrategy.Quadratic standard =
new SliderStrategy.Quadratic(0f, 100f, 50f, STEP); new SliderStrategy.Quadratic(0f, 100f, 50f, STEP);
@Test @Test
public void testLeftBound() throws Exception { public void testLeftBound() {
assertEquals(standard.progressOf(0), 0); assertEquals(standard.progressOf(0), 0);
assertEquals(standard.valueOf(0), 0f, DELTA); assertEquals(standard.valueOf(0), 0f, DELTA);
} }
@Test @Test
public void testCenter() throws Exception { public void testCenter() {
assertEquals(standard.progressOf(50), 50); assertEquals(standard.progressOf(50), 50);
assertEquals(standard.valueOf(50), 50f, DELTA); assertEquals(standard.valueOf(50), 50f, DELTA);
} }
@Test @Test
public void testRightBound() throws Exception { public void testRightBound() {
assertEquals(standard.progressOf(100), 100); assertEquals(standard.progressOf(100), 100);
assertEquals(standard.valueOf(100), 100f, DELTA); assertEquals(standard.valueOf(100), 100f, DELTA);
} }
@Test @Test
public void testLeftRegion() throws Exception { public void testLeftRegion() {
final int leftProgress = standard.progressOf(25); final int leftProgress = standard.progressOf(25);
final double leftValue = standard.valueOf(25); final double leftValue = standard.valueOf(25);
assertTrue(leftProgress > 0 && leftProgress < 50); assertTrue(leftProgress > 0 && leftProgress < 50);
@ -37,7 +37,7 @@ public class QuadraticSliderStrategyTest {
} }
@Test @Test
public void testRightRegion() throws Exception { public void testRightRegion() {
final int leftProgress = standard.progressOf(75); final int leftProgress = standard.progressOf(75);
final double leftValue = standard.valueOf(75); final double leftValue = standard.valueOf(75);
assertTrue(leftProgress > 50 && leftProgress < 100); assertTrue(leftProgress > 50 && leftProgress < 100);
@ -45,7 +45,7 @@ public class QuadraticSliderStrategyTest {
} }
@Test @Test
public void testConversion() throws Exception { public void testConversion() {
assertEquals(standard.progressOf(standard.valueOf(0)), 0); assertEquals(standard.progressOf(standard.valueOf(0)), 0);
assertEquals(standard.progressOf(standard.valueOf(25)), 25); assertEquals(standard.progressOf(standard.valueOf(25)), 25);
assertEquals(standard.progressOf(standard.valueOf(50)), 50); assertEquals(standard.progressOf(standard.valueOf(50)), 50);
@ -54,7 +54,7 @@ public class QuadraticSliderStrategyTest {
} }
@Test @Test
public void testReverseConversion() throws Exception { public void testReverseConversion() {
// Need a larger delta since step size / granularity is too small and causes // Need a larger delta since step size / granularity is too small and causes
// floating point round-off errors during conversion // floating point round-off errors during conversion
final float largeDelta = 1f; final float largeDelta = 1f;
@ -67,7 +67,7 @@ public class QuadraticSliderStrategyTest {
} }
@Test @Test
public void testQuadraticPropertyLeftRegion() throws Exception { public void testQuadraticPropertyLeftRegion() {
final double differenceCloserToCenter = final double differenceCloserToCenter =
Math.abs(standard.valueOf(40) - standard.valueOf(45)); Math.abs(standard.valueOf(40) - standard.valueOf(45));
final double differenceFurtherFromCenter = final double differenceFurtherFromCenter =
@ -76,7 +76,7 @@ public class QuadraticSliderStrategyTest {
} }
@Test @Test
public void testQuadraticPropertyRightRegion() throws Exception { public void testQuadraticPropertyRightRegion() {
final double differenceCloserToCenter = final double differenceCloserToCenter =
Math.abs(standard.valueOf(75) - standard.valueOf(70)); Math.abs(standard.valueOf(75) - standard.valueOf(70));
final double differenceFurtherFromCenter = final double differenceFurtherFromCenter =

View File

@ -110,7 +110,7 @@ public class DownloadManagerImplTest {
} }
@Test @Test
public void resumeMission() throws Exception { public void resumeMission() {
DownloadMission mission = missions.get(0); DownloadMission mission = missions.get(0);
mission.running = true; mission.running = true;
verify(mission, never()).start(); verify(mission, never()).start();
@ -122,7 +122,7 @@ public class DownloadManagerImplTest {
} }
@Test @Test
public void pauseMission() throws Exception { public void pauseMission() {
DownloadMission mission = missions.get(0); DownloadMission mission = missions.get(0);
mission.running = false; mission.running = false;
downloadManager.pauseMission(0); downloadManager.pauseMission(0);
@ -133,7 +133,7 @@ public class DownloadManagerImplTest {
} }
@Test @Test
public void deleteMission() throws Exception { public void deleteMission() {
DownloadMission mission = missions.get(0); DownloadMission mission = missions.get(0);
assertEquals(mission, downloadManager.getMission(0)); assertEquals(mission, downloadManager.getMission(0));
downloadManager.deleteMission(0); downloadManager.deleteMission(0);
@ -143,18 +143,18 @@ public class DownloadManagerImplTest {
} }
@Test(expected = RuntimeException.class) @Test(expected = RuntimeException.class)
public void getMissionWithNegativeIndex() throws Exception { public void getMissionWithNegativeIndex() {
downloadManager.getMission(-1); downloadManager.getMission(-1);
} }
@Test @Test
public void getMission() throws Exception { public void getMission() {
assertSame(missions.get(0), downloadManager.getMission(0)); assertSame(missions.get(0), downloadManager.getMission(0));
assertSame(missions.get(1), downloadManager.getMission(1)); assertSame(missions.get(1), downloadManager.getMission(1));
} }
@Test @Test
public void sortByTimestamp() throws Exception { public void sortByTimestamp() {
ArrayList<DownloadMission> downloadMissions = new ArrayList<>(); ArrayList<DownloadMission> downloadMissions = new ArrayList<>();
DownloadMission mission = new DownloadMission(); DownloadMission mission = new DownloadMission();
mission.timestamp = 0; mission.timestamp = 0;