Bump existing ids in the CoverView bitmap timeline

This commit is contained in:
Christopher Eby 2010-04-27 22:34:05 -05:00
parent f92c7348c6
commit 753af4fa11

View File

@ -303,17 +303,22 @@ public final class CoverView extends View {
int[] timeline = mCacheTimeline; int[] timeline = mCacheTimeline;
int i = timeline.length; int i = timeline.length;
while (--i != -1 && timeline[i] == 0); while (--i != -1 && timeline[i] == 0);
if (i == timeline.length - 1) { int j = i + 1;
while (--j != -1 && timeline[j] != id);
if (j != -1) {
System.arraycopy(timeline, j + 1, timeline, j, timeline.length - j - 1);
} else if (i == timeline.length - 1) {
int toRemove = timeline[0]; int toRemove = timeline[0];
System.arraycopy(timeline, 1, timeline, 0, timeline.length - 1); System.arraycopy(timeline, 1, timeline, 0, timeline.length - 1);
Bitmap bitmap = mBitmapCache.get(toRemove); Bitmap bitmap = mBitmapCache.get(toRemove);
mBitmapCache.remove(toRemove); mBitmapCache.remove(toRemove);
if (bitmap != null) if (bitmap != null)
bitmap.recycle(); bitmap.recycle();
} else {
++i;
} }
if (i < timeline.length - 1)
++i;
timeline[i] = id; timeline[i] = id;
} }