mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-12 12:23:38 +00:00
parent
ab8593d5f3
commit
8011b308c2
@ -8,6 +8,8 @@ import android.graphics.Paint;
|
|||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.style.ImageSpan;
|
import android.text.style.ImageSpan;
|
||||||
@ -35,6 +37,7 @@ public class EmojiProvider {
|
|||||||
private static volatile EmojiProvider instance = null;
|
private static volatile EmojiProvider instance = null;
|
||||||
private static final SparseArray<SoftReference<Bitmap>> bitmaps = new SparseArray<>();
|
private static final SparseArray<SoftReference<Bitmap>> bitmaps = new SparseArray<>();
|
||||||
private static final Paint paint = new Paint();
|
private static final Paint paint = new Paint();
|
||||||
|
private static final Handler handler = new Handler(Looper.getMainLooper());
|
||||||
static { paint.setFilterBitmap(true); }
|
static { paint.setFilterBitmap(true); }
|
||||||
|
|
||||||
private final SparseArray<DrawInfo> offsets = new SparseArray<>();
|
private final SparseArray<DrawInfo> offsets = new SparseArray<>();
|
||||||
@ -84,7 +87,6 @@ public class EmojiProvider {
|
|||||||
try {
|
try {
|
||||||
loadPage(page);
|
loadPage(page);
|
||||||
if (pageLoadListener != null) {
|
if (pageLoadListener != null) {
|
||||||
Log.w(TAG, "onPageLoaded("+page+")");
|
|
||||||
pageLoadListener.onPageLoaded();
|
pageLoadListener.onPageLoaded();
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
@ -107,6 +109,7 @@ public class EmojiProvider {
|
|||||||
final InputStream bitmapStream = context.getAssets().open(file);
|
final InputStream bitmapStream = context.getAssets().open(file);
|
||||||
final Bitmap bitmap = BitmapUtil.createScaledBitmap(measureStream, bitmapStream, (float) bigDrawSize / (float) EMOJI_RAW_SIZE);
|
final Bitmap bitmap = BitmapUtil.createScaledBitmap(measureStream, bitmapStream, (float) bigDrawSize / (float) EMOJI_RAW_SIZE);
|
||||||
bitmaps.put(page, new SoftReference<>(bitmap));
|
bitmaps.put(page, new SoftReference<>(bitmap));
|
||||||
|
Log.w(TAG, "onPageLoaded(" + page + ")");
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.w(TAG, ioe);
|
Log.w(TAG, ioe);
|
||||||
throw ioe;
|
throw ioe;
|
||||||
@ -172,9 +175,13 @@ public class EmojiProvider {
|
|||||||
if (bitmaps.get(page) == null || bitmaps.get(page).get() == null) {
|
if (bitmaps.get(page) == null || bitmaps.get(page).get() == null) {
|
||||||
preloadPage(page, new PageLoadedListener() {
|
preloadPage(page, new PageLoadedListener() {
|
||||||
@Override public void onPageLoaded() {
|
@Override public void onPageLoaded() {
|
||||||
|
handler.post(new Runnable() {
|
||||||
|
@Override public void run() {
|
||||||
invalidateSelf();
|
invalidateSelf();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (bmp == null) {
|
if (bmp == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user