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.setAllowMobileImages(true);
break;
default: // Fall-through to "images"
case "images":
UserPreferences.setAllowMobileImages(true);
break;

View File

@ -431,17 +431,14 @@ public class MainActivity extends CastEnabledActivity {
Validate.notNull(fragment);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
switch (transition) {
case FADE:
if (transition == TransitionEffect.FADE) {
transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
break;
case SLIDE:
} 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);
break;
}
transaction

View File

@ -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);

View File

@ -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 {

View File

@ -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>

View File

@ -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 (type == PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD) {
if (playbackService == null && PlaybackService.isRunning) {
bindToService();
return;
}
mediaInfoLoaded = false;
queryService();
break;
case PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END:
} else if (type == PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END) {
onPlaybackEnd();
break;
}
}

View File

@ -531,7 +531,6 @@ 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<>();
@ -540,8 +539,8 @@ public class DBWriter {
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);
Log.e(TAG, "removeQueueItem - item in queue but somehow cannot be loaded."
+ " Item ignored. It should never happen. id:" + itemId);
continue;
}
queue.remove(position);
@ -562,9 +561,6 @@ public class DBWriter {
} else {
Log.w(TAG, "Queue was not modified by call to removeQueueItem");
}
} else {
Log.e(TAG, "removeQueueItem: Could not load queue");
}
adapter.close();
if (performAutoDownload) {
AutoDownloadManager.getInstance().autodownloadUndownloadedItems(context);
@ -670,7 +666,6 @@ 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);
@ -680,9 +675,6 @@ public class DBWriter {
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,15 +964,11 @@ 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");
}
adapter.close();
});
}

View File

@ -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);