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.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;
|
||||||
|
|
|
@ -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);
|
} else if (transition == TransitionEffect.SLIDE) {
|
||||||
break;
|
transaction.setCustomAnimations(
|
||||||
case SLIDE:
|
R.anim.slide_right_in,
|
||||||
transaction.setCustomAnimations(
|
R.anim.slide_left_out,
|
||||||
R.anim.slide_right_in,
|
R.anim.slide_left_in,
|
||||||
R.anim.slide_left_out,
|
R.anim.slide_right_out);
|
||||||
R.anim.slide_left_in,
|
|
||||||
R.anim.slide_right_out);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction
|
transaction
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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();
|
} else if (type == PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END) {
|
||||||
break;
|
onPlaybackEnd();
|
||||||
case PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END:
|
|
||||||
onPlaybackEnd();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -531,39 +531,35 @@ 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<>();
|
for (long itemId : itemIds) {
|
||||||
for (long itemId : itemIds) {
|
int position = indexInItemList(queue, itemId);
|
||||||
int position = indexInItemList(queue, itemId);
|
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);
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
queue.remove(position);
|
||||||
if (queueModified) {
|
item.removeTag(FeedItem.TAG_QUEUE);
|
||||||
adapter.setQueue(queue);
|
events.add(QueueEvent.removed(item));
|
||||||
for (QueueEvent event : events) {
|
updatedItems.add(item);
|
||||||
EventBus.getDefault().post(event);
|
queueModified = true;
|
||||||
}
|
|
||||||
EventBus.getDefault().post(FeedItemEvent.updated(updatedItems));
|
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
Log.e(TAG, "removeQueueItem: Could not load queue");
|
Log.w(TAG, "Queue was not modified by call to removeQueueItem");
|
||||||
}
|
}
|
||||||
adapter.close();
|
adapter.close();
|
||||||
if (performAutoDownload) {
|
if (performAutoDownload) {
|
||||||
|
@ -670,18 +666,14 @@ 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);
|
|
||||||
|
|
||||||
adapter.setQueue(queue);
|
adapter.setQueue(queue);
|
||||||
if (broadcastUpdate) {
|
if (broadcastUpdate) {
|
||||||
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,14 +964,10 @@ 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();
|
||||||
});
|
});
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue