From af280a73436b4ab984fa9ecd0b9ad6e89765af56 Mon Sep 17 00:00:00 2001 From: BO41 Date: Tue, 28 Aug 2018 20:14:26 +0200 Subject: [PATCH] Java language level + javadoc + xml replace with <> String builder BUILD SUCCESSFUL in 4s 39 actionable tasks: 4 executed, 35 up-to-date --- .../org/schabi/newpipe/RouterActivity.java | 16 ++++++---- .../newpipe/about/LicenseFragmentHelper.java | 6 ++-- .../services/SubscriptionsImportService.java | 16 ++++++---- .../schabi/newpipe/report/ErrorActivity.java | 9 +++--- .../org/schabi/newpipe/util/ZipHelper.java | 1 - .../giga/get/DownloadManagerImpl.java | 2 +- .../us/shandian/giga/get/DownloadMission.java | 8 ++--- .../main/res/layout/fragment_choose_tabs.xml | 32 ------------------- app/src/main/res/xml/provider_paths.xml | 2 +- .../schabi/newpipe/util/ListHelperTest.java | 4 +-- .../giga/get/DownloadManagerImplTest.java | 6 ++-- assets/BETA_new_pipe_icon_5.svg | 25 ++++----------- assets/NP logo v2.svg | 2 +- assets/buddy_channel_item.svg | 24 ++++---------- assets/budy.svg | 21 +++--------- assets/channel_banner_desktop.svg | 26 ++++----------- assets/channel_banner_mobild.svg | 26 ++++----------- assets/dummi_thumbnail.svg | 19 +++-------- assets/dummi_thumbnail_backup.svg | 21 +++--------- assets/dummi_thumbnail_playlist.svg | 21 +++--------- .../dummi_thumbnail_playlist_background.svg | 21 +++--------- assets/gruese_die_gema.svg | 24 ++++---------- assets/ic_play_circle_transparent.svg | 23 ++++--------- assets/ic_play_circle_transparent_80px.svg | 25 ++++----------- assets/new_pipe_icon_4.svg | 27 ++++------------ assets/new_pipe_icon_5.svg | 25 ++++----------- assets/new_pipe_icon_5_beta2.svg | 27 ++++------------ assets/new_play_arrow.svg | 21 +++--------- assets/not_available_monkey.svg | 19 +++-------- assets/service.svg | 21 +++--------- 30 files changed, 141 insertions(+), 379 deletions(-) delete mode 100644 app/src/main/res/layout/fragment_choose_tabs.xml diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index f1b1b45d8..e22e2f474 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -179,12 +179,16 @@ public class RouterActivity extends AppCompatActivity { if (selectedChoiceKey.equals(alwaysAskKey)) { final List choices = getChoicesForService(currentService, currentLinkType); - if (choices.size() == 1) { - handleChoice(choices.get(0).key); - } else if (choices.size() == 0) { - handleChoice(showInfoKey); - } else { - showDialog(choices); + switch (choices.size()) { + case 1: + handleChoice(choices.get(0).key); + break; + case 0: + handleChoice(showInfoKey); + break; + default: + showDialog(choices); + break; } } else if (selectedChoiceKey.equals(showInfoKey)) { handleChoice(showInfoKey); diff --git a/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java b/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java index 339cd5370..09d33bd8a 100644 --- a/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java +++ b/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java @@ -77,18 +77,18 @@ public class LicenseFragmentHelper extends AsyncTask { throw new NullPointerException("license is null"); } - String licenseContent = ""; + StringBuilder licenseContent = new StringBuilder(); String webViewData; try { BufferedReader in = new BufferedReader(new InputStreamReader(context.getAssets().open(license.getFilename()), "UTF-8")); String str; while ((str = in.readLine()) != null) { - licenseContent += str; + licenseContent.append(str); } in.close(); // split the HTML file and insert the stylesheet into the HEAD of the file - String[] insert = licenseContent.split(""); + String[] insert = licenseContent.toString().split(""); webViewData = insert[0] + "" + insert[1]; diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsImportService.java b/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsImportService.java index 3fdc91358..48410205a 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsImportService.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsImportService.java @@ -144,12 +144,16 @@ public class SubscriptionsImportService extends BaseImportExportService { showToast(R.string.import_ongoing); Flowable> flowable = null; - if (currentMode == CHANNEL_URL_MODE) { - flowable = importFromChannelUrl(); - } else if (currentMode == INPUT_STREAM_MODE) { - flowable = importFromInputStream(); - } else if (currentMode == PREVIOUS_EXPORT_MODE) { - flowable = importFromPreviousExport(); + switch (currentMode) { + case CHANNEL_URL_MODE: + flowable = importFromChannelUrl(); + break; + case INPUT_STREAM_MODE: + flowable = importFromInputStream(); + break; + case PREVIOUS_EXPORT_MODE: + flowable = importFromPreviousExport(); + break; } if (flowable == null) { diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index a0e1ee19d..f852e0134 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -274,15 +274,14 @@ public class ErrorActivity extends AppCompatActivity { } private String formErrorText(String[] el) { - String text = ""; + StringBuilder text = new StringBuilder(); if (el != null) { for (String e : el) { - text += "-------------------------------------\n" - + e; + text.append("-------------------------------------\n").append(e); } } - text += "-------------------------------------"; - return text; + text.append("-------------------------------------"); + return text.toString(); } /** diff --git a/app/src/main/java/org/schabi/newpipe/util/ZipHelper.java b/app/src/main/java/org/schabi/newpipe/util/ZipHelper.java index 3578f34ac..3142ad8dc 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ZipHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ZipHelper.java @@ -56,7 +56,6 @@ public class ZipHelper { /** * This will extract data from Zipfiles. * Caution this will override the original file. - * @param inZip The ZipOutputStream where the data is stored in * @param file The path of the file on the disk where the data should be extracted to. * @param name The path of the file inside the zip. * @return will return true if the file was found within the zip file diff --git a/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java b/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java index 3294f5164..a377d861c 100755 --- a/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java @@ -123,7 +123,7 @@ public class DownloadManagerImpl implements DownloadManager { Collections.sort(missions, new Comparator() { @Override public int compare(DownloadMission o1, DownloadMission o2) { - return Long.valueOf(o1.timestamp).compareTo(o2.timestamp); + return Long.compare(o1.timestamp, o2.timestamp); } }); } diff --git a/app/src/main/java/us/shandian/giga/get/DownloadMission.java b/app/src/main/java/us/shandian/giga/get/DownloadMission.java index 05ea7cbd4..79c4baf05 100644 --- a/app/src/main/java/us/shandian/giga/get/DownloadMission.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadMission.java @@ -67,8 +67,8 @@ public class DownloadMission implements Serializable { public long done; public int threadCount = 3; public int finishCount; - private final List threadPositions = new ArrayList(); - public final Map blockState = new HashMap(); + private final List threadPositions = new ArrayList<>(); + public final Map blockState = new HashMap<>(); public boolean running; public boolean finished; public boolean fallback; @@ -77,7 +77,7 @@ public class DownloadMission implements Serializable { public transient boolean recovered; - private transient ArrayList> mListeners = new ArrayList>(); + private transient ArrayList> mListeners = new ArrayList<>(); private transient boolean mWritingToFile; private static final int NO_IDENTIFIER = -1; @@ -232,7 +232,7 @@ public class DownloadMission implements Serializable { public synchronized void addListener(MissionListener listener) { Handler handler = new Handler(Looper.getMainLooper()); MissionListener.handlerStore.put(listener, handler); - mListeners.add(new WeakReference(listener)); + mListeners.add(new WeakReference<>(listener)); } public synchronized void removeListener(MissionListener listener) { diff --git a/app/src/main/res/layout/fragment_choose_tabs.xml b/app/src/main/res/layout/fragment_choose_tabs.xml deleted file mode 100644 index 0097a409a..000000000 --- a/app/src/main/res/layout/fragment_choose_tabs.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/xml/provider_paths.xml b/app/src/main/res/xml/provider_paths.xml index 7c55d5a29..598a1b1c7 100644 --- a/app/src/main/res/xml/provider_paths.xml +++ b/app/src/main/res/xml/provider_paths.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java b/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java index abc09dc98..a6e7fc2c0 100644 --- a/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java +++ b/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java @@ -188,7 +188,7 @@ public class ListHelperTest { @Test public void getHighestQualityAudioNull() { assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, null)); - assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, new ArrayList())); + assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, new ArrayList<>())); } @Test @@ -252,7 +252,7 @@ public class ListHelperTest { @Test public void getLowestQualityAudioNull() { assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, null)); - assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, new ArrayList())); + assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, new ArrayList<>())); } @Test diff --git a/app/src/test/java/us/shandian/giga/get/DownloadManagerImplTest.java b/app/src/test/java/us/shandian/giga/get/DownloadManagerImplTest.java index 49bfd4840..c755ba2e9 100644 --- a/app/src/test/java/us/shandian/giga/get/DownloadManagerImplTest.java +++ b/app/src/test/java/us/shandian/giga/get/DownloadManagerImplTest.java @@ -42,12 +42,12 @@ public class DownloadManagerImplTest { missions.add(generateFinishedDownloadMission()); } when(downloadDataSource.loadMissions()).thenReturn(new ArrayList<>(missions)); - downloadManager = new DownloadManagerImpl(new ArrayList(), downloadDataSource); + downloadManager = new DownloadManagerImpl(new ArrayList<>(), downloadDataSource); } @Test(expected = NullPointerException.class) public void testConstructorWithNullAsDownloadDataSource() { - new DownloadManagerImpl(new ArrayList(), null); + new DownloadManagerImpl(new ArrayList<>(), null); } @@ -84,7 +84,7 @@ public class DownloadManagerImplTest { downloadDataSource = mock(DownloadDataSource.class); when(downloadDataSource.loadMissions()).thenReturn(new ArrayList<>(missions)); - downloadManager = new DownloadManagerImpl(new ArrayList(), downloadDataSource); + downloadManager = new DownloadManagerImpl(new ArrayList<>(), downloadDataSource); verify(downloadDataSource, times(1)).loadMissions(); assertEquals(50, downloadManager.getCount()); diff --git a/assets/BETA_new_pipe_icon_5.svg b/assets/BETA_new_pipe_icon_5.svg index 9406f2469..4fee29b3e 100644 --- a/assets/BETA_new_pipe_icon_5.svg +++ b/assets/BETA_new_pipe_icon_5.svg @@ -1,23 +1,10 @@ - + -