Commit f3c00efc authored by Thomas's avatar Thomas
Browse files

- Fix #1339 - Display placeholder for unfederated emojis

parent 2dfb54dd
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ public class CustomEmoji extends ReplacementSpan {
    private float scale;
    private Drawable imageDrawable;
    private boolean callbackCalled;
    private boolean loadFailed;

    CustomEmoji(WeakReference<View> viewWeakReference) {
        Context mContext = viewWeakReference.get().getContext();
@@ -44,6 +45,7 @@ public class CustomEmoji extends ReplacementSpan {
            scale = 1.3f;
        }
        callbackCalled = false;
        loadFailed = false;
    }

    public SpannableStringBuilder makeEmoji(SpannableStringBuilder content, List<Emoji> emojiList, boolean animate, Status.Callback callback) {
@@ -82,6 +84,8 @@ public class CustomEmoji extends ReplacementSpan {
            canvas.translate(x, (float) transY);
            imageDrawable.draw(canvas);
            canvas.restore();
        } else if (loadFailed) {
            canvas.drawText(charSequence, start, end, x, y, paint);
        }
    }

@@ -138,6 +142,15 @@ public class CustomEmoji extends ReplacementSpan {
                }
            }

            @Override
            public void onLoadFailed(@Nullable Drawable errorDrawable) {
                loadFailed = true;
                View view = viewWeakReference.get();
                if (view != null) {
                    view.invalidate();
                }
            }

            @Override
            public void onLoadCleared(@Nullable Drawable placeholder) {
                View view = viewWeakReference.get();