Skip to content

Commit b906465

Browse files
committed
Address non-final resource IDs warnings
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
1 parent 83f9646 commit b906465

10 files changed

Lines changed: 366 additions & 405 deletions

File tree

app/src/main/java/org/schabi/newpipe/MainActivity.java

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -309,25 +309,21 @@ private void addDrawerMenuForCurrentService() throws ExtractionException {
309309
}
310310

311311
private boolean drawerItemSelected(final MenuItem item) {
312-
switch (item.getGroupId()) {
313-
case R.id.menu_services_group:
314-
changeService(item);
315-
break;
316-
case R.id.menu_tabs_group:
317-
tabSelected(item);
318-
break;
319-
case R.id.menu_kiosks_group:
320-
try {
321-
kioskSelected(item);
322-
} catch (final Exception e) {
323-
ErrorUtil.showUiErrorSnackbar(this, "Selecting drawer kiosk", e);
324-
}
325-
break;
326-
case R.id.menu_options_about_group:
327-
optionsAboutSelected(item);
328-
break;
329-
default:
330-
return false;
312+
final int groupId = item.getGroupId();
313+
if (groupId == R.id.menu_services_group) {
314+
changeService(item);
315+
} else if (groupId == R.id.menu_tabs_group) {
316+
tabSelected(item);
317+
} else if (groupId == R.id.menu_kiosks_group) {
318+
try {
319+
kioskSelected(item);
320+
} catch (final Exception e) {
321+
ErrorUtil.showUiErrorSnackbar(this, "Selecting drawer kiosk", e);
322+
}
323+
} else if (groupId == R.id.menu_options_about_group) {
324+
optionsAboutSelected(item);
325+
} else {
326+
return false;
331327
}
332328

333329
mainBinding.getRoot().closeDrawers();

app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -41,50 +41,50 @@ public static void openPopupMenu(final PlayQueue playQueue,
4141
}
4242

4343
popupMenu.setOnMenuItemClickListener(menuItem -> {
44-
switch (menuItem.getItemId()) {
45-
case R.id.menu_item_remove:
46-
final int index = playQueue.indexOf(item);
47-
playQueue.remove(index);
48-
return true;
49-
case R.id.menu_item_details:
50-
// playQueue is null since we don't want any queue change
51-
NavigationHelper.openVideoDetail(context, item.getServiceId(),
52-
item.getUrl(), item.getTitle(), null,
53-
false);
54-
return true;
55-
case R.id.menu_item_append_playlist:
56-
PlaylistDialog.createCorrespondingDialog(
57-
context,
58-
List.of(new StreamEntity(item)),
59-
dialog -> dialog.show(
60-
fragmentManager,
61-
"QueueItemMenuUtil@append_playlist"
62-
)
63-
);
44+
final int itemId = menuItem.getItemId();
45+
if (itemId == R.id.menu_item_remove) {
46+
final int index = playQueue.indexOf(item);
47+
playQueue.remove(index);
48+
return true;
49+
} else if (itemId == R.id.menu_item_details) {
50+
// playQueue is null since we don't want any queue change
51+
NavigationHelper.openVideoDetail(context, item.getServiceId(),
52+
item.getUrl(), item.getTitle(), null,
53+
false);
54+
return true;
55+
} else if (itemId == R.id.menu_item_append_playlist) {
56+
PlaylistDialog.createCorrespondingDialog(
57+
context,
58+
List.of(new StreamEntity(item)),
59+
dialog -> dialog.show(
60+
fragmentManager,
61+
"QueueItemMenuUtil@append_playlist"
62+
)
63+
);
6464

65-
return true;
66-
case R.id.menu_item_channel_details:
67-
SparseItemUtil.fetchUploaderUrlIfSparse(context, item.getServiceId(),
68-
item.getUrl(), item.getUploaderUrl(),
69-
// An intent must be used here.
70-
// Opening with FragmentManager transactions is not working,
71-
// as PlayQueueActivity doesn't use fragments.
72-
uploaderUrl -> NavigationHelper.openChannelFragmentUsingIntent(
73-
context, item.getServiceId(), uploaderUrl, item.getUploader()
74-
));
75-
return true;
76-
case R.id.menu_item_share:
77-
shareText(context, item.getTitle(), item.getUrl(),
78-
item.getThumbnails());
79-
return true;
80-
case R.id.menu_item_download:
81-
fetchStreamInfoAndSaveToDatabase(context, item.getServiceId(), item.getUrl(),
82-
info -> {
83-
final DownloadDialog downloadDialog = new DownloadDialog(context,
84-
info);
85-
downloadDialog.show(fragmentManager, "downloadDialog");
86-
});
87-
return true;
65+
return true;
66+
} else if (itemId == R.id.menu_item_channel_details) {
67+
SparseItemUtil.fetchUploaderUrlIfSparse(context, item.getServiceId(),
68+
item.getUrl(), item.getUploaderUrl(),
69+
// An intent must be used here.
70+
// Opening with FragmentManager transactions is not working,
71+
// as PlayQueueActivity doesn't use fragments.
72+
uploaderUrl -> NavigationHelper.openChannelFragmentUsingIntent(
73+
context, item.getServiceId(), uploaderUrl, item.getUploader()
74+
));
75+
return true;
76+
} else if (itemId == R.id.menu_item_share) {
77+
shareText(context, item.getTitle(), item.getUrl(),
78+
item.getThumbnails());
79+
return true;
80+
} else if (itemId == R.id.menu_item_download) {
81+
fetchStreamInfoAndSaveToDatabase(context, item.getServiceId(), item.getUrl(),
82+
info -> {
83+
final DownloadDialog downloadDialog = new DownloadDialog(context,
84+
info);
85+
downloadDialog.show(fragmentManager, "downloadDialog");
86+
});
87+
return true;
8888
}
8989
return false;
9090
});

0 commit comments

Comments
 (0)