Fix custom emoji size (#407)

Now custom emoji images adapt to the font size.
main
Ivan Kupalov 7 years ago committed by Konrad Pozniak
parent 58600fe8ce
commit 6223a1bfa3
  1. 9
      app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java

@ -524,15 +524,16 @@ class StatusBaseViewHolder extends RecyclerView.ViewHolder {
} }
public void setCallback(Callback callback) { public void setCallback(Callback callback) {
this.callbackWeakReference = new WeakReference<Callback>(callback); this.callbackWeakReference = new WeakReference<>(callback);
} }
@Override @Override
public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, public int getSize(@NonNull Paint paint, CharSequence text, int start, int end,
@Nullable Paint.FontMetricsInt fm) { @Nullable Paint.FontMetricsInt fm) {
if (imageDrawable == null) return 0; if (imageDrawable == null) return 0;
Rect sizeRect = imageDrawable.getBounds(); int textSize = (int) paint.getTextSize();
return sizeRect.right; imageDrawable.setBounds(0, 0, textSize, textSize);
return textSize;
} }
@Override @Override
@ -550,8 +551,6 @@ class StatusBaseViewHolder extends RecyclerView.ViewHolder {
@Override @Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
imageDrawable = new BitmapDrawable(bitmap); imageDrawable = new BitmapDrawable(bitmap);
imageDrawable.setBounds(0, 0, imageDrawable.getIntrinsicWidth() + 10,
imageDrawable.getIntrinsicHeight() + 10);
if (callbackWeakReference != null) { if (callbackWeakReference != null) {
Callback cb = callbackWeakReference.get(); Callback cb = callbackWeakReference.get();
if (cb != null) cb.onSuccess(); if (cb != null) cb.onSuccess();

Loading…
Cancel
Save