Switched from Picasso to Ion

Much better performance.
Not well tested yet but it should work.
This commit is contained in:
Karim Abou Zeid 2015-04-17 00:56:55 +02:00
commit a11535c8a3
39 changed files with 733 additions and 419 deletions

View file

@ -5,7 +5,7 @@ import android.widget.ImageView;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.util.MusicUtil;
import com.squareup.picasso.Picasso;
import com.koushikdutta.ion.Ion;
/**
* Created by karim on 22.11.14.
@ -48,11 +48,19 @@ public class Album implements SearchEntry {
}
@Override
public void loadImage(Context context, ImageView imageView) {
public void loadImage(final Context context, final ImageView imageView) {
imageView.setImageResource(R.drawable.default_album_art);
Picasso.with(context)
.load(MusicUtil.getAlbumArtUri(id))
.placeholder(R.drawable.default_album_art)
.into(imageView);
imageView.post(new Runnable() {
@Override
public void run() {
Ion.with(context)
.load(MusicUtil.getAlbumArtUri(id).toString())
.withBitmap()
.resize(imageView.getWidth(), imageView.getHeight())
.centerCrop()
.error(R.drawable.default_album_art)
.intoImageView(imageView);
}
});
}
}

View file

@ -5,7 +5,7 @@ import android.widget.ImageView;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistThumbnailUrlLoader;
import com.squareup.picasso.Picasso;
import com.koushikdutta.ion.Ion;
/**
* Created by karim on 29.12.14.
@ -45,10 +45,19 @@ public class Artist implements SearchEntry {
imageView.setImageResource(R.drawable.default_artist_image);
LastFMArtistThumbnailUrlLoader.loadArtistThumbnailUrl(context, name, false, new LastFMArtistThumbnailUrlLoader.ArtistThumbnailUrlLoaderCallback() {
@Override
public void onArtistThumbnailUrlLoaded(String url) {
Picasso.with(context)
.load(url)
.into(imageView);
public void onArtistThumbnailUrlLoaded(final String url) {
imageView.post(new Runnable() {
@Override
public void run() {
Ion.with(context)
.load(url)
.withBitmap()
.resize(imageView.getWidth(), imageView.getHeight())
.centerCrop()
.error(R.drawable.default_artist_image)
.intoImageView(imageView);
}
});
}
});
}

View file

@ -3,7 +3,7 @@ package com.kabouzeid.gramophone.model;
/**
* Created by karim on 28.03.15.
*/
public class UIPreferenceChangedEvent {
public class UiPreferenceChangedEvent {
public static final int THEME_CHANGED = 0;
public static final int ALBUM_OVERVIEW_PALETTE_CHANGED = 1;
public static final int COLORED_NAVIGATION_BAR_ARTIST_CHANGED = 2;
@ -14,7 +14,7 @@ public class UIPreferenceChangedEvent {
private int action;
private Object value;
public UIPreferenceChangedEvent(int action, Object value) {
public UiPreferenceChangedEvent(int action, Object value) {
this.action = action;
this.value = value;
}