diff options
author | ByteHamster <info@bytehamster.com> | 2021-03-27 19:40:53 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2021-03-27 20:44:35 +0100 |
commit | 71184ee5d4bc3a5b9e83625b9ee40297a6e3dd21 (patch) | |
tree | 2baf4dba3b2e179b09e29f4f72b0f92cf9d4af3e /app/src/main | |
parent | 3946f986d723f8579a33140bbe3c0d95182ecab1 (diff) | |
download | AntennaPod-71184ee5d4bc3a5b9e83625b9ee40297a6e3dd21.zip |
Fixed SpotBugs violations, so that at least the most severe checks pass
Diffstat (limited to 'app/src/main')
11 files changed, 20 insertions, 18 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index b5edcc878..aa1d746a5 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -188,7 +188,9 @@ public class MainActivity extends CastEnabledActivity { public void setupToolbarToggle(@NonNull Toolbar toolbar, boolean displayUpArrow) { if (drawerLayout != null) { // Tablet layout does not have a drawer - drawerLayout.removeDrawerListener(drawerToggle); + if (drawerToggle != null) { + drawerLayout.removeDrawerListener(drawerToggle); + } drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close); drawerLayout.addDrawerListener(drawerToggle); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java index de3242b1a..05099777c 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -58,9 +58,8 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder> */ public static final String SUBSCRIPTION_LIST_TAG = "SubscriptionList"; - private static List<String> fragmentTags; - private static String[] titles; - + private final List<String> fragmentTags = new ArrayList<>(); + private final String[] titles; private final ItemAccess itemAccess; private final WeakReference<Activity> activity; public boolean showSubscriptionList = true; @@ -98,7 +97,8 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder> showSubscriptionList = false; } - fragmentTags = newTags; + fragmentTags.clear(); + fragmentTags.addAll(newTags); notifyDataSetChanged(); } diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java index d0fb91692..375f676c8 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java @@ -206,7 +206,7 @@ public class ProxyDialog { private boolean checkPort() { int port = getPort(); - if(port < 0 && port > 65535) { + if (port < 0 || port > 65535) { etPort.setError(context.getString(R.string.proxy_port_invalid_error)); return false; } diff --git a/app/src/main/java/de/danoeh/antennapod/discovery/PodcastSearcherRegistry.java b/app/src/main/java/de/danoeh/antennapod/discovery/PodcastSearcherRegistry.java index 16c5548be..dfea627df 100644 --- a/app/src/main/java/de/danoeh/antennapod/discovery/PodcastSearcherRegistry.java +++ b/app/src/main/java/de/danoeh/antennapod/discovery/PodcastSearcherRegistry.java @@ -12,7 +12,7 @@ public class PodcastSearcherRegistry { private PodcastSearcherRegistry() { } - public static List<SearcherInfo> getSearchProviders() { + public static synchronized List<SearcherInfo> getSearchProviders() { if (searchProviders == null) { searchProviders = new ArrayList<>(); searchProviders.add(new SearcherInfo(new CombinedSearcher(), 1.0f)); diff --git a/app/src/main/java/de/danoeh/antennapod/error/CrashReportWriter.java b/app/src/main/java/de/danoeh/antennapod/error/CrashReportWriter.java index dc62863f9..23c8ffdd5 100644 --- a/app/src/main/java/de/danoeh/antennapod/error/CrashReportWriter.java +++ b/app/src/main/java/de/danoeh/antennapod/error/CrashReportWriter.java @@ -7,7 +7,6 @@ import de.danoeh.antennapod.BuildConfig; import org.apache.commons.io.IOUtils; import java.io.File; -import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.text.SimpleDateFormat; @@ -40,7 +39,7 @@ public class CrashReportWriter implements Thread.UncaughtExceptionHandler { File path = getFile(); PrintWriter out = null; try { - out = new PrintWriter(new FileWriter(path)); + out = new PrintWriter(path, "UTF-8"); out.println("## Crash info"); out.println("Time: " + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss", Locale.getDefault()).format(new Date())); out.println("AntennaPod version: " + BuildConfig.VERSION_NAME); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java index 612959c04..18b011a08 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -27,7 +27,7 @@ public class AllEpisodesFragment extends EpisodesListFragment { private static final String PREF_NAME = "PrefAllEpisodesFragment"; private static final String PREF_FILTER = "filter"; - private static FeedItemFilter feedItemFilter = new FeedItemFilter(""); + private FeedItemFilter feedItemFilter = new FeedItemFilter(""); @Override public void onCreate(@Nullable Bundle savedInstanceState) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java index 0ce38656a..0d9181d84 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java @@ -1,13 +1,13 @@ package de.danoeh.antennapod.fragment.gpodnet; import android.os.Bundle; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import de.danoeh.antennapod.core.sync.gpoddernet.GpodnetService; import de.danoeh.antennapod.core.sync.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.core.sync.gpoddernet.model.GpodnetPodcast; import de.danoeh.antennapod.core.sync.gpoddernet.model.GpodnetTag; -import org.apache.commons.lang3.Validate; import de.danoeh.antennapod.activity.MainActivity; @@ -24,8 +24,7 @@ public class TagFragment extends PodcastListFragment { private GpodnetTag tag; - public static TagFragment newInstance(GpodnetTag tag) { - Validate.notNull(tag); + public static TagFragment newInstance(@NonNull GpodnetTag tag) { TagFragment fragment = new TagFragment(); Bundle args = new Bundle(); args.putParcelable("tag", tag); @@ -38,7 +37,9 @@ public class TagFragment extends PodcastListFragment { super.onCreate(savedInstanceState); Bundle args = getArguments(); - Validate.isTrue(args != null && args.getParcelable("tag") != null, "args invalid"); + if (args == null || args.getParcelable("tag") == null) { + throw new IllegalArgumentException("Arguments not given"); + } tag = args.getParcelable("tag"); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java index b844234b7..dcd720dc2 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java @@ -29,7 +29,7 @@ public class DevelopersFragment extends ListFragment { developersLoader = Single.create((SingleOnSubscribe<ArrayList<SimpleIconListAdapter.ListItem>>) emitter -> { ArrayList<SimpleIconListAdapter.ListItem> developers = new ArrayList<>(); BufferedReader reader = new BufferedReader(new InputStreamReader( - getContext().getAssets().open("developers.csv"))); + getContext().getAssets().open("developers.csv"), "UTF-8")); String line; while ((line = reader.readLine()) != null) { String[] info = line.split(";"); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java index 97565a613..38e532aed 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java @@ -95,7 +95,7 @@ public class LicensesFragment extends ListFragment { private void showLicenseText(String licenseTextFile) { try { BufferedReader reader = new BufferedReader(new InputStreamReader( - getContext().getAssets().open(licenseTextFile))); + getContext().getAssets().open(licenseTextFile), "UTF-8")); StringBuilder licenseText = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java index d759a5ff2..1b4beeea0 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java @@ -29,7 +29,7 @@ public class SpecialThanksFragment extends ListFragment { translatorsLoader = Single.create((SingleOnSubscribe<ArrayList<SimpleIconListAdapter.ListItem>>) emitter -> { ArrayList<SimpleIconListAdapter.ListItem> translators = new ArrayList<>(); BufferedReader reader = new BufferedReader(new InputStreamReader( - getContext().getAssets().open("special_thanks.csv"))); + getContext().getAssets().open("special_thanks.csv"), "UTF-8")); String line; while ((line = reader.readLine()) != null) { String[] info = line.split(";"); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java index b77c74de6..ed0d53145 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java @@ -29,7 +29,7 @@ public class TranslatorsFragment extends ListFragment { translatorsLoader = Single.create((SingleOnSubscribe<ArrayList<SimpleIconListAdapter.ListItem>>) emitter -> { ArrayList<SimpleIconListAdapter.ListItem> translators = new ArrayList<>(); BufferedReader reader = new BufferedReader(new InputStreamReader( - getContext().getAssets().open("translators.csv"))); + getContext().getAssets().open("translators.csv"), "UTF-8")); String line; while ((line = reader.readLine()) != null) { String[] info = line.split(";"); |