Spotbugs cleanup part 2 (#7204)

This commit is contained in:
Taco 2024-06-09 14:47:49 -04:00 committed by GitHub
parent 46a409ad34
commit c51656f8e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 61 additions and 82 deletions

View File

@ -68,6 +68,7 @@ public class PreferenceUpgrader {
UserPreferences.setAllowMobileEpisodeDownload(true); UserPreferences.setAllowMobileEpisodeDownload(true);
UserPreferences.setAllowMobileImages(true); UserPreferences.setAllowMobileImages(true);
break; break;
default: // Fall-through to "images"
case "images": case "images":
UserPreferences.setAllowMobileImages(true); UserPreferences.setAllowMobileImages(true);
break; break;

View File

@ -431,17 +431,14 @@ public class MainActivity extends CastEnabledActivity {
Validate.notNull(fragment); Validate.notNull(fragment);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
switch (transition) { if (transition == TransitionEffect.FADE) {
case FADE:
transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out); transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
break; } else if (transition == TransitionEffect.SLIDE) {
case SLIDE:
transaction.setCustomAnimations( transaction.setCustomAnimations(
R.anim.slide_right_in, R.anim.slide_right_in,
R.anim.slide_left_out, R.anim.slide_left_out,
R.anim.slide_left_in, R.anim.slide_left_in,
R.anim.slide_right_out); R.anim.slide_right_out);
break;
} }
transaction transaction

View File

@ -450,7 +450,7 @@ public class FeedSettingsFragment extends Fragment {
pref.setChecked(feedPreferences.getKeepUpdated()); pref.setChecked(feedPreferences.getKeepUpdated());
pref.setOnPreferenceChangeListener((preference, newValue) -> { pref.setOnPreferenceChangeListener((preference, newValue) -> {
boolean checked = newValue == Boolean.TRUE; boolean checked = Boolean.TRUE.equals(newValue);
feedPreferences.setKeepUpdated(checked); feedPreferences.setKeepUpdated(checked);
DBWriter.setFeedPreferences(feedPreferences); DBWriter.setFeedPreferences(feedPreferences);
pref.setChecked(checked); pref.setChecked(checked);
@ -480,7 +480,7 @@ public class FeedSettingsFragment extends Fragment {
} }
pref.setOnPreferenceChangeListener((preference, newValue) -> { pref.setOnPreferenceChangeListener((preference, newValue) -> {
boolean checked = newValue == Boolean.TRUE; boolean checked = Boolean.TRUE.equals(newValue);
feedPreferences.setAutoDownload(checked); feedPreferences.setAutoDownload(checked);
DBWriter.setFeedPreferences(feedPreferences); DBWriter.setFeedPreferences(feedPreferences);
@ -515,7 +515,7 @@ public class FeedSettingsFragment extends Fragment {
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS); requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
return false; return false;
} }
boolean checked = newValue == Boolean.TRUE; boolean checked = Boolean.TRUE.equals(newValue);
feedPreferences.setShowEpisodeNotification(checked); feedPreferences.setShowEpisodeNotification(checked);
DBWriter.setFeedPreferences(feedPreferences); DBWriter.setFeedPreferences(feedPreferences);
pref.setChecked(checked); pref.setChecked(checked);

View File

@ -39,7 +39,7 @@ public class AutomaticDeletionPreferencesFragment extends PreferenceFragmentComp
findPreference(UserPreferences.PREF_EPISODE_CLEANUP).setSummary(R.string.auto_download_disabled_globally); findPreference(UserPreferences.PREF_EPISODE_CLEANUP).setSummary(R.string.auto_download_disabled_globally);
} }
findPreference(PREF_AUTO_DELETE_LOCAL).setOnPreferenceChangeListener((preference, newValue) -> { findPreference(PREF_AUTO_DELETE_LOCAL).setOnPreferenceChangeListener((preference, newValue) -> {
if (blockAutoDeleteLocal && newValue == Boolean.TRUE) { if (blockAutoDeleteLocal && newValue.equals(Boolean.TRUE)) {
showAutoDeleteEnableDialog(); showAutoDeleteEnableDialog();
return false; return false;
} else { } else {

View File

@ -80,14 +80,10 @@
<Match><Bug pattern="IS2_INCONSISTENT_SYNC"/></Match> <Match><Bug pattern="IS2_INCONSISTENT_SYNC"/></Match>
<Match><Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/></Match> <Match><Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/></Match>
<Match><Bug pattern="OS_OPEN_STREAM"/></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="RV_RETURN_VALUE_IGNORED"/></Match>
<Match><Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE"/></Match> <Match><Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE"/></Match>
<Match><Bug pattern="SE_NO_SERIALVERSIONID"/></Match> <Match><Bug pattern="SE_NO_SERIALVERSIONID"/></Match>
<Match><Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/></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="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/></Match>
<Match><Bug pattern="VA_FORMAT_STRING_USES_NEWLINE"/></Match> <Match><Bug pattern="VA_FORMAT_STRING_USES_NEWLINE"/></Match>
<Match><Bug pattern="WMI_WRONG_MAP_ITERATOR"/></Match>
</FindBugsFilter> </FindBugsFilter>

View File

@ -208,18 +208,15 @@ public abstract class PlaybackController {
Log.d(TAG, "Bad arguments. Won't handle intent"); Log.d(TAG, "Bad arguments. Won't handle intent");
return; return;
} }
switch (type) { if (type == PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD) {
case PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD:
if (playbackService == null && PlaybackService.isRunning) { if (playbackService == null && PlaybackService.isRunning) {
bindToService(); bindToService();
return; return;
} }
mediaInfoLoaded = false; mediaInfoLoaded = false;
queryService(); queryService();
break; } else if (type == PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END) {
case PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END:
onPlaybackEnd(); onPlaybackEnd();
break;
} }
} }

View File

@ -531,7 +531,6 @@ public class DBWriter {
adapter.open(); adapter.open();
final List<FeedItem> queue = DBReader.getQueue(); final List<FeedItem> queue = DBReader.getQueue();
if (queue != null) {
boolean queueModified = false; boolean queueModified = false;
List<QueueEvent> events = new ArrayList<>(); List<QueueEvent> events = new ArrayList<>();
List<FeedItem> updatedItems = new ArrayList<>(); List<FeedItem> updatedItems = new ArrayList<>();
@ -540,8 +539,8 @@ public class DBWriter {
if (position >= 0) { if (position >= 0) {
final FeedItem item = DBReader.getFeedItem(itemId); final FeedItem item = DBReader.getFeedItem(itemId);
if (item == null) { if (item == null) {
Log.e(TAG, "removeQueueItem - item in queue but somehow cannot be loaded." + Log.e(TAG, "removeQueueItem - item in queue but somehow cannot be loaded."
" Item ignored. It should never happen. id:" + itemId); + " Item ignored. It should never happen. id:" + itemId);
continue; continue;
} }
queue.remove(position); queue.remove(position);
@ -562,9 +561,6 @@ public class DBWriter {
} else { } else {
Log.w(TAG, "Queue was not modified by call to removeQueueItem"); Log.w(TAG, "Queue was not modified by call to removeQueueItem");
} }
} else {
Log.e(TAG, "removeQueueItem: Could not load queue");
}
adapter.close(); adapter.close();
if (performAutoDownload) { if (performAutoDownload) {
AutoDownloadManager.getInstance().autodownloadUndownloadedItems(context); AutoDownloadManager.getInstance().autodownloadUndownloadedItems(context);
@ -670,7 +666,6 @@ public class DBWriter {
adapter.open(); adapter.open();
final List<FeedItem> queue = DBReader.getQueue(); final List<FeedItem> queue = DBReader.getQueue();
if (queue != null) {
if (from >= 0 && from < queue.size() && to >= 0 && to < queue.size()) { if (from >= 0 && from < queue.size() && to >= 0 && to < queue.size()) {
final FeedItem item = queue.remove(from); final FeedItem item = queue.remove(from);
queue.add(to, item); queue.add(to, item);
@ -680,9 +675,6 @@ public class DBWriter {
EventBus.getDefault().post(QueueEvent.moved(item, to)); EventBus.getDefault().post(QueueEvent.moved(item, to));
} }
} }
} else {
Log.e(TAG, "moveQueueItemHelper: Could not load queue");
}
adapter.close(); adapter.close();
} }
@ -695,7 +687,7 @@ public class DBWriter {
}); });
} }
/* /**
* Sets the 'read'-attribute of all specified FeedItems * Sets the 'read'-attribute of all specified FeedItems
* *
* @param played New value of the 'read'-attribute, one of FeedItem.PLAYED, FeedItem.NEW, * @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); return markItemPlayed(played, true, itemIds);
} }
/* /**
* Sets the 'read'-attribute of all specified FeedItems * Sets the 'read'-attribute of all specified FeedItems
* *
* @param played New value of the 'read'-attribute, one of FeedItem.PLAYED, FeedItem.NEW, * @param played New value of the 'read'-attribute, one of FeedItem.PLAYED, FeedItem.NEW,
@ -972,15 +964,11 @@ public class DBWriter {
adapter.open(); adapter.open();
final List<FeedItem> queue = DBReader.getQueue(); final List<FeedItem> queue = DBReader.getQueue();
if (queue != null) {
permutor.reorder(queue); permutor.reorder(queue);
adapter.setQueue(queue); adapter.setQueue(queue);
if (broadcastUpdate) { if (broadcastUpdate) {
EventBus.getDefault().post(QueueEvent.sorted(queue)); EventBus.getDefault().post(QueueEvent.sorted(queue));
} }
} else {
Log.e(TAG, "reorderQueue: Could not load queue");
}
adapter.close(); adapter.close();
}); });
} }

View File

@ -42,8 +42,8 @@ public class FavoritesWriter {
writer.append(templateParts[0]); writer.append(templateParts[0]);
for (Long feedId : favoriteByFeed.keySet()) { for (final Map.Entry<Long, List<FeedItem>> feedId : favoriteByFeed.entrySet()) {
List<FeedItem> favorites = favoriteByFeed.get(feedId); final List<FeedItem> favorites = feedId.getValue();
writer.append("<li><div>\n"); writer.append("<li><div>\n");
writeFeed(writer, favorites.get(0).getFeed(), feedTemplate); writeFeed(writer, favorites.get(0).getFeed(), feedTemplate);