Porównaj commity

...

7 Commity

Autor SHA1 Wiadomość Data
Alex 2c1383f75e
Merge 86f1cf2584 into 879d7a24f0 2024-05-07 17:44:46 +00:00
Alex 86f1cf2584
simplified lambda expresions 2024-05-08 00:44:17 +07:00
Alex 8ac87daae4
placed the "default" option at last position 2024-04-28 19:40:56 +07:00
Alex 45de9fc8f2
simplify switch case flow foe Utility 2024-04-27 17:04:32 +07:00
Alex c57f14bca5
simplify switch case flow for DownloadMission 2024-04-27 17:03:24 +07:00
Alex 8e3449180f
simplify switch case flow for DescriprionFragment 2024-04-27 17:01:11 +07:00
Alex c226f11245
simplify controll flows for ChannelTabHelper 2024-04-27 17:00:12 +07:00
6 zmienionych plików z 63 dodań i 127 usunięć

Wyświetl plik

@ -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,

Wyświetl plik

@ -1685,10 +1685,8 @@ public final class VideoDetailFragment
.subscribeOn(Schedulers.io())
.onErrorComplete()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(state -> {
updatePlaybackProgress(
state.getProgressMillis(), info.getDuration() * 1000);
}, e -> {
.subscribe(state -> updatePlaybackProgress(
state.getProgressMillis(), info.getDuration() * 1000), e -> {
// impossible since the onErrorComplete()
}, () -> {
binding.positionView.setVisibility(View.GONE);

Wyświetl plik

@ -500,7 +500,7 @@ public class PlaylistFragment extends BaseListInfoFragment<StreamInfoItem, Playl
final boolean isDurationComplete) {
if (activity != null && headerBinding != null) {
playlistOverallDurationSeconds += list.stream()
.mapToLong(x -> x.getDuration())
.mapToLong(StreamInfoItem::getDuration)
.sum();
headerBinding.playlistStreamCount.setText(
Localization.concatenateStrings(

Wyświetl plik

@ -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,

Wyświetl plik

@ -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;
}
/**

Wyświetl plik

@ -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;
case SUBTITLE -> R.drawable.ic_subtitles;
default -> R.drawable.ic_movie;
};
}
public static String checksum(final StoredFileHelper source, final int algorithmId)