diff --git a/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java b/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java index ef7cdfa8b..c45605d22 100644 --- a/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java +++ b/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java @@ -8,7 +8,6 @@ import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; import android.text.Spannable; import android.text.style.ReplacementSpan; -import android.util.Log; import android.view.View; import androidx.annotation.NonNull; @@ -31,7 +30,6 @@ import app.fedilab.android.client.entities.api.Emoji; public class CustomEmoji extends ReplacementSpan { - private final View view; private final float scale; private Drawable imageDrawable; private final WeakReference viewWeakReference; @@ -40,21 +38,20 @@ public class CustomEmoji extends ReplacementSpan { CustomEmoji(WeakReference viewWeakReference) { Context mContext = viewWeakReference.get().getContext(); this.viewWeakReference = viewWeakReference; - view = viewWeakReference.get(); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(mContext); scale = sharedpreferences.getFloat(mContext.getString(R.string.SET_FONT_SCALE), 1.0f); } public static void displayEmoji(List emojis, Spannable spannableString, View view) { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(view.getContext()); - boolean animate = !sharedpreferences.getBoolean(view.getContext().getString(R.string.SET_DISABLE_GIF), false); + boolean animate = !sharedpreferences.getBoolean(view.getContext().getString(R.string.SET_DISABLE_ANIMATED_EMOJI), false); for (Emoji emoji : emojis) { Matcher matcher = Pattern.compile(":" + emoji.shortcode + ":", Pattern.LITERAL) .matcher(spannableString); while (matcher.find()) { CustomEmoji customEmoji = new CustomEmoji(new WeakReference<>(view)); spannableString.setSpan(customEmoji, matcher.start(), matcher.end(), 0); - Glide.with(view) + Glide.with(view.getContext()) .asDrawable() .load(animate ? emoji.url : emoji.static_url) .into(customEmoji.getTarget(animate)); @@ -95,8 +92,6 @@ public class CustomEmoji extends ReplacementSpan { return new CustomTarget() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) { - Log.v(Helper.TAG, "resource: " + resource); - Log.v(Helper.TAG, "instanceof: " + (resource instanceof Animatable)); View view = viewWeakReference.get(); if (animate && resource instanceof Animatable) { Drawable.Callback callback = resource.getCallback(); diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index d837d330d..84ade8340 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -369,9 +369,6 @@ public class StatusAdapter extends RecyclerView.Adapter holder.binding.actionButtonBoost.setActiveImageTint(R.color.boost_icon); holder.binding.actionButtonBookmark.setActiveImageTint(R.color.marked_icon); - if (statusToDeal.emojis != null && statusToDeal.emojis.size() > 0) { - CustomEmoji.displayEmoji(statusToDeal.emojis, statusToDeal.span_content, holder.binding.statusContent); - } if (status.pinned) { holder.binding.statusPinned.setVisibility(View.VISIBLE); @@ -881,7 +878,19 @@ public class StatusAdapter extends RecyclerView.Adapter break; } //--- MAIN CONTENT --- - holder.binding.statusContent.setText(statusToDeal.span_content, TextView.BufferType.SPANNABLE); + if (statusToDeal.emojis != null && statusToDeal.emojis.size() > 0) { + CustomEmoji.displayEmoji(statusToDeal.emojis, statusToDeal.span_content, holder.binding.statusContent); + holder.binding.statusContent.postDelayed(new Runnable() { + @Override + public void run() { + holder.binding.statusContent.setText(statusToDeal.span_content, TextView.BufferType.SPANNABLE); + } + }, 100); + } else { + holder.binding.statusContent.setText(statusToDeal.span_content, TextView.BufferType.SPANNABLE); + } + + if (truncate_toots_size > 0) { holder.binding.statusContent.setMaxLines(truncate_toots_size); holder.binding.statusContent.setEllipsize(TextUtils.TruncateAt.END);