Spotbugs cleanup part 2 (#7204)
This commit is contained in:
parent
46a409ad34
commit
c51656f8e7
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue