Separated attrs
This commit is contained in:
parent
fac9d00f47
commit
ccad96dd41
12 changed files with 137 additions and 85 deletions
|
@ -177,8 +177,16 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
}
|
||||
|
||||
private fun loadAlbumCover() {
|
||||
/* Glide.with(this).load(RetroUtil.getAlbumArtUri(album.id)).placeholder(R.drawable.default_album_art)
|
||||
.error(R.drawable.default_album_art)
|
||||
.dontTransform()
|
||||
.dontAnimate().into(image)*/
|
||||
|
||||
SongGlideRequest.Builder.from(Glide.with(this), album.safeGetFirstSong())
|
||||
.checkIgnoreMediaStore(this).generatePalette(this).build().dontAnimate().dontTransform()
|
||||
.checkIgnoreMediaStore(this)
|
||||
.ignoreMediaStore(PreferenceUtil.getInstance(this).ignoreMediaStoreArtwork())
|
||||
.generatePalette(this)
|
||||
.build().dontAnimate().dontTransform()
|
||||
.into(object : RetroMusicColoredTarget(image) {
|
||||
override fun onColorReady(color: Int) {
|
||||
setColors(color)
|
||||
|
|
|
@ -41,15 +41,16 @@ import code.name.monkey.retromusic.util.PreferenceUtil;
|
|||
*/
|
||||
public class SongGlideRequest {
|
||||
|
||||
public static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE;
|
||||
public static final int DEFAULT_ERROR_IMAGE = R.drawable.default_album_art;
|
||||
public static final int DEFAULT_ANIMATION = android.R.anim.fade_in;
|
||||
private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE;
|
||||
private static final int DEFAULT_ERROR_IMAGE = R.drawable.default_album_art;
|
||||
private static final int DEFAULT_ANIMATION = android.R.anim.fade_in;
|
||||
|
||||
public static class Builder {
|
||||
final RequestManager requestManager;
|
||||
final Song song;
|
||||
boolean ignoreMediaStore;
|
||||
|
||||
@NonNull
|
||||
public static Builder from(@NonNull RequestManager requestManager, Song song) {
|
||||
return new Builder(requestManager, song);
|
||||
}
|
||||
|
@ -59,23 +60,28 @@ public class SongGlideRequest {
|
|||
this.song = song;
|
||||
}
|
||||
|
||||
public PaletteBuilder generatePalette(Context context) {
|
||||
@NonNull
|
||||
public PaletteBuilder generatePalette(@NonNull Context context) {
|
||||
return new PaletteBuilder(this, context);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public BitmapBuilder asBitmap() {
|
||||
return new BitmapBuilder(this);
|
||||
}
|
||||
|
||||
public Builder checkIgnoreMediaStore(Context context) {
|
||||
@NonNull
|
||||
public Builder checkIgnoreMediaStore(@NonNull Context context) {
|
||||
return ignoreMediaStore(PreferenceUtil.getInstance(context).ignoreMediaStoreArtwork());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder ignoreMediaStore(boolean ignoreMediaStore) {
|
||||
this.ignoreMediaStore = ignoreMediaStore;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public DrawableRequestBuilder<GlideDrawable> build() {
|
||||
//noinspection unchecked
|
||||
return createBaseRequest(requestManager, song, ignoreMediaStore)
|
||||
|
@ -125,7 +131,10 @@ public class SongGlideRequest {
|
|||
}
|
||||
}
|
||||
|
||||
public static DrawableTypeRequest createBaseRequest(RequestManager requestManager, Song song, boolean ignoreMediaStore) {
|
||||
@NonNull
|
||||
private static DrawableTypeRequest createBaseRequest(@NonNull RequestManager requestManager,
|
||||
@NonNull Song song,
|
||||
boolean ignoreMediaStore) {
|
||||
if (ignoreMediaStore) {
|
||||
return requestManager.load(new AudioFileCover(song.getData()));
|
||||
} else {
|
||||
|
@ -133,7 +142,8 @@ public class SongGlideRequest {
|
|||
}
|
||||
}
|
||||
|
||||
public static Key createSignature(Song song) {
|
||||
@NonNull
|
||||
private static Key createSignature(@NonNull Song song) {
|
||||
return new MediaStoreSignature("", song.getDateModified(), 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,10 +58,9 @@ public class MusicUtil {
|
|||
public static final String TAG = MusicUtil.class.getSimpleName();
|
||||
private static Playlist playlist;
|
||||
|
||||
@NonNull
|
||||
public static Uri getMediaStoreAlbumCoverUri(int albumId) {
|
||||
final Uri sArtworkUri = Uri
|
||||
.parse("content://media/external/audio/albumart");
|
||||
|
||||
final Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
|
||||
return ContentUris.withAppendedId(sArtworkUri, albumId);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,10 +58,6 @@ public class RetroUtil {
|
|||
return (int) (dpWidth / 180);
|
||||
}
|
||||
|
||||
public static Uri getAlbumArtUri(long paramInt) {
|
||||
return ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"), paramInt);
|
||||
}
|
||||
|
||||
public static boolean isTablet() {
|
||||
return App.Companion.getContext().getResources().getConfiguration().smallestScreenWidthDp >= 600;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue