Hopefully fixed OOM when bluring an image.

This commit is contained in:
Karim Abou Zeid 2015-06-29 15:42:33 +02:00
commit bfa800bce6
5 changed files with 34 additions and 19 deletions

View file

@ -213,11 +213,12 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
.resetViewBeforeLoading(true)
.build(),
new SimpleImageLoadingListener() {
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
applyPalette(null);
albumArtBackground.setImageBitmap(new StackBlurManager(BitmapFactory.decodeResource(getResources(), R.drawable.default_album_art)).process(10));
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
albumArtBackground.setImageBitmap(new StackBlurManager(BitmapFactory.decodeResource(getResources(), R.drawable.default_album_art, options)).process(10));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
startPostponedEnterTransition();
}

View file

@ -68,7 +68,7 @@ import butterknife.InjectView;
/**
* A lot of hackery is done in this activity. Changing things may will brake the whole activity.
* <p>
* <p/>
* Should be kinda stable ONLY AS IT IS!!!
*/
public class ArtistDetailActivity extends AbsFabActivity implements PaletteColorHolder, CabHolder {
@ -282,8 +282,9 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
}
private void setUpArtistImageAndApplyPalette(final boolean forceDownload) {
final StackBlurManager defaultArtistImageBlurManager = new StackBlurManager(BitmapFactory.decodeResource(getResources(), R.drawable.default_artist_image));
artistImageBackground.setImageBitmap(defaultArtistImageBlurManager.process(10));
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
final StackBlurManager defaultArtistImageBlurManager = new StackBlurManager(BitmapFactory.decodeResource(getResources(), R.drawable.default_artist_image, options));
LastFMArtistImageUrlLoader.loadArtistImageUrl(this, artist.name, forceDownload, new LastFMArtistImageUrlLoader.ArtistImageUrlLoaderCallback() {
@Override
public void onArtistImageUrlLoaded(final String url) {
@ -299,7 +300,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
applyPalette(null);
artistImageBackground.setImageBitmap(defaultArtistImageBlurManager.returnBlurredImage());
artistImageBackground.setImageBitmap(defaultArtistImageBlurManager.process(10));
}
@Override

View file

@ -435,7 +435,9 @@ public class MusicControllerActivity extends AbsFabActivity {
applyPalette(null);
// to gain some performance cache the blurred bitmap
if (defaultAlbumArtStackBlurManager == null) {
defaultAlbumArtStackBlurManager = new StackBlurManager(BitmapFactory.decodeResource(getResources(), R.drawable.default_album_art));
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());