This commit is contained in:
Alex 2024-04-27 10:14:07 +00:00 committed by GitHub
commit 0565226cbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 60 additions and 122 deletions

View File

@ -111,25 +111,13 @@ public class DescriptionFragment extends BaseDescriptionFragment {
private void addPrivacyMetadataItem(final LayoutInflater inflater, final LinearLayout layout) {
if (streamInfo.getPrivacy() != null) {
@StringRes final int contentRes;
switch (streamInfo.getPrivacy()) {
case PUBLIC:
contentRes = R.string.metadata_privacy_public;
break;
case UNLISTED:
contentRes = R.string.metadata_privacy_unlisted;
break;
case PRIVATE:
contentRes = R.string.metadata_privacy_private;
break;
case INTERNAL:
contentRes = R.string.metadata_privacy_internal;
break;
case OTHER:
default:
contentRes = 0;
break;
}
@StringRes final int contentRes = switch (streamInfo.getPrivacy()) {
case PUBLIC -> R.string.metadata_privacy_public;
case UNLISTED -> R.string.metadata_privacy_unlisted;
case PRIVATE -> R.string.metadata_privacy_private;
case INTERNAL -> R.string.metadata_privacy_internal;
default -> 0;
};
if (contentRes != 0) {
addMetadataItem(inflater, layout, false, R.string.metadata_privacy,

View File

@ -47,62 +47,41 @@ public final class ChannelTabHelper {
@StringRes
private static int getShowTabKey(final String tab) {
switch (tab) {
case ChannelTabs.VIDEOS:
return R.string.show_channel_tabs_videos;
case ChannelTabs.TRACKS:
return R.string.show_channel_tabs_tracks;
case ChannelTabs.SHORTS:
return R.string.show_channel_tabs_shorts;
case ChannelTabs.LIVESTREAMS:
return R.string.show_channel_tabs_livestreams;
case ChannelTabs.CHANNELS:
return R.string.show_channel_tabs_channels;
case ChannelTabs.PLAYLISTS:
return R.string.show_channel_tabs_playlists;
case ChannelTabs.ALBUMS:
return R.string.show_channel_tabs_albums;
default:
return -1;
}
return switch (tab) {
case ChannelTabs.VIDEOS -> R.string.show_channel_tabs_videos;
case ChannelTabs.TRACKS -> R.string.show_channel_tabs_tracks;
case ChannelTabs.SHORTS -> R.string.show_channel_tabs_shorts;
case ChannelTabs.LIVESTREAMS -> R.string.show_channel_tabs_livestreams;
case ChannelTabs.CHANNELS -> R.string.show_channel_tabs_channels;
case ChannelTabs.PLAYLISTS -> R.string.show_channel_tabs_playlists;
case ChannelTabs.ALBUMS -> R.string.show_channel_tabs_albums;
default -> -1;
};
}
@StringRes
private static int getFetchFeedTabKey(final String tab) {
switch (tab) {
case ChannelTabs.VIDEOS:
return R.string.fetch_channel_tabs_videos;
case ChannelTabs.TRACKS:
return R.string.fetch_channel_tabs_tracks;
case ChannelTabs.SHORTS:
return R.string.fetch_channel_tabs_shorts;
case ChannelTabs.LIVESTREAMS:
return R.string.fetch_channel_tabs_livestreams;
default:
return -1;
}
return switch (tab) {
case ChannelTabs.VIDEOS -> R.string.fetch_channel_tabs_videos;
case ChannelTabs.TRACKS -> R.string.fetch_channel_tabs_tracks;
case ChannelTabs.SHORTS -> R.string.fetch_channel_tabs_shorts;
case ChannelTabs.LIVESTREAMS -> R.string.fetch_channel_tabs_livestreams;
default -> -1;
};
}
@StringRes
public static int getTranslationKey(final String tab) {
switch (tab) {
case ChannelTabs.VIDEOS:
return R.string.channel_tab_videos;
case ChannelTabs.TRACKS:
return R.string.channel_tab_tracks;
case ChannelTabs.SHORTS:
return R.string.channel_tab_shorts;
case ChannelTabs.LIVESTREAMS:
return R.string.channel_tab_livestreams;
case ChannelTabs.CHANNELS:
return R.string.channel_tab_channels;
case ChannelTabs.PLAYLISTS:
return R.string.channel_tab_playlists;
case ChannelTabs.ALBUMS:
return R.string.channel_tab_albums;
default:
return R.string.unknown_content;
}
return switch (tab) {
case ChannelTabs.VIDEOS -> R.string.channel_tab_videos;
case ChannelTabs.TRACKS -> R.string.channel_tab_tracks;
case ChannelTabs.SHORTS -> R.string.channel_tab_shorts;
case ChannelTabs.LIVESTREAMS -> R.string.channel_tab_livestreams;
case ChannelTabs.CHANNELS -> R.string.channel_tab_channels;
case ChannelTabs.PLAYLISTS -> R.string.channel_tab_playlists;
case ChannelTabs.ALBUMS -> R.string.channel_tab_albums;
default -> R.string.unknown_content;
};
}
public static boolean showChannelTab(final Context context,

View File

@ -396,17 +396,11 @@ public class DownloadMission extends Mission {
}
private void notifyPostProcessing(int state) {
String action;
switch (state) {
case 1:
action = "Running";
break;
case 2:
action = "Completed";
break;
default:
action = "Failed";
}
String action = switch (state) {
case 1 -> "Running";
case 2 -> "Completed";
default -> "Failed";
};
Log.d(TAG, action + " postprocessing on " + storage.getName());
@ -590,13 +584,11 @@ public class DownloadMission extends Mission {
* @return {@code true} if this mission is unrecoverable
*/
public boolean isPsFailed() {
switch (errCode) {
case ERROR_POSTPROCESSING:
case ERROR_POSTPROCESSING_STOPPED:
return psAlgorithm.worksOnSameFile;
}
return switch (errCode) {
case ERROR_POSTPROCESSING, ERROR_POSTPROCESSING_STOPPED -> psAlgorithm.worksOnSameFile;
default -> false;
};
return false;
}
/**

View File

@ -139,56 +139,35 @@ public class Utility {
@ColorInt
public static int getBackgroundForFileType(Context ctx, FileType type) {
int colorRes;
switch (type) {
case MUSIC:
colorRes = R.color.audio_left_to_load_color;
break;
case VIDEO:
colorRes = R.color.video_left_to_load_color;
break;
case SUBTITLE:
colorRes = R.color.subtitle_left_to_load_color;
break;
default:
colorRes = R.color.gray;
}
int colorRes = switch (type) {
case MUSIC -> R.color.audio_left_to_load_color;
case VIDEO -> R.color.video_left_to_load_color;
case SUBTITLE -> R.color.subtitle_left_to_load_color;
default -> R.color.gray;
};
return ContextCompat.getColor(ctx, colorRes);
}
@ColorInt
public static int getForegroundForFileType(Context ctx, FileType type) {
int colorRes;
switch (type) {
case MUSIC:
colorRes = R.color.audio_already_load_color;
break;
case VIDEO:
colorRes = R.color.video_already_load_color;
break;
case SUBTITLE:
colorRes = R.color.subtitle_already_load_color;
break;
default:
colorRes = R.color.gray;
break;
}
int colorRes = switch (type) {
case MUSIC -> R.color.audio_already_load_color;
case VIDEO -> R.color.video_already_load_color;
case SUBTITLE -> R.color.subtitle_already_load_color;
default -> R.color.gray;
};
return ContextCompat.getColor(ctx, colorRes);
}
@DrawableRes
public static int getIconForFileType(FileType type) {
switch (type) {
case MUSIC:
return R.drawable.ic_headset;
default:
case VIDEO:
return R.drawable.ic_movie;
case SUBTITLE:
return R.drawable.ic_subtitles;
}
return switch (type) {
case MUSIC -> R.drawable.ic_headset;
default -> R.drawable.ic_movie;
case SUBTITLE -> R.drawable.ic_subtitles;
};
}
public static String checksum(final StoredFileHelper source, final int algorithmId)