Some tries
This commit is contained in:
parent
270e722a38
commit
aa3c6f07e7
|
@ -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<View> viewWeakReference;
|
||||
|
@ -40,21 +38,20 @@ public class CustomEmoji extends ReplacementSpan {
|
|||
CustomEmoji(WeakReference<View> 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<Emoji> 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<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> 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();
|
||||
|
|
|
@ -369,9 +369,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
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<RecyclerView.ViewHolder>
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue