From 938229d7d49b5e5b1ac9c023da2850b0c91ce142 Mon Sep 17 00:00:00 2001 From: Ivan Kupalov Date: Tue, 24 Oct 2017 01:04:53 +0400 Subject: [PATCH] Fix custom emoji size (#407) Now custom emoji images adapt to the font size. --- .../tusky/adapter/StatusBaseViewHolder.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java index 234316a98..3624595f7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java @@ -524,15 +524,16 @@ class StatusBaseViewHolder extends RecyclerView.ViewHolder { } public void setCallback(Callback callback) { - this.callbackWeakReference = new WeakReference(callback); + this.callbackWeakReference = new WeakReference<>(callback); } @Override public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, @Nullable Paint.FontMetricsInt fm) { if (imageDrawable == null) return 0; - Rect sizeRect = imageDrawable.getBounds(); - return sizeRect.right; + int textSize = (int) paint.getTextSize(); + imageDrawable.setBounds(0, 0, textSize, textSize); + return textSize; } @Override @@ -550,8 +551,6 @@ class StatusBaseViewHolder extends RecyclerView.ViewHolder { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { imageDrawable = new BitmapDrawable(bitmap); - imageDrawable.setBounds(0, 0, imageDrawable.getIntrinsicWidth() + 10, - imageDrawable.getIntrinsicHeight() + 10); if (callbackWeakReference != null) { Callback cb = callbackWeakReference.get(); if (cb != null) cb.onSuccess();