Improved time for opening Album, Artist or Now Playing screen
This commit is contained in:
parent
e5146ea279
commit
9cdde459aa
5 changed files with 86 additions and 29 deletions
|
|
@ -0,0 +1,23 @@
|
|||
package com.kabouzeid.gramophone.imageloader;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.kabouzeid.gramophone.helper.bitmapblur.StackBlurManager;
|
||||
import com.nostra13.universalimageloader.core.process.BitmapProcessor;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class BlurProcessor implements BitmapProcessor {
|
||||
|
||||
final int blurRadius;
|
||||
|
||||
public BlurProcessor(int blurRadius) {
|
||||
this.blurRadius = blurRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap process(Bitmap bitmap) {
|
||||
return new StackBlurManager(bitmap).process(blurRadius);
|
||||
}
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ public class PhonographImageDownloader extends BaseImageDownloader {
|
|||
return null;
|
||||
}
|
||||
|
||||
int id = Integer.valueOf(data[0].substring(SCHEME_SONG.length()));
|
||||
int id = Integer.parseInt(data[0].substring(SCHEME_SONG.length()));
|
||||
return getMediaProviderAlbumArtInputStream(id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import android.animation.Animator;
|
|||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -31,7 +30,7 @@ import com.kabouzeid.gramophone.R;
|
|||
import com.kabouzeid.gramophone.adapter.songadapter.AlbumSongAdapter;
|
||||
import com.kabouzeid.gramophone.dialogs.SleepTimerDialog;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.helper.bitmapblur.StackBlurManager;
|
||||
import com.kabouzeid.gramophone.imageloader.BlurProcessor;
|
||||
import com.kabouzeid.gramophone.interfaces.CabHolder;
|
||||
import com.kabouzeid.gramophone.interfaces.PaletteColorHolder;
|
||||
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
||||
|
|
@ -218,20 +217,33 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
.build(),
|
||||
new SimpleImageLoadingListener() {
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
public void onLoadingFailed(String imageUri, View view, @Nullable FailReason failReason) {
|
||||
applyPalette(null);
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inSampleSize = 2;
|
||||
albumArtBackground.setImageBitmap(new StackBlurManager(BitmapFactory.decodeResource(getResources(), R.drawable.default_album_art, options)).process(10));
|
||||
|
||||
ImageLoader.getInstance().displayImage(
|
||||
"drawable://" + R.drawable.default_album_art,
|
||||
albumArtBackground,
|
||||
new DisplayImageOptions.Builder().postProcessor(new BlurProcessor(10)).build()
|
||||
);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
startPostponedEnterTransition();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, @NonNull Bitmap loadedImage) {
|
||||
public void onLoadingComplete(String imageUri, View view, @Nullable Bitmap loadedImage) {
|
||||
if (loadedImage == null) {
|
||||
onLoadingFailed(imageUri, view, null);
|
||||
return;
|
||||
}
|
||||
applyPalette(loadedImage);
|
||||
albumArtBackground.setImageBitmap(new StackBlurManager(loadedImage).process(10));
|
||||
|
||||
ImageLoader.getInstance().displayImage(
|
||||
imageUri,
|
||||
albumArtBackground,
|
||||
new DisplayImageOptions.Builder().postProcessor(new BlurProcessor(10)).build()
|
||||
);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
startPostponedEnterTransition();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import com.kabouzeid.gramophone.adapter.songadapter.ArtistSongAdapter;
|
|||
import com.kabouzeid.gramophone.dialogs.SleepTimerDialog;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.helper.bitmapblur.StackBlurManager;
|
||||
import com.kabouzeid.gramophone.imageloader.BlurProcessor;
|
||||
import com.kabouzeid.gramophone.interfaces.CabHolder;
|
||||
import com.kabouzeid.gramophone.interfaces.PaletteColorHolder;
|
||||
import com.kabouzeid.gramophone.lastfm.rest.LastFMRestClient;
|
||||
|
|
@ -71,6 +72,7 @@ import java.util.List;
|
|||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
import hugo.weaving.DebugLog;
|
||||
import retrofit.Callback;
|
||||
import retrofit.RetrofitError;
|
||||
import retrofit.client.Response;
|
||||
|
|
@ -333,20 +335,28 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
.resetViewBeforeLoading(true)
|
||||
.build(),
|
||||
new SimpleImageLoadingListener() {
|
||||
@DebugLog
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
public void onLoadingFailed(String imageUri, View view, @Nullable FailReason failReason) {
|
||||
resetPaletteAndArtistImageBackground();
|
||||
toastUpdatedArtistImageIfDownloadWasForced();
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, @Nullable Bitmap loadedImage) {
|
||||
if (loadedImage != null) {
|
||||
applyPalette(loadedImage);
|
||||
artistImageBackground.setImageBitmap(new StackBlurManager(loadedImage).process(10));
|
||||
} else {
|
||||
resetPaletteAndArtistImageBackground();
|
||||
if (loadedImage == null) {
|
||||
onLoadingFailed(imageUri, view, null);
|
||||
return;
|
||||
}
|
||||
applyPalette(loadedImage);
|
||||
|
||||
ImageLoader.getInstance().displayImage(
|
||||
imageUri,
|
||||
artistImageBackground,
|
||||
new DisplayImageOptions.Builder().postProcessor(new BlurProcessor(10)).build()
|
||||
);
|
||||
|
||||
toastUpdatedArtistImageIfDownloadWasForced();
|
||||
}
|
||||
|
||||
|
|
@ -374,7 +384,11 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
|
||||
private void resetPaletteAndArtistImageBackground() {
|
||||
applyPalette(null);
|
||||
artistImageBackground.setImageBitmap(defaultArtistImageBlurManager.process(10));
|
||||
ImageLoader.getInstance().displayImage(
|
||||
"drawable://" + R.drawable.default_artist_image,
|
||||
artistImageBackground,
|
||||
new DisplayImageOptions.Builder().postProcessor(new BlurProcessor(10)).build()
|
||||
);
|
||||
}
|
||||
|
||||
private void applyPalette(@Nullable Bitmap bitmap) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import android.annotation.TargetApi;
|
|||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Build;
|
||||
|
|
@ -44,6 +43,7 @@ import com.kabouzeid.gramophone.dialogs.SongDetailDialog;
|
|||
import com.kabouzeid.gramophone.dialogs.SongShareDialog;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.helper.bitmapblur.StackBlurManager;
|
||||
import com.kabouzeid.gramophone.imageloader.BlurProcessor;
|
||||
import com.kabouzeid.gramophone.misc.SmallTransitionListener;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.service.MusicService;
|
||||
|
|
@ -66,6 +66,7 @@ import java.lang.ref.WeakReference;
|
|||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
import hugo.weaving.DebugLog;
|
||||
|
||||
public class MusicControllerActivity extends AbsFabActivity {
|
||||
|
||||
|
|
@ -433,23 +434,30 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
.showImageOnFail(R.drawable.default_album_art)
|
||||
.build(),
|
||||
new SimpleImageLoadingListener() {
|
||||
@DebugLog
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
public void onLoadingFailed(String imageUri, View view, @Nullable FailReason failReason) {
|
||||
applyPalette(null);
|
||||
// to gain some performance cache the blurred bitmap
|
||||
if (defaultAlbumArtStackBlurManager == null) {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inSampleSize = 2;
|
||||
defaultAlbumArtStackBlurManager = new StackBlurManager(BitmapFactory.decodeResource(getResources(), R.drawable.default_album_art, options));
|
||||
defaultAlbumArtStackBlurManager.process(10);
|
||||
}
|
||||
albumArtBackground.setImageBitmap(defaultAlbumArtStackBlurManager.returnBlurredImage());
|
||||
ImageLoader.getInstance().displayImage(
|
||||
"drawable://" + R.drawable.default_album_art,
|
||||
albumArtBackground,
|
||||
new DisplayImageOptions.Builder().postProcessor(new BlurProcessor(10)).build()
|
||||
);
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, @NonNull Bitmap loadedImage) {
|
||||
public void onLoadingComplete(String imageUri, View view, @Nullable Bitmap loadedImage) {
|
||||
if (loadedImage == null) {
|
||||
onLoadingFailed(imageUri, view, null);
|
||||
return;
|
||||
}
|
||||
applyPalette(loadedImage);
|
||||
albumArtBackground.setImageBitmap(new StackBlurManager(loadedImage).process(10));
|
||||
ImageLoader.getInstance().displayImage(
|
||||
imageUri,
|
||||
albumArtBackground,
|
||||
new DisplayImageOptions.Builder().postProcessor(new BlurProcessor(10)).build()
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue