simplify switch case flow foe Utility
This commit is contained in:
parent
c57f14bca5
commit
45de9fc8f2
|
@ -153,56 +153,35 @@ public class Utility {
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
public static int getBackgroundForFileType(Context ctx, FileType type) {
|
public static int getBackgroundForFileType(Context ctx, FileType type) {
|
||||||
int colorRes;
|
int colorRes = switch (type) {
|
||||||
switch (type) {
|
case MUSIC -> R.color.audio_left_to_load_color;
|
||||||
case MUSIC:
|
case VIDEO -> R.color.video_left_to_load_color;
|
||||||
colorRes = R.color.audio_left_to_load_color;
|
case SUBTITLE -> R.color.subtitle_left_to_load_color;
|
||||||
break;
|
default -> R.color.gray;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ContextCompat.getColor(ctx, colorRes);
|
return ContextCompat.getColor(ctx, colorRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
public static int getForegroundForFileType(Context ctx, FileType type) {
|
public static int getForegroundForFileType(Context ctx, FileType type) {
|
||||||
int colorRes;
|
int colorRes = switch (type) {
|
||||||
switch (type) {
|
case MUSIC -> R.color.audio_already_load_color;
|
||||||
case MUSIC:
|
case VIDEO -> R.color.video_already_load_color;
|
||||||
colorRes = R.color.audio_already_load_color;
|
case SUBTITLE -> R.color.subtitle_already_load_color;
|
||||||
break;
|
default -> R.color.gray;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ContextCompat.getColor(ctx, colorRes);
|
return ContextCompat.getColor(ctx, colorRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
public static int getIconForFileType(FileType type) {
|
public static int getIconForFileType(FileType type) {
|
||||||
switch (type) {
|
return switch (type) {
|
||||||
case MUSIC:
|
case MUSIC -> R.drawable.ic_headset;
|
||||||
return R.drawable.ic_headset;
|
default -> R.drawable.ic_movie;
|
||||||
default:
|
case SUBTITLE -> R.drawable.ic_subtitles;
|
||||||
case VIDEO:
|
};
|
||||||
return R.drawable.ic_movie;
|
|
||||||
case SUBTITLE:
|
|
||||||
return R.drawable.ic_subtitles;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String checksum(final StoredFileHelper source, final int algorithmId)
|
public static String checksum(final StoredFileHelper source, final int algorithmId)
|
||||||
|
|
Loading…
Reference in New Issue