invalidate emoji when load completes

Closes #3169
// FREEBIE
This commit is contained in:
Jake McGinty 2015-05-14 16:36:25 -07:00 committed by Moxie Marlinspike
parent 54db79bfdd
commit ab8593d5f3

View File

@ -34,6 +34,8 @@ public class EmojiProvider {
private static final ExecutorService executor = Util.newSingleThreadedLifoExecutor();
private static volatile EmojiProvider instance = null;
private static final SparseArray<SoftReference<Bitmap>> bitmaps = new SparseArray<>();
private static final Paint paint = new Paint();
static { paint.setFilterBitmap(true); }
private final SparseArray<DrawInfo> offsets = new SparseArray<>();
@ -153,18 +155,12 @@ public class EmojiProvider {
return drawable;
}
public static class EmojiDrawable extends Drawable {
public class EmojiDrawable extends Drawable {
private final int index;
private final int page;
private final int emojiSize;
private static final Paint paint;
private Bitmap bmp;
static {
paint = new Paint();
paint.setFilterBitmap(true);
}
public EmojiDrawable(DrawInfo info, int emojiSize) {
this.index = info.index;
this.page = info.page;
@ -174,7 +170,11 @@ public class EmojiProvider {
@Override
public void draw(Canvas canvas) {
if (bitmaps.get(page) == null || bitmaps.get(page).get() == null) {
Log.w(TAG, "bitmap for this page was null");
preloadPage(page, new PageLoadedListener() {
@Override public void onPageLoaded() {
invalidateSelf();
}
});
return;
}
if (bmp == null) {