diff options
author | TacoTheDank <SkytkRSfan3895@gmail.com> | 2021-07-22 16:49:50 -0400 |
---|---|---|
committer | TacoTheDank <SkytkRSfan3895@gmail.com> | 2021-07-22 16:49:50 -0400 |
commit | 47ac240f56dd7cb3eab81b040bfbcae62d1341e8 (patch) | |
tree | 3b7c02230a7a33364fca4e679a542d607c14f6be /app/src/main/java/de/danoeh/antennapod/menuhandler | |
parent | fdaf5394d93ff4f9a31109f1161e48ffe1bc7ec7 (diff) | |
download | AntennaPod-47ac240f56dd7cb3eab81b040bfbcae62d1341e8.zip |
Fix NonConstantResourceId code lint errors
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/menuhandler')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java | 115 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java | 68 |
2 files changed, 81 insertions, 102 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java index e542f94d2..c272af7d5 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java @@ -142,73 +142,60 @@ public class FeedItemMenuHandler { @NonNull FeedItem selectedItem) { @NonNull Context context = fragment.requireContext(); - switch (menuItemId) { - case R.id.skip_episode_item: - IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SKIP_CURRENT_EPISODE); - break; - case R.id.remove_item: - DBWriter.deleteFeedMediaOfItem(context, selectedItem.getMedia().getId()); - break; - case R.id.remove_new_flag_item: - removeNewFlagWithUndo(fragment, selectedItem); - break; - case R.id.mark_read_item: - selectedItem.setPlayed(true); - DBWriter.markItemPlayed(selectedItem, FeedItem.PLAYED, true); - if (GpodnetPreferences.loggedIn()) { - FeedMedia media = selectedItem.getMedia(); - // not all items have media, Gpodder only cares about those that do - if (media != null) { - EpisodeAction actionPlay = new EpisodeAction.Builder(selectedItem, EpisodeAction.PLAY) - .currentTimestamp() - .started(media.getDuration() / 1000) - .position(media.getDuration() / 1000) - .total(media.getDuration() / 1000) - .build(); - SyncService.enqueueEpisodeAction(context, actionPlay); - } - } - break; - case R.id.mark_unread_item: - selectedItem.setPlayed(false); - DBWriter.markItemPlayed(selectedItem, FeedItem.UNPLAYED, false); - if (GpodnetPreferences.loggedIn() && selectedItem.getMedia() != null) { - EpisodeAction actionNew = new EpisodeAction.Builder(selectedItem, EpisodeAction.NEW) + if (menuItemId == R.id.skip_episode_item) { + IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SKIP_CURRENT_EPISODE); + } else if (menuItemId == R.id.remove_item) { + DBWriter.deleteFeedMediaOfItem(context, selectedItem.getMedia().getId()); + } else if (menuItemId == R.id.remove_new_flag_item) { + removeNewFlagWithUndo(fragment, selectedItem); + } else if (menuItemId == R.id.mark_read_item) { + selectedItem.setPlayed(true); + DBWriter.markItemPlayed(selectedItem, FeedItem.PLAYED, true); + if (GpodnetPreferences.loggedIn()) { + FeedMedia media = selectedItem.getMedia(); + // not all items have media, Gpodder only cares about those that do + if (media != null) { + EpisodeAction actionPlay = new EpisodeAction.Builder(selectedItem, EpisodeAction.PLAY) .currentTimestamp() + .started(media.getDuration() / 1000) + .position(media.getDuration() / 1000) + .total(media.getDuration() / 1000) .build(); - SyncService.enqueueEpisodeAction(context, actionNew); - } - break; - case R.id.add_to_queue_item: - DBWriter.addQueueItem(context, selectedItem); - break; - case R.id.remove_from_queue_item: - DBWriter.removeQueueItem(context, true, selectedItem); - break; - case R.id.add_to_favorites_item: - DBWriter.addFavoriteItem(selectedItem); - break; - case R.id.remove_from_favorites_item: - DBWriter.removeFavoriteItem(selectedItem); - break; - case R.id.reset_position: - selectedItem.getMedia().setPosition(0); - if (PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == selectedItem.getMedia().getId()) { - PlaybackPreferences.writeNoMediaPlaying(); - IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE); + SyncService.enqueueEpisodeAction(context, actionPlay); } - DBWriter.markItemPlayed(selectedItem, FeedItem.UNPLAYED, true); - break; - case R.id.visit_website_item: - IntentUtils.openInBrowser(context, FeedItemUtil.getLinkWithFallback(selectedItem)); - break; - case R.id.share_item: - ShareDialog shareDialog = ShareDialog.newInstance(selectedItem); - shareDialog.show((fragment.getActivity().getSupportFragmentManager()), "ShareEpisodeDialog"); - break; - default: - Log.d(TAG, "Unknown menuItemId: " + menuItemId); - return false; + } + } else if (menuItemId == R.id.mark_unread_item) { + selectedItem.setPlayed(false); + DBWriter.markItemPlayed(selectedItem, FeedItem.UNPLAYED, false); + if (GpodnetPreferences.loggedIn() && selectedItem.getMedia() != null) { + EpisodeAction actionNew = new EpisodeAction.Builder(selectedItem, EpisodeAction.NEW) + .currentTimestamp() + .build(); + SyncService.enqueueEpisodeAction(context, actionNew); + } + } else if (menuItemId == R.id.add_to_queue_item) { + DBWriter.addQueueItem(context, selectedItem); + } else if (menuItemId == R.id.remove_from_queue_item) { + DBWriter.removeQueueItem(context, true, selectedItem); + } else if (menuItemId == R.id.add_to_favorites_item) { + DBWriter.addFavoriteItem(selectedItem); + } else if (menuItemId == R.id.remove_from_favorites_item) { + DBWriter.removeFavoriteItem(selectedItem); + } else if (menuItemId == R.id.reset_position) { + selectedItem.getMedia().setPosition(0); + if (PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == selectedItem.getMedia().getId()) { + PlaybackPreferences.writeNoMediaPlaying(); + IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE); + } + DBWriter.markItemPlayed(selectedItem, FeedItem.UNPLAYED, true); + } else if (menuItemId == R.id.visit_website_item) { + IntentUtils.openInBrowser(context, FeedItemUtil.getLinkWithFallback(selectedItem)); + } else if (menuItemId == R.id.share_item) { + ShareDialog shareDialog = ShareDialog.newInstance(selectedItem); + shareDialog.show((fragment.getActivity().getSupportFragmentManager()), "ShareEpisodeDialog"); + } else { + Log.d(TAG, "Unknown menuItemId: " + menuItemId); + return false; } // Refresh menu state diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java index ed0cac05d..fded5fb34 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java @@ -60,44 +60,36 @@ public class FeedMenuHandler { */ public static boolean onOptionsItemClicked(final Context context, final MenuItem item, final Feed selectedFeed) throws DownloadRequestException { - switch (item.getItemId()) { - case R.id.refresh_item: - DBTasks.forceRefreshFeed(context, selectedFeed, true); - break; - case R.id.refresh_complete_item: - DBTasks.forceRefreshCompleteFeed(context, selectedFeed); - break; - case R.id.sort_items: - showSortDialog(context, selectedFeed); - break; - case R.id.filter_items: - showFilterDialog(context, selectedFeed); - break; - case R.id.mark_all_read_item: - ConfirmationDialog conDialog = new ConfirmationDialog(context, - R.string.mark_all_read_label, - R.string.mark_all_read_feed_confirmation_msg) { - - @Override - public void onConfirmButtonPressed( - DialogInterface dialog) { - dialog.dismiss(); - DBWriter.markFeedRead(selectedFeed.getId()); - } - }; - conDialog.createNewDialog().show(); - break; - case R.id.visit_website_item: - IntentUtils.openInBrowser(context, selectedFeed.getLink()); - break; - case R.id.share_link_item: - ShareUtils.shareFeedlink(context, selectedFeed); - break; - case R.id.share_download_url_item: - ShareUtils.shareFeedDownloadLink(context, selectedFeed); - break; - default: - return false; + final int itemId = item.getItemId(); + if (itemId == R.id.refresh_item) { + DBTasks.forceRefreshFeed(context, selectedFeed, true); + } else if (itemId == R.id.refresh_complete_item) { + DBTasks.forceRefreshCompleteFeed(context, selectedFeed); + } else if (itemId == R.id.sort_items) { + showSortDialog(context, selectedFeed); + } else if (itemId == R.id.filter_items) { + showFilterDialog(context, selectedFeed); + } else if (itemId == R.id.mark_all_read_item) { + ConfirmationDialog conDialog = new ConfirmationDialog(context, + R.string.mark_all_read_label, + R.string.mark_all_read_feed_confirmation_msg) { + + @Override + public void onConfirmButtonPressed( + DialogInterface dialog) { + dialog.dismiss(); + DBWriter.markFeedRead(selectedFeed.getId()); + } + }; + conDialog.createNewDialog().show(); + } else if (itemId == R.id.visit_website_item) { + IntentUtils.openInBrowser(context, selectedFeed.getLink()); + } else if (itemId == R.id.share_link_item) { + ShareUtils.shareFeedlink(context, selectedFeed); + } else if (itemId == R.id.share_download_url_item) { + ShareUtils.shareFeedDownloadLink(context, selectedFeed); + } else { + return false; } return true; } |