summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaco <SkytkRSfan3895@gmail.com>2024-06-09 14:47:49 -0400
committerGitHub <noreply@github.com>2024-06-09 20:47:49 +0200
commitc51656f8e7077ed1dbd967064a7a065a045accfb (patch)
tree720c8a1cfcec8a1e546534c8efea8e6a434105fd
parent46a409ad34025460db4ea813ff31ceeaeabae45d (diff)
downloadAntennaPod-c51656f8e7077ed1dbd967064a7a065a045accfb.zip
Spotbugs cleanup part 2 (#7204)
-rw-r--r--app/src/main/java/de/danoeh/antennapod/PreferenceUpgrader.java1
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java19
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/feed/preferences/FeedSettingsFragment.java6
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/preferences/AutomaticDeletionPreferencesFragment.java2
-rw-r--r--config/spotbugs/exclude.xml4
-rw-r--r--playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java21
-rw-r--r--storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBWriter.java86
-rw-r--r--storage/importexport/src/main/java/de/danoeh/antennapod/storage/importexport/FavoritesWriter.java4
8 files changed, 61 insertions, 82 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/PreferenceUpgrader.java b/app/src/main/java/de/danoeh/antennapod/PreferenceUpgrader.java
index 02abc23fb..c5e805f92 100644
--- a/app/src/main/java/de/danoeh/antennapod/PreferenceUpgrader.java
+++ b/app/src/main/java/de/danoeh/antennapod/PreferenceUpgrader.java
@@ -68,6 +68,7 @@ public class PreferenceUpgrader {
UserPreferences.setAllowMobileEpisodeDownload(true);
UserPreferences.setAllowMobileImages(true);
break;
+ default: // Fall-through to "images"
case "images":
UserPreferences.setAllowMobileImages(true);
break;
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 fd4007736..4b7c59257 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java
@@ -431,17 +431,14 @@ public class MainActivity extends CastEnabledActivity {
Validate.notNull(fragment);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- switch (transition) {
- case FADE:
- transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
- break;
- case SLIDE:
- transaction.setCustomAnimations(
- R.anim.slide_right_in,
- R.anim.slide_left_out,
- R.anim.slide_left_in,
- R.anim.slide_right_out);
- break;
+ if (transition == TransitionEffect.FADE) {
+ transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
+ } else if (transition == TransitionEffect.SLIDE) {
+ transaction.setCustomAnimations(
+ R.anim.slide_right_in,
+ R.anim.slide_left_out,
+ R.anim.slide_left_in,
+ R.anim.slide_right_out);
}
transaction
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/preferences/FeedSettingsFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/preferences/FeedSettingsFragment.java
index 4438f80cc..d657ed675 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/preferences/FeedSettingsFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/preferences/FeedSettingsFragment.java
@@ -450,7 +450,7 @@ public class FeedSettingsFragment extends Fragment {
pref.setChecked(feedPreferences.getKeepUpdated());
pref.setOnPreferenceChangeListener((preference, newValue) -> {
- boolean checked = newValue == Boolean.TRUE;
+ boolean checked = Boolean.TRUE.equals(newValue);
feedPreferences.setKeepUpdated(checked);
DBWriter.setFeedPreferences(feedPreferences);
pref.setChecked(checked);
@@ -480,7 +480,7 @@ public class FeedSettingsFragment extends Fragment {
}
pref.setOnPreferenceChangeListener((preference, newValue) -> {
- boolean checked = newValue == Boolean.TRUE;
+ boolean checked = Boolean.TRUE.equals(newValue);
feedPreferences.setAutoDownload(checked);
DBWriter.setFeedPreferences(feedPreferences);
@@ -515,7 +515,7 @@ public class FeedSettingsFragment extends Fragment {
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
return false;
}
- boolean checked = newValue == Boolean.TRUE;
+ boolean checked = Boolean.TRUE.equals(newValue);
feedPreferences.setShowEpisodeNotification(checked);
DBWriter.setFeedPreferences(feedPreferences);
pref.setChecked(checked);
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/preferences/AutomaticDeletionPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/preferences/AutomaticDeletionPreferencesFragment.java
index 8c7608b6b..de7283ad2 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/preferences/AutomaticDeletionPreferencesFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/preferences/AutomaticDeletionPreferencesFragment.java
@@ -39,7 +39,7 @@ public class AutomaticDeletionPreferencesFragment extends PreferenceFragmentComp
findPreference(UserPreferences.PREF_EPISODE_CLEANUP).setSummary(R.string.auto_download_disabled_globally);
}
findPreference(PREF_AUTO_DELETE_LOCAL).setOnPreferenceChangeListener((preference, newValue) -> {
- if (blockAutoDeleteLocal && newValue == Boolean.TRUE) {
+ if (blockAutoDeleteLocal && newValue.equals(Boolean.TRUE)) {
showAutoDeleteEnableDialog();
return false;
} else {
diff --git a/config/spotbugs/exclude.xml b/config/spotbugs/exclude.xml
index d49d5280b..295123e6b 100644
--- a/config/spotbugs/exclude.xml
+++ b/config/spotbugs/exclude.xml
@@ -80,14 +80,10 @@
<Match><Bug pattern="IS2_INCONSISTENT_SYNC"/></Match>
<Match><Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/></Match>
<Match><Bug pattern="OS_OPEN_STREAM"/></Match>
- <Match><Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN"/></Match>
- <Match><Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/></Match>
<Match><Bug pattern="RV_RETURN_VALUE_IGNORED"/></Match>
<Match><Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE"/></Match>
<Match><Bug pattern="SE_NO_SERIALVERSIONID"/></Match>
<Match><Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/></Match>
- <Match><Bug pattern="SF_SWITCH_NO_DEFAULT"/></Match>
<Match><Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/></Match>
<Match><Bug pattern="VA_FORMAT_STRING_USES_NEWLINE"/></Match>
- <Match><Bug pattern="WMI_WRONG_MAP_ITERATOR"/></Match>
</FindBugsFilter>
diff --git a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java
index 4a6ebbad2..f7ae97dbb 100644
--- a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java
+++ b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java
@@ -208,18 +208,15 @@ public abstract class PlaybackController {
Log.d(TAG, "Bad arguments. Won't handle intent");
return;
}
- switch (type) {
- case PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD:
- if (playbackService == null && PlaybackService.isRunning) {
- bindToService();
- return;
- }
- mediaInfoLoaded = false;
- queryService();
- break;
- case PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END:
- onPlaybackEnd();
- break;
+ if (type == PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD) {
+ if (playbackService == null && PlaybackService.isRunning) {
+ bindToService();
+ return;
+ }
+ mediaInfoLoaded = false;
+ queryService();
+ } else if (type == PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END) {
+ onPlaybackEnd();
}
}
diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBWriter.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBWriter.java
index df690ff5f..9bfff11bd 100644
--- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBWriter.java
+++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBWriter.java
@@ -531,39 +531,35 @@ public class DBWriter {
adapter.open();
final List<FeedItem> queue = DBReader.getQueue();
- if (queue != null) {
- boolean queueModified = false;
- List<QueueEvent> events = new ArrayList<>();
- List<FeedItem> updatedItems = new ArrayList<>();
- for (long itemId : itemIds) {
- int position = indexInItemList(queue, itemId);
- if (position >= 0) {
- final FeedItem item = DBReader.getFeedItem(itemId);
- if (item == null) {
- Log.e(TAG, "removeQueueItem - item in queue but somehow cannot be loaded." +
- " Item ignored. It should never happen. id:" + itemId);
- continue;
- }
- queue.remove(position);
- item.removeTag(FeedItem.TAG_QUEUE);
- events.add(QueueEvent.removed(item));
- updatedItems.add(item);
- queueModified = true;
- } else {
- Log.v(TAG, "removeQueueItem - item not in queue:" + itemId);
+ boolean queueModified = false;
+ List<QueueEvent> events = new ArrayList<>();
+ List<FeedItem> updatedItems = new ArrayList<>();
+ for (long itemId : itemIds) {
+ int position = indexInItemList(queue, itemId);
+ if (position >= 0) {
+ final FeedItem item = DBReader.getFeedItem(itemId);
+ if (item == null) {
+ Log.e(TAG, "removeQueueItem - item in queue but somehow cannot be loaded."
+ + " Item ignored. It should never happen. id:" + itemId);
+ continue;
}
- }
- if (queueModified) {
- adapter.setQueue(queue);
- for (QueueEvent event : events) {
- EventBus.getDefault().post(event);
- }
- EventBus.getDefault().post(FeedItemEvent.updated(updatedItems));
+ queue.remove(position);
+ item.removeTag(FeedItem.TAG_QUEUE);
+ events.add(QueueEvent.removed(item));
+ updatedItems.add(item);
+ queueModified = true;
} else {
- Log.w(TAG, "Queue was not modified by call to removeQueueItem");
+ Log.v(TAG, "removeQueueItem - item not in queue:" + itemId);
}
+ }
+ if (queueModified) {
+ adapter.setQueue(queue);
+ for (QueueEvent event : events) {
+ EventBus.getDefault().post(event);
+ }
+ EventBus.getDefault().post(FeedItemEvent.updated(updatedItems));
} else {
- Log.e(TAG, "removeQueueItem: Could not load queue");
+ Log.w(TAG, "Queue was not modified by call to removeQueueItem");
}
adapter.close();
if (performAutoDownload) {
@@ -670,18 +666,14 @@ public class DBWriter {
adapter.open();
final List<FeedItem> queue = DBReader.getQueue();
- if (queue != null) {
- if (from >= 0 && from < queue.size() && to >= 0 && to < queue.size()) {
- final FeedItem item = queue.remove(from);
- queue.add(to, item);
+ if (from >= 0 && from < queue.size() && to >= 0 && to < queue.size()) {
+ final FeedItem item = queue.remove(from);
+ queue.add(to, item);
- adapter.setQueue(queue);
- if (broadcastUpdate) {
- EventBus.getDefault().post(QueueEvent.moved(item, to));
- }
+ adapter.setQueue(queue);
+ if (broadcastUpdate) {
+ EventBus.getDefault().post(QueueEvent.moved(item, to));
}
- } else {
- Log.e(TAG, "moveQueueItemHelper: Could not load queue");
}
adapter.close();
}
@@ -695,7 +687,7 @@ public class DBWriter {
});
}
- /*
+ /**
* Sets the 'read'-attribute of all specified FeedItems
*
* @param played New value of the 'read'-attribute, one of FeedItem.PLAYED, FeedItem.NEW,
@@ -706,7 +698,7 @@ public class DBWriter {
return markItemPlayed(played, true, itemIds);
}
- /*
+ /**
* Sets the 'read'-attribute of all specified FeedItems
*
* @param played New value of the 'read'-attribute, one of FeedItem.PLAYED, FeedItem.NEW,
@@ -972,14 +964,10 @@ public class DBWriter {
adapter.open();
final List<FeedItem> queue = DBReader.getQueue();
- if (queue != null) {
- permutor.reorder(queue);
- adapter.setQueue(queue);
- if (broadcastUpdate) {
- EventBus.getDefault().post(QueueEvent.sorted(queue));
- }
- } else {
- Log.e(TAG, "reorderQueue: Could not load queue");
+ permutor.reorder(queue);
+ adapter.setQueue(queue);
+ if (broadcastUpdate) {
+ EventBus.getDefault().post(QueueEvent.sorted(queue));
}
adapter.close();
});
diff --git a/storage/importexport/src/main/java/de/danoeh/antennapod/storage/importexport/FavoritesWriter.java b/storage/importexport/src/main/java/de/danoeh/antennapod/storage/importexport/FavoritesWriter.java
index 882311fab..21107487d 100644
--- a/storage/importexport/src/main/java/de/danoeh/antennapod/storage/importexport/FavoritesWriter.java
+++ b/storage/importexport/src/main/java/de/danoeh/antennapod/storage/importexport/FavoritesWriter.java
@@ -42,8 +42,8 @@ public class FavoritesWriter {
writer.append(templateParts[0]);
- for (Long feedId : favoriteByFeed.keySet()) {
- List<FeedItem> favorites = favoriteByFeed.get(feedId);
+ for (final Map.Entry<Long, List<FeedItem>> feedId : favoriteByFeed.entrySet()) {
+ final List<FeedItem> favorites = feedId.getValue();
writer.append("<li><div>\n");
writeFeed(writer, favorites.get(0).getFeed(), feedTemplate);