remove weak references

This commit is contained in:
Thomas 2025-05-29 11:01:48 +02:00
parent 2ff3e10303
commit 60db57a42f
23 changed files with 114 additions and 124 deletions

View file

@ -1290,7 +1290,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
if (!isFinishing()) {
headerMainBinding.accountName.setText(
Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account.getSpanDisplayNameEmoji(BaseMainActivity.this,
new WeakReference<>(headerMainBinding.accountName)),
headerMainBinding.accountName),
TextView.BufferType.SPANNABLE);
}
float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);

View file

@ -523,7 +523,7 @@ public class ProfileActivity extends BaseActivity {
binding.accountDn.setText(
account.getSpanDisplayNameEmoji(ProfileActivity.this,
new WeakReference<>(binding.accountDn)),
binding.accountDn),
TextView.BufferType.SPANNABLE);
binding.accountUn.setText(String.format("@%s", account.acct));
@ -540,7 +540,7 @@ public class ProfileActivity extends BaseActivity {
});
binding.accountNote.setText(
account.getSpanNote(ProfileActivity.this,
new WeakReference<>(binding.accountNote)),
binding.accountNote),
TextView.BufferType.SPANNABLE);
binding.accountNote.setMovementMethod(LinkMovementMethod.getInstance());

View file

@ -324,7 +324,7 @@ public class AdminAccountActivity extends BaseActivity {
binding.accountDn.setText(
adminAccount.account.getSpanDisplayNameEmoji(AdminAccountActivity.this,
new WeakReference<>(binding.accountDn)),
binding.accountDn),
TextView.BufferType.SPANNABLE);
binding.accountUn.setText(String.format("@%s", adminAccount.account.acct));
binding.accountUn.setOnLongClickListener(v -> {

View file

@ -337,7 +337,7 @@ public class AdminReportActivity extends BaseBarActivity {
binding.accountDn.setText(
account.getSpanDisplayNameEmoji(AdminReportActivity.this,
new WeakReference<>(binding.accountDn)),
binding.accountDn),
TextView.BufferType.SPANNABLE);
binding.accountUn.setText(String.format("@%s", account.acct));
binding.accountUn.setOnLongClickListener(v -> {

View file

@ -91,26 +91,26 @@ public class Account implements Serializable {
public transient String pronouns = null;
public synchronized Spannable getSpanDisplayName(Context context, WeakReference<View> viewWeakReference) {
public synchronized Spannable getSpanDisplayName(Context context, View view) {
if (display_name == null || display_name.isEmpty()) {
display_name = username;
}
return SpannableHelper.convert(context, display_name, null, this, null, viewWeakReference, true, false);
return SpannableHelper.convert(context, display_name, null, this, null, view, true, false);
}
public synchronized Spannable getSpanDisplayNameEmoji(Activity activity, WeakReference<View> viewWeakReference) {
public synchronized Spannable getSpanDisplayNameEmoji(Activity activity, View view) {
if (display_name == null || display_name.isEmpty()) {
display_name = username;
}
return SpannableHelper.convertEmoji(activity, display_name, this, viewWeakReference);
return SpannableHelper.convertEmoji(activity, display_name, this, view);
}
public synchronized Spannable getSpanDisplayNameTitle(Context context, WeakReference<View> viewWeakReference, String title) {
return SpannableHelper.convert(context, title, null, this, null, viewWeakReference, true, false);
public synchronized Spannable getSpanDisplayNameTitle(Context context, View view, String title) {
return SpannableHelper.convert(context, title, null, this, null, view, true, false);
}
public synchronized Spannable getSpanNote(Context context, WeakReference<View> viewWeakReference) {
return SpannableHelper.convert(context, note, null, this, null, viewWeakReference, true, false);
public synchronized Spannable getSpanNote(Context context, View view) {
return SpannableHelper.convert(context, note, null, this, null, view, true, false);
}

View file

@ -55,8 +55,8 @@ public class Announcement {
public List<Reaction> reactions;
public synchronized Spannable getSpanContent(Context context, WeakReference<View> viewWeakReference) {
return SpannableHelper.convert(context, content, null, null, this, viewWeakReference, true, false);
public synchronized Spannable getSpanContent(Context context, View view) {
return SpannableHelper.convert(context, content, null, null, this, view, true, false);
}
}

View file

@ -42,12 +42,12 @@ public class Field implements Serializable {
private transient ForegroundColorSpan value_span;
private transient ForegroundColorSpan name_span;
public synchronized Spannable getValueSpan(Context context, Account account, WeakReference<View> viewWeakReference) {
public synchronized Spannable getValueSpan(Context context, Account account, View view) {
if (verified_at != null && value != null) {
value_span = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.verified_text));
}
Spannable spannable = SpannableHelper.convert(context, value, null, account, null, viewWeakReference, true, false);
Spannable spannable = SpannableHelper.convert(context, value, null, account, null, view, true, false);
if (value_span != null && spannable != null) {
spannable.setSpan(value_span, 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
@ -55,9 +55,9 @@ public class Field implements Serializable {
}
public synchronized Spannable getLabelSpan(Context context, Account account, WeakReference<View> viewWeakReference) {
public synchronized Spannable getLabelSpan(Context context, Account account, View view) {
Spannable spannable = SpannableHelper.convert(context, name, null, account, null, viewWeakReference, true, false);
Spannable spannable = SpannableHelper.convert(context, name, null, account, null, view, true, false);
if (name_span != null && spannable != null) {
spannable.setSpan(name_span, 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}

View file

@ -60,8 +60,8 @@ public class Poll implements Serializable {
public transient Spannable span_title;
public Spannable getSpanTitle(Context context, Status status, WeakReference<View> viewWeakReference) {
span_title = SpannableHelper.convert(context, title, status, null, null, viewWeakReference, false, false);
public Spannable getSpanTitle(Context context, Status status,View view) {
span_title = SpannableHelper.convert(context, title, status, null, null, view, false, false);
return span_title;
}
}

View file

@ -155,23 +155,23 @@ public class Status implements Serializable, Cloneable {
return same;
}
public synchronized Spannable getSpanContent(Context context, boolean checkRemotely, WeakReference<View> viewWeakReference) {
public synchronized Spannable getSpanContent(Context context, boolean checkRemotely, View view) {
if (contentSpan == null) {
contentSpan = SpannableHelper.convert(context, content, this, null, null, checkRemotely, viewWeakReference, true, true);
contentSpan = SpannableHelper.convert(context, content, this, null, null, checkRemotely, view, true, true);
}
return contentSpan;
}
public synchronized Spannable getSpanSpoiler(Context context, WeakReference<View> viewWeakReference) {
public synchronized Spannable getSpanSpoiler(Context context, View view) {
if (contentSpoilerSpan == null) {
contentSpoilerSpan = SpannableHelper.convert(context, spoiler_text, this, null, null, viewWeakReference, true, false);
contentSpoilerSpan = SpannableHelper.convert(context, spoiler_text, this, null, null, view, true, false);
}
return contentSpoilerSpan;
}
public synchronized Spannable getSpanTranslate(Context context, WeakReference<View> viewWeakReference) {
public synchronized Spannable getSpanTranslate(Context context, View view) {
if (contentTranslateSpan == null) {
contentTranslateSpan = SpannableHelper.convert(context, translationContent, this, null, null, viewWeakReference, true, true);
contentTranslateSpan = SpannableHelper.convert(context, translationContent, this, null, null, view, true, true);
}
return contentTranslateSpan;
}

View file

@ -6,7 +6,6 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.text.SpannableStringBuilder;
import android.text.style.ReplacementSpan;
import android.view.View;
@ -14,28 +13,21 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceManager;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition;
import java.lang.ref.WeakReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import app.fedilab.android.R;
import app.fedilab.android.mastodon.client.entities.api.Emoji;
public class CustomImageSpan extends ReplacementSpan {
private final WeakReference<View> viewWeakReference;
private float scale;
private Drawable imageDrawable;
CustomImageSpan(WeakReference<View> viewWeakReference) {
Context mContext = viewWeakReference.get().getContext();
this.viewWeakReference = viewWeakReference;
CustomImageSpan(View view) {
Context mContext = view.getContext();
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
scale = sharedpreferences.getFloat(mContext.getString(R.string.SET_FONT_SCALE), 1.1f);
if (scale > 1.3f) {
@ -43,20 +35,6 @@ public class CustomImageSpan extends ReplacementSpan {
}
}
public void makeEmoji(SpannableStringBuilder content, Emoji emoji, boolean animate) {
if (emoji != null) {
Matcher matcher = Pattern.compile(":" + emoji.shortcode + ":", Pattern.LITERAL)
.matcher(content);
while (matcher.find()) {
CustomImageSpan customEmoji = new CustomImageSpan(new WeakReference<>(viewWeakReference.get()));
content.setSpan(customEmoji, matcher.start(), matcher.end(), 0);
Glide.with(viewWeakReference.get())
.asDrawable()
.load(animate ? emoji.url : emoji.static_url)
.into(customEmoji.getTarget(animate));
}
}
}
@Override
public int getSize(@NonNull Paint paint, CharSequence charSequence, int i, int i1, @Nullable Paint.FontMetricsInt fontMetricsInt) {
@ -84,45 +62,48 @@ public class CustomImageSpan extends ReplacementSpan {
}
}
public Target<Drawable> getTarget(boolean animate) {
public Target<Drawable> getTarget(View view, boolean animate) {
return new CustomTarget<>() {
@Override
public void onStart() {
super.onStart();
if(imageDrawable instanceof Animatable) {
((Animatable) imageDrawable).start();
}
}
@Override
public void onStop() {
super.onStop();
if(imageDrawable instanceof Animatable) {
((Animatable) imageDrawable).stop();
}
}
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
View view = viewWeakReference.get();
if (animate && resource instanceof Animatable) {
Drawable.Callback drawableCallBack = resource.getCallback();
resource.setCallback(new Drawable.Callback() {
@Override
public void invalidateDrawable(@NonNull Drawable drawable) {
if (drawableCallBack != null) {
drawableCallBack.invalidateDrawable(drawable);
}
if(view != null) {
view.invalidate();
}
view.invalidate();
}
@Override
public void scheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable, long l) {
if (drawableCallBack != null) {
drawableCallBack.scheduleDrawable(drawable, runnable, l);
}
view.postDelayed(runnable,l);
}
@Override
public void unscheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable) {
if (drawableCallBack != null) {
drawableCallBack.unscheduleDrawable(drawable, runnable);
}
view.removeCallbacks(runnable);
}
});
((Animatable) resource).start();
}
imageDrawable = resource;
if (view != null) {
view.invalidate();
}
view.invalidate();
}
@Override

View file

@ -109,13 +109,13 @@ public class SpannableHelper {
public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement,
WeakReference<View> viewWeakReference, boolean convertHtml, boolean convertMarkdown) {
return convert(context, text, status, account, announcement, false, viewWeakReference, convertHtml, convertMarkdown);
View view, boolean convertHtml, boolean convertMarkdown) {
return convert(context, text, status, account, announcement, false, view, convertHtml, convertMarkdown);
}
public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement, boolean checkRemotely,
WeakReference<View> viewWeakReference, boolean convertHtml, boolean convertMarkdown) {
View view, boolean convertHtml, boolean convertMarkdown) {
if (text == null) {
return null;
}
@ -375,25 +375,34 @@ public class SpannableHelper {
}
boolean animate = !sharedpreferences.getBoolean(context.getString(R.string.SET_DISABLE_ANIMATED_EMOJI), false);
if(emojiList != null) {
emojiList.forEach(emoji -> {
CustomImageSpan customImageSpan = new CustomImageSpan(viewWeakReference);
customImageSpan.makeEmoji(content, emoji, animate);
});
}
for(Emoji emoji: emojiList) {
Matcher matcher = Pattern.compile(":" + emoji.shortcode + ":", Pattern.LITERAL)
.matcher(content);
while (matcher.find()) {
CustomImageSpan customImageSpan = new CustomImageSpan(view);
content.setSpan(customImageSpan, matcher.start(), matcher.end(), 0);
Glide.with(context)
.asDrawable()
.load(animate ? emoji.url : emoji.static_url)
.into(customImageSpan.getTarget(view, animate));
}
}
}
CustomImageSpan customImageSpan = new CustomImageSpan(view);
if (!imagesToReplace.isEmpty()) {
for (Map.Entry<String, String> entry : imagesToReplace.entrySet()) {
CustomImageSpan customImageSpan = new CustomImageSpan(viewWeakReference);
String key = entry.getKey();
String url = entry.getValue();
Matcher matcher = Pattern.compile(key, Pattern.LITERAL)
.matcher(content);
while (matcher.find()) {
content.setSpan(customImageSpan, matcher.start(), matcher.end(), 0);
Glide.with(viewWeakReference.get().getContext())
Glide.with(context)
.asDrawable()
.load(url)
.into(customImageSpan.getTarget(animate));
.into(customImageSpan.getTarget(view, false));
}
}
@ -979,7 +988,7 @@ public class SpannableHelper {
}
public static Spannable convertEmoji(Activity activity, String text, Account account, WeakReference<View> viewWeakReference) {
public static Spannable convertEmoji(Activity activity, String text, Account account, View view) {
SpannableString initialContent;
if (text == null) {
@ -999,13 +1008,13 @@ public class SpannableHelper {
Matcher matcher = Pattern.compile(":" + emoji.shortcode + ":", Pattern.LITERAL)
.matcher(content);
while (matcher.find()) {
CustomImageSpan customImageSpan = new CustomImageSpan(viewWeakReference);
CustomImageSpan customImageSpan = new CustomImageSpan(view);
content.setSpan(customImageSpan, matcher.start(), matcher.end(), 0);
if (Helper.isValidContextForGlide(activity)) {
Glide.with(viewWeakReference.get().getContext())
Glide.with(view.getContext())
.asDrawable()
.load(animate ? emoji.url : emoji.static_url)
.into(customImageSpan.getTarget(animate));
.into(customImageSpan.getTarget(view, animate));
}
}
}

View file

@ -309,12 +309,12 @@ public class AccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
}
accountViewHolder.binding.displayName.setText(
account.getSpanDisplayName(context,
new WeakReference<>(accountViewHolder.binding.displayName)),
accountViewHolder.binding.displayName),
TextView.BufferType.SPANNABLE);
accountViewHolder.binding.username.setText(String.format("@%s", account.acct));
accountViewHolder.binding.bio.setText(
account.getSpanNote(context,
new WeakReference<>(accountViewHolder.binding.bio)),
accountViewHolder.binding.bio),
TextView.BufferType.SPANNABLE);
}

View file

@ -91,7 +91,7 @@ public class AccountListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
MastodonHelper.loadPPMastodon(holder.binding.avatar, account);
holder.binding.displayName.setText(
account.getSpanDisplayName(context,
new WeakReference<>(holder.binding.displayName)),
holder.binding.displayName),
TextView.BufferType.SPANNABLE);
holder.binding.username.setText(String.format("@%s", account.acct));

View file

@ -102,7 +102,7 @@ public class AnnouncementAdapter extends RecyclerView.Adapter<AnnouncementAdapte
}
holder.binding.content.setText(
announcement.getSpanContent(context,
new WeakReference<>(holder.binding.content)),
holder.binding.content),
TextView.BufferType.SPANNABLE);
if (announcement.starts_at != null) {
String dateIni;

View file

@ -1418,14 +1418,14 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
}
holder.binding.statusContent.setText(
status.getSpanContent(context, false,
new WeakReference<>(holder.binding.statusContent)),
holder.binding.statusContent),
TextView.BufferType.SPANNABLE);
holder.binding.statusContent.setMovementMethod(LongClickLinkMovementMethod.getInstance());
MastodonHelper.loadPPMastodon(holder.binding.avatar, status.account);
if (status.account != null) {
holder.binding.displayName.setText(
status.account.getSpanDisplayName(context,
new WeakReference<>(holder.binding.displayName)),
holder.binding.displayName),
TextView.BufferType.SPANNABLE);
holder.binding.username.setText(String.format("@%s", status.account.acct));
}
@ -1434,7 +1434,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
holder.binding.spoiler.setVisibility(View.VISIBLE);
holder.binding.spoiler.setText(
status.getSpanSpoiler(context,
new WeakReference<>(holder.binding.spoiler)),
holder.binding.spoiler),
TextView.BufferType.SPANNABLE);
} else {
holder.binding.spoiler.setVisibility(View.GONE);

View file

@ -199,7 +199,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
holder.binding.spoiler.setVisibility(View.VISIBLE);
holder.binding.spoiler.setText(
conversation.last_status.getSpanSpoiler(context,
new WeakReference<>(holder.binding.spoiler)),
holder.binding.spoiler),
TextView.BufferType.SPANNABLE);
} else {
holder.binding.spoiler.setVisibility(View.GONE);
@ -209,7 +209,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
//--- MAIN CONTENT ---
holder.binding.statusContent.setText(
conversation.last_status.getSpanContent(context, false,
new WeakReference<>(holder.binding.statusContent)),
holder.binding.statusContent),
TextView.BufferType.SPANNABLE);
//--- DATE ---
holder.binding.lastMessageDate.setText(Helper.dateDiff(context, conversation.last_status.created_at));

View file

@ -72,13 +72,13 @@ public class FieldAdapter extends RecyclerView.Adapter<FieldAdapter.FieldViewHol
holder.binding.value.setText(
field.getValueSpan(context, account,
new WeakReference<>(holder.binding.value)),
holder.binding.value),
TextView.BufferType.SPANNABLE);
holder.binding.value.setMovementMethod(LinkMovementMethod.getInstance());
holder.binding.label.setText(
field.getLabelSpan(context, account,
new WeakReference<>(holder.binding.label)),
holder.binding.label),
TextView.BufferType.SPANNABLE);
holder.binding.label.setMovementMethod(LinkMovementMethod.getInstance());
}

View file

@ -251,7 +251,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
MastodonHelper.loadPPMastodon(holderFollow.binding.avatar, notification.account);
holderFollow.binding.displayName.setText(
notification.account.getSpanDisplayName(context,
new WeakReference<>(holderFollow.binding.displayName)),
holderFollow.binding.displayName),
TextView.BufferType.SPANNABLE);
holderFollow.binding.username.setText(String.format("@%s", notification.account.acct));
@ -415,7 +415,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
}
holderStatus.bindingNotification.status.displayName.setText(
notification.account.getSpanDisplayNameTitle(context,
new WeakReference<>(holderStatus.bindingNotification.status.displayName), title),
holderStatus.bindingNotification.status.displayName, title),
TextView.BufferType.SPANNABLE);
holderStatus.bindingNotification.status.username.setText(String.format("@%s", notification.account.acct));
@ -494,7 +494,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
});
holderStatus.bindingNotification.status.displayName.setText(
notification.account.getSpanDisplayNameTitle(context,
new WeakReference<>(holderStatus.bindingNotification.status.displayName), title),
holderStatus.bindingNotification.status.displayName, title),
TextView.BufferType.SPANNABLE);
holderStatus.bindingNotification.status.username.setText(String.format("@%s", notification.account.acct));
holderStatus.bindingNotification.status.actionButtons.setVisibility(View.GONE);

View file

@ -604,13 +604,13 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.quotedMessage.cardviewContainer.setStrokeColor(ThemeHelper.getAttColor(context, R.attr.colorPrimary));
holder.binding.quotedMessage.statusContent.setText(
statusToDeal.quote.getSpanContent(context, remote,
new WeakReference<>(holder.binding.quotedMessage.statusContent)),
holder.binding.quotedMessage.statusContent),
TextView.BufferType.SPANNABLE);
MastodonHelper.loadPPMastodon(holder.binding.quotedMessage.avatar, statusToDeal.quote.account);
if (statusToDeal.quote.account != null) {
holder.binding.quotedMessage.displayName.setText(
statusToDeal.quote.account.getSpanDisplayName(context,
new WeakReference<>(holder.binding.quotedMessage.displayName)),
holder.binding.quotedMessage.displayName),
TextView.BufferType.SPANNABLE);
holder.binding.quotedMessage.username.setText(String.format("@%s", statusToDeal.quote.account.acct));
}
@ -619,7 +619,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.quotedMessage.spoiler.setVisibility(View.VISIBLE);
holder.binding.quotedMessage.spoiler.setText(
statusToDeal.quote.getSpanSpoiler(context,
new WeakReference<>(holder.binding.quotedMessage.spoiler)),
holder.binding.quotedMessage.spoiler),
TextView.BufferType.SPANNABLE);
} else {
holder.binding.quotedMessage.spoiler.setVisibility(View.GONE);
@ -1258,7 +1258,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.displayName.setText(
statusToDeal.account.getSpanDisplayName(context,
new WeakReference<>(holder.binding.displayName)),
holder.binding.displayName),
TextView.BufferType.SPANNABLE);
holder.binding.username.setText(String.format("@%s", statusToDeal.account.acct));
//final float scale = context.getResources().getDisplayMetrics().density;
@ -1440,7 +1440,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.spoiler.setVisibility(View.VISIBLE);
holder.binding.spoiler.setText(
statusToDeal.getSpanSpoiler(context,
new WeakReference<>(holder.binding.spoiler)),
holder.binding.spoiler),
TextView.BufferType.SPANNABLE);
statusToDeal.isExpended = true;
} else {
@ -1453,7 +1453,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.spoiler.setText(
statusToDeal.getSpanSpoiler(context,
new WeakReference<>(holder.binding.spoiler)),
holder.binding.spoiler),
TextView.BufferType.SPANNABLE);
}
if (statusToDeal.isExpended) {
@ -1477,7 +1477,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
holder.binding.statusBoosterDisplayName.setText(
status.account.getSpanDisplayName(context,
new WeakReference<>(holder.binding.statusBoosterDisplayName)),
holder.binding.statusBoosterDisplayName),
TextView.BufferType.SPANNABLE);
holder.binding.statusBoosterInfo.setVisibility(View.VISIBLE);
@ -1506,7 +1506,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
//--- MAIN CONTENT ---
holder.binding.statusContent.setText(
statusToDeal.getSpanContent(context, remote,
new WeakReference<>(holder.binding.statusContent)),
holder.binding.statusContent),
TextView.BufferType.SPANNABLE);
if (truncate_toots_size > 0) {
holder.binding.statusContent.setMaxLines(truncate_toots_size);
@ -1531,7 +1531,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.containerTrans.setVisibility(View.VISIBLE);
holder.binding.statusContentTranslated.setText(
statusToDeal.getSpanTranslate(context,
new WeakReference<>(holder.binding.statusContentTranslated)),
holder.binding.statusContentTranslated),
TextView.BufferType.SPANNABLE);
} else {
holder.binding.containerTrans.setVisibility(View.GONE);
@ -1955,7 +1955,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
pollItemBinding.pollItemPercent.setText(String.format("%s %%", (int) value));
pollItemBinding.pollItemText.setText(
pollItem.getSpanTitle(context, statusToDeal,
new WeakReference<>(pollItemBinding.pollItemText)),
pollItemBinding.pollItemText),
TextView.BufferType.SPANNABLE);
pollItemBinding.pollItemValue.setProgress((int) value);
if (pollItem.votes_count == greaterValue) {
@ -1984,7 +1984,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
CheckBox cb = new CheckBox(context);
cb.setText(
pollOption.getSpanTitle(context, statusToDeal,
new WeakReference<>(cb)),
cb),
TextView.BufferType.SPANNABLE);
holder.binding.poll.multipleChoice.addView(cb);
}
@ -1997,7 +1997,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
RadioButton rb = new RadioButton(context);
rb.setText(
pollOption.getSpanTitle(context, statusToDeal,
new WeakReference<>(rb)),
rb),
TextView.BufferType.SPANNABLE);
holder.binding.poll.singleChoiceRadioGroup.addView(rb);
@ -3378,7 +3378,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
holder.bindingArt.artUsername.setText(
status.account.getSpanDisplayName(context,
new WeakReference<>(holder.bindingArt.artUsername)),
holder.bindingArt.artUsername),
TextView.BufferType.SPANNABLE);
holder.bindingArt.artAcct.setText(String.format(Locale.getDefault(), "@%s", status.account.acct));
holder.bindingArt.artPp.setOnClickListener(v -> {
@ -3543,7 +3543,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
});
holder.bindingPixelfed.artUsername.setText(
statusToDeal.account.getSpanDisplayName(context,
new WeakReference<>(holder.bindingPixelfed.artUsername)),
holder.bindingPixelfed.artUsername),
TextView.BufferType.SPANNABLE);
holder.bindingPixelfed.artAcct.setText(String.format(Locale.getDefault(), "@%s", statusToDeal.account.acct));
holder.bindingPixelfed.artPp.setOnClickListener(v -> {

View file

@ -241,7 +241,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
status.underlined = true;
holder.binding.messageContent.setText(
status.getSpanContent(context, false,
new WeakReference<>(holder.binding.messageContent)),
holder.binding.messageContent),
TextView.BufferType.SPANNABLE);
holder.binding.messageContent.setMovementMethod(LongClickLinkMovementMethod.getInstance());
if (measuredWidth <= 0 && status.media_attachments != null && status.media_attachments.size() > 0) {
@ -370,7 +370,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
pollItemBinding.pollItemPercent.setText(String.format("%s %%", (int) value));
pollItemBinding.pollItemText.setText(
pollItem.getSpanTitle(context, status,
new WeakReference<>(pollItemBinding.pollItemText)),
pollItemBinding.pollItemText),
TextView.BufferType.SPANNABLE);
if (status.account.id.equals(MainActivity.currentUserID)) {
pollItemBinding.pollItemPercent.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
@ -407,7 +407,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
CheckBox cb = new CheckBox(context);
cb.setText(
pollOption.getSpanTitle(context, status,
new WeakReference<>(cb)),
cb),
TextView.BufferType.SPANNABLE);
holder.binding.poll.multipleChoice.addView(cb);
if (status.account.id.equals(MainActivity.currentUserID)) {
@ -426,7 +426,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
RadioButton rb = new RadioButton(context);
rb.setText(
pollOption.getSpanTitle(context, status,
new WeakReference<>(rb)),
rb),
TextView.BufferType.SPANNABLE);
if (status.account.id.equals(MainActivity.currentUserID)) {
@ -524,7 +524,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
}
holder.binding.userName.setText(
status.account.getSpanDisplayName(context,
new WeakReference<>(holder.binding.userName)),
holder.binding.userName),
TextView.BufferType.SPANNABLE);
if (status.media_attachments != null && status.media_attachments.size() > 0) {

View file

@ -56,13 +56,13 @@ public class StatusHistoryAdapter extends RecyclerView.Adapter<RecyclerView.View
Status status = statuses.get(position);
holder.binding.statusContent.setText(
status.getSpanContent(context, false,
new WeakReference<>(holder.binding.statusContent)),
holder.binding.statusContent),
TextView.BufferType.SPANNABLE);
if (status.spoiler_text != null && !status.spoiler_text.trim().isEmpty()) {
holder.binding.spoiler.setVisibility(View.VISIBLE);
holder.binding.spoiler.setText(
status.getSpanSpoiler(context,
new WeakReference<>(holder.binding.spoiler)),
holder.binding.spoiler),
TextView.BufferType.SPANNABLE);
} else {
holder.binding.spoiler.setVisibility(View.GONE);
@ -72,7 +72,7 @@ public class StatusHistoryAdapter extends RecyclerView.Adapter<RecyclerView.View
if (status.account != null) {
holder.binding.displayName.setText(
status.account.getSpanDisplayName(context,
new WeakReference<>(holder.binding.displayName)),
holder.binding.displayName),
TextView.BufferType.SPANNABLE);
holder.binding.username.setText(String.format("@%s", status.account.acct));
}

View file

@ -101,12 +101,12 @@ public class SuggestionAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
holder.binding.displayName.setText(
account.getSpanDisplayName(context,
new WeakReference<>(holder.binding.displayName)),
holder.binding.displayName),
TextView.BufferType.SPANNABLE);
holder.binding.username.setText(String.format("@%s", account.acct));
holder.binding.bio.setText(
account.getSpanNote(context,
new WeakReference<>(holder.binding.bio)),
holder.binding.bio),
TextView.BufferType.SPANNABLE);
holder.binding.followAction.setOnClickListener(v -> {

View file

@ -73,7 +73,7 @@ public class ReportAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.accountDn.setText(
report.account.account.getSpanDisplayName(context,
new WeakReference<>(holder.binding.accountDn)),
holder.binding.accountDn),
TextView.BufferType.SPANNABLE);
MastodonHelper.loadPPMastodon(holder.binding.accountPp, target_account);