Code refactor
This commit is contained in:
parent
27ec1a0ce1
commit
1dc0a8fcc0
1 changed files with 1 additions and 111 deletions
|
@ -159,113 +159,3 @@ public class ArtistGlideRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
|
||||||
*//*
|
|
||||||
public class ArtistGlideRequest {
|
|
||||||
|
|
||||||
public static final int DEFAULT_ANIMATION = android.R.anim.fade_in;
|
|
||||||
private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.ALL;
|
|
||||||
private static final int DEFAULT_ERROR_IMAGE = R.drawable.default_artist_art;
|
|
||||||
|
|
||||||
public static DrawableTypeRequest createBaseRequest(RequestManager requestManager, Artist artist, boolean noCustomImage) {
|
|
||||||
boolean hasCustomImage = CustomArtistImageUtil.Companion.getInstance(App.Companion.getContext()).hasCustomArtistImage(artist);
|
|
||||||
if (noCustomImage || !hasCustomImage) {
|
|
||||||
final List<AlbumCover> songs = new ArrayList<>();
|
|
||||||
for (final Album album : artist.getAlbums()) {
|
|
||||||
final Song song = album.safeGetFirstSong();
|
|
||||||
songs.add(new AlbumCover(album.getYear(), song.getData()));
|
|
||||||
}
|
|
||||||
return requestManager.load(new ArtistImage(artist.getName(), songs));
|
|
||||||
} else {
|
|
||||||
return requestManager.load(CustomArtistImageUtil.getFile(artist));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Key createSignature(Artist artist) {
|
|
||||||
return ArtistSignatureUtil.getInstance(App.Companion.getContext()).getArtistSignature(artist.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
final RequestManager requestManager;
|
|
||||||
final Artist artist;
|
|
||||||
boolean noCustomImage;
|
|
||||||
|
|
||||||
private Builder(@NonNull RequestManager requestManager, Artist artist) {
|
|
||||||
this.requestManager = requestManager;
|
|
||||||
this.artist = artist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder from(@NonNull RequestManager requestManager, Artist artist) {
|
|
||||||
return new Builder(requestManager, artist);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PaletteBuilder generatePalette(Context context) {
|
|
||||||
return new PaletteBuilder(this, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BitmapBuilder asBitmap() {
|
|
||||||
return new BitmapBuilder(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder noCustomImage(boolean noCustomImage) {
|
|
||||||
this.noCustomImage = noCustomImage;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrawableRequestBuilder<GlideDrawable> build() {
|
|
||||||
//noinspection unchecked
|
|
||||||
return createBaseRequest(requestManager, artist, noCustomImage)
|
|
||||||
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
|
||||||
.error(DEFAULT_ERROR_IMAGE)
|
|
||||||
.animate(DEFAULT_ANIMATION)
|
|
||||||
.priority(Priority.LOW)
|
|
||||||
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
|
|
||||||
.signature(createSignature(artist));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class BitmapBuilder {
|
|
||||||
private final Builder builder;
|
|
||||||
|
|
||||||
public BitmapBuilder(Builder builder) {
|
|
||||||
this.builder = builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BitmapRequestBuilder<?, Bitmap> build() {
|
|
||||||
//noinspection unchecked
|
|
||||||
return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage)
|
|
||||||
.asBitmap()
|
|
||||||
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
|
||||||
.error(DEFAULT_ERROR_IMAGE)
|
|
||||||
.animate(DEFAULT_ANIMATION)
|
|
||||||
.priority(Priority.LOW)
|
|
||||||
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
|
|
||||||
.signature(createSignature(builder.artist));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PaletteBuilder {
|
|
||||||
final Context context;
|
|
||||||
private final Builder builder;
|
|
||||||
|
|
||||||
public PaletteBuilder(Builder builder, Context context) {
|
|
||||||
this.builder = builder;
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() {
|
|
||||||
//noinspection unchecked
|
|
||||||
return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage)
|
|
||||||
.asBitmap()
|
|
||||||
.transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
|
|
||||||
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
|
||||||
.error(DEFAULT_ERROR_IMAGE)
|
|
||||||
.animate(DEFAULT_ANIMATION)
|
|
||||||
.priority(Priority.LOW)
|
|
||||||
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
|
|
||||||
.signature(createSignature(builder.artist));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue