CoverView improvements
Cancel stale pending generate jobs---these can build up if skipping songs rapidly. Avoid calling touch on worker thread---no advantage to doing so and builds up jobs. Load songs in more optimal order (current, then next, then previous).
This commit is contained in:
parent
518e16ffc4
commit
bb39b8677e
@ -317,17 +317,12 @@ public final class CoverView extends View implements Handler.Callback {
|
|||||||
if (song == null || song.id == -1)
|
if (song == null || song.id == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Bitmap bitmap = mBitmapCache.get(song.id);
|
Bitmap bitmap = CoverBitmap.createBitmap(getContext(), mCoverStyle, song, getWidth(), getHeight(), mBitmapCache.discardOldest());
|
||||||
if (bitmap == null) {
|
if (bitmap != null) {
|
||||||
bitmap = CoverBitmap.createBitmap(getContext(), mCoverStyle, song, getWidth(), getHeight(), mBitmapCache.discardOldest());
|
|
||||||
mBitmaps[i] = bitmap;
|
mBitmaps[i] = bitmap;
|
||||||
mBitmapCache.put(song.id, bitmap);
|
mBitmapCache.put(song.id, bitmap);
|
||||||
} else {
|
postInvalidate();
|
||||||
mBitmaps[i] = bitmap;
|
|
||||||
mBitmapCache.touch(song.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postInvalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -340,8 +335,14 @@ public final class CoverView extends View implements Handler.Callback {
|
|||||||
if (song == null) {
|
if (song == null) {
|
||||||
mBitmaps[i] = null;
|
mBitmaps[i] = null;
|
||||||
} else {
|
} else {
|
||||||
mBitmaps[i] = mBitmapCache.get(song.id);
|
Bitmap bitmap = mBitmapCache.get(song.id);
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_GENERATE_BITMAP, i, 0));
|
if (bitmap != null) {
|
||||||
|
mBitmaps[i] = bitmap;
|
||||||
|
mBitmapCache.touch(song.id);
|
||||||
|
} else {
|
||||||
|
mBitmaps[i] = null;
|
||||||
|
mHandler.sendMessage(mHandler.obtainMessage(MSG_GENERATE_BITMAP, i, 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,8 +353,10 @@ public final class CoverView extends View implements Handler.Callback {
|
|||||||
*/
|
*/
|
||||||
public void querySongs(PlaybackService service)
|
public void querySongs(PlaybackService service)
|
||||||
{
|
{
|
||||||
for (int i = 3; --i != -1; )
|
mHandler.removeMessages(MSG_GENERATE_BITMAP);
|
||||||
setSong(i, service.getSong(i - 1));
|
setSong(1, service.getSong(0));
|
||||||
|
setSong(2, service.getSong(1));
|
||||||
|
setSong(0, service.getSong(-1));
|
||||||
resetScroll();
|
resetScroll();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user