Some changes

This commit is contained in:
Thomas 2020-06-16 20:09:29 +02:00
parent 1c31f1b9d1
commit f4de89f2fa
10 changed files with 89 additions and 285 deletions

View File

@ -618,7 +618,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
SpannableString spannableString = Helper.clickableElementsDescription(ShowAccountActivity.this, account.getNote());
account.setNoteSpan(spannableString);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
account.makeEmojisAccountProfile(ShowAccountActivity.this, ShowAccountActivity.this, account);
account.fillProfileAccount(ShowAccountActivity.this, ShowAccountActivity.this, account);
account_note.setText(account.getNoteSpan(), TextView.BufferType.SPANNABLE);
account_note.setMovementMethod(LinkMovementMethod.getInstance());
if (!peertubeAccount && tabLayout.getTabAt(0) != null && tabLayout.getTabAt(1) != null && tabLayout.getTabAt(2) != null) {

View File

@ -111,10 +111,6 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
detailsStatus.setFocused(true);
//Some spannable
Status.fillSpan(new WeakReference<>(ShowConversationActivity.this), detailsStatus);
if (detailsStatus.getPoll() != null) {
Status.makeEmojiPoll(new WeakReference<>(ShowConversationActivity.this), detailsStatus.getPoll());
}
Account.makeAccountNameEmoji(new WeakReference<>(ShowConversationActivity.this), detailsStatus.getAccount());
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {

View File

@ -374,8 +374,6 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
for (app.fedilab.android.client.Entities.Status status : statuses) {
app.fedilab.android.client.Entities.Status.fillSpan(contextReference, status);
app.fedilab.android.client.Entities.Status.makeEmojiPoll(contextReference, status.getReblog() != null ? status.getReblog().getPoll() : status.getPoll());
Account.makeAccountNameEmoji(contextReference, status.getReblog() != null ? status.getReblog().getAccount() : status.getAccount());
}
} else {
statuses = new ArrayList<>();

View File

@ -740,7 +740,6 @@ public class API {
} catch (JSONException | ParseException e) {
e.printStackTrace();
}
Status.makeEmojiPoll(new WeakReference<>(context), poll);
return poll;
}
@ -1510,11 +1509,6 @@ public class API {
} catch (JSONException | ParseException e) {
e.printStackTrace();
}
try {
Account.makeAccountNameEmoji(new WeakReference<>(context), account);
} catch (Exception e) {
e.printStackTrace();
}
return account;
}

View File

@ -200,63 +200,6 @@ public class Account implements Parcelable {
this.invited_by_account_id = in.readString();
}
public static void makeAccountNameEmoji(final WeakReference<Context> contextWeakReference, Account account) {
Context context = contextWeakReference.get();
if ((context instanceof Activity && ((Activity) context).isFinishing()) || account == null || account.getDisplay_name() == null)
return;
account.setDisplayNameSpan(new SpannableString(account.getDisplay_name()));
SpannableString displayNameSpan = account.getDisplayNameSpan();
if (displayNameSpan == null)
return;
final List<Emojis> emojis = account.getEmojis();
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
if (emojis != null && emojis.size() > 0) {
final int[] i = {0};
for (final Emojis emoji : emojis) {
try {
Glide.with(context)
.asDrawable()
.load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
.into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
final String targetedEmoji = ":" + emoji.getShortcode() + ":";
if (displayNameSpan.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = displayNameSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length();
if (resource != null && endPosition <= displayNameSpan.toString().length() && endPosition >= startPosition) {
try {
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
resource.setVisible(true, true);
ImageSpan imageSpan = new ImageSpan(resource);
displayNameSpan.setSpan(
imageSpan, startPosition,
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
} catch (Exception ignored) {
}
return;
}
}
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
@Override
public int describeContents() {
@ -534,6 +477,9 @@ public class Account implements Parcelable {
}
public SpannableString getDisplayNameSpan() {
if (this.displayNameSpan == null) {
displayNameSpan = new SpannableString(display_name);
}
return displayNameSpan;
}
@ -745,15 +691,14 @@ public class Account implements Parcelable {
return spannableString;
}
public void makeEmojisAccountProfile(final Context context, final OnRetrieveEmojiAccountInterface listener, Account account) {
public void fillProfileAccount(final Context context, final OnRetrieveEmojiAccountInterface listener, Account account) {
if (context instanceof Activity && ((Activity) context).isFinishing())
return;
if (fields == null)
fields = new LinkedHashMap<>();
if (fieldsSpan == null)
fieldsSpan = new LinkedHashMap<>();
if (account.getDisplay_name() != null)
displayNameSpan = new SpannableString(account.getDisplay_name());
displayNameSpan = account.getDisplayNameSpan();
ArrayList<Account> accountsMentionUnknown = new ArrayList<>();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

View File

@ -74,6 +74,9 @@ public class PollOptions implements Parcelable {
}
public SpannableString getTitleSpan() {
if( titleSpan == null) {
titleSpan = new SpannableString(title);
}
return titleSpan;
}

View File

@ -267,7 +267,6 @@ public class Status implements Parcelable {
public static void fillSpan(WeakReference<Context> contextWeakReference, Status status) {
Status.transform(contextWeakReference, status);
Status.makeEmojis(contextWeakReference, status);
Status.makeImage(contextWeakReference, status);
}
@ -895,126 +894,6 @@ public class Status implements Parcelable {
status.setContentSpanTranslated(contentSpanTranslated);
}
private static void makeEmojis(final WeakReference<Context> contextWeakReference, Status status) {
Context context = contextWeakReference.get();
if (context instanceof Activity && ((Activity) context).isFinishing())
return;
if (status.getReblog() != null && status.getReblog().getEmojis() == null)
return;
if (status.getReblog() == null && status.getEmojis() == null)
return;
final List<Emojis> emojis = status.getReblog() != null ? status.getReblog().getEmojis() : status.getEmojis();
SpannableString contentSpan = status.getContentSpan();
SpannableString contentSpanCW = status.getContentSpanCW();
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
if (emojis != null && emojis.size() > 0) {
final int[] i = {0};
for (final Emojis emoji : emojis) {
Glide.with(context)
.asDrawable()
.load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
.into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
final String targetedEmoji = ":" + emoji.getShortcode() + ":";
if (contentSpan != null && contentSpan.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = contentSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length();
if (endPosition <= contentSpan.toString().length() && endPosition >= startPosition) {
ImageSpan imageSpan;
try {
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
resource.setVisible(true, true);
imageSpan = new ImageSpan(resource);
contentSpan.setSpan(
imageSpan, startPosition,
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
} catch (Exception ignored) {
}
}
}
}
if (contentSpanCW != null && contentSpanCW.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = contentSpanCW.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length();
if (endPosition <= contentSpanCW.toString().length() && endPosition >= startPosition) {
ImageSpan imageSpan;
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
resource.setVisible(true, true);
imageSpan = new ImageSpan(resource);
contentSpanCW.setSpan(
imageSpan, startPosition,
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}
}
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
}
}
}
public static void makeEmojiPoll(final WeakReference<Context> contextWeakReference, Poll poll) {
Context context = contextWeakReference.get();
if ((context instanceof Activity && ((Activity) context).isFinishing()) || poll == null || poll.getOptionsList() == null)
return;
final List<Emojis> emojis = poll.getEmojis();
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
int inc = 0;
for (PollOptions pollOption : poll.getOptionsList()) {
inc++;
SpannableString titleSpan = new SpannableString(pollOption.getTitle());
if (emojis != null && emojis.size() > 0) {
final int[] i = {0};
for (final Emojis emoji : emojis) {
Glide.with(context)
.asDrawable()
.load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
.into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
final String targetedEmoji = ":" + emoji.getShortcode() + ":";
if (titleSpan.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = titleSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length();
if (endPosition <= titleSpan.toString().length() && endPosition >= startPosition) {
ImageSpan imageSpan;
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
resource.setVisible(true, true);
imageSpan = new ImageSpan(resource);
titleSpan.setSpan(
imageSpan, startPosition,
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
pollOption.setTitleSpan(titleSpan);
}
}
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
}
}
}
}
private static void makeImage(final WeakReference<Context> contextWeakReference, Status status) {
Context context = contextWeakReference.get();
@ -1068,78 +947,6 @@ public class Status implements Parcelable {
}
public static void makeEmojisTranslation(final Context context, final OnRetrieveEmojiInterface listener, Status status) {
if (context instanceof Activity && ((Activity) context).isFinishing())
return;
SpannableString spannableStringTranslated = null;
if (status.getContentTranslated() != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
spannableStringTranslated = new SpannableString(Html.fromHtml(status.getContentTranslated(), Html.FROM_HTML_MODE_LEGACY));
else
spannableStringTranslated = new SpannableString(Html.fromHtml(status.getContentTranslated()));
}
final List<Emojis> emojis = status.getReblog() != null ? status.getReblog().getEmojis() : status.getEmojis();
if (emojis != null && emojis.size() > 0) {
final int[] i = {0};
for (final Emojis emoji : emojis) {
final SpannableString finalSpannableStringTranslated = spannableStringTranslated;
Glide.with(context)
.asBitmap()
.load(emoji.getUrl())
.listener(new RequestListener<Bitmap>() {
@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
i[0]++;
if (i[0] == (emojis.size())) {
if (finalSpannableStringTranslated != null)
status.setContentSpanTranslated(finalSpannableStringTranslated);
listener.onRetrieveEmoji(status, true);
}
return false;
}
})
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
final String targetedEmoji = ":" + emoji.getShortcode() + ":";
if (finalSpannableStringTranslated != null && finalSpannableStringTranslated.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = finalSpannableStringTranslated.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length();
if (endPosition <= finalSpannableStringTranslated.toString().length() && endPosition >= startPosition)
finalSpannableStringTranslated.setSpan(
new ImageSpan(context,
Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(20, context),
(int) Helper.convertDpToPixel(20, context), false)), startPosition,
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}
}
i[0]++;
if (i[0] == (emojis.size())) {
if (finalSpannableStringTranslated != null)
status.setContentSpanTranslated(finalSpannableStringTranslated);
status.setEmojiTranslateFound(true);
listener.onRetrieveEmoji(status, true);
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
}
}
}
private static void replaceQuoteSpans(Context context, Spannable spannable) {
QuoteSpan[] quoteSpans = spannable.getSpans(0, spannable.length(), QuoteSpan.class);

View File

@ -114,6 +114,7 @@ import es.dmoral.toasty.Toasty;
import static android.content.Context.MODE_PRIVATE;
import static app.fedilab.android.activities.BaseMainActivity.mutedAccount;
import static app.fedilab.android.activities.BaseMainActivity.social;
import static app.fedilab.android.helper.Helper.makeEmojis;
/**
@ -1063,7 +1064,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
status.setTranslationShown(true);
status.setContentTranslated(translate.getTranslatedContent());
Status.transformTranslation(context, status);
Status.makeEmojisTranslation(context, PixelfedListAdapter.this, status);
//makeEmojis(context, view, status.getContentSpan(), status.getReblog()!=null?status.getReblog().getEmojis():status.getEmojis());
notifyStatusChanged(status);
} else {
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();

View File

@ -191,6 +191,7 @@ import static android.content.Context.MODE_PRIVATE;
import static app.fedilab.android.activities.BaseMainActivity.mPageReferenceMap;
import static app.fedilab.android.activities.BaseMainActivity.mutedAccount;
import static app.fedilab.android.activities.BaseMainActivity.social;
import static app.fedilab.android.helper.Helper.makeEmojis;
/**
@ -756,7 +757,8 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
TextView poll_item_text = item.findViewById(R.id.poll_item_text);
ProgressBar poll_item_value = item.findViewById(R.id.poll_item_value);
poll_item_percent.setText(String.format("%s %%", (int) value));
poll_item_text.setText(pollOption.getTitle(), TextView.BufferType.SPANNABLE);
poll_item_text.setText(pollOption.getTitleSpan(), TextView.BufferType.SPANNABLE);
makeEmojis(context, poll_item_text, pollOption.getTitleSpan(), poll.getEmojis());
poll_item_value.setProgress((int) value);
holder.rated.addView(item);
if (pollOption.getVotes_count() == greaterValue) {
@ -780,11 +782,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
(holder.multiple_choice).removeAllViews();
for (PollOptions pollOption : poll.getOptionsList()) {
CheckBox cb = new CheckBox(context);
if (pollOption.getTitleSpan() != null) {
cb.setText(pollOption.getTitleSpan(), TextView.BufferType.SPANNABLE);
} else {
cb.setText(pollOption.getTitle());
}
makeEmojis(context, cb, pollOption.getTitleSpan(), poll.getEmojis());
holder.multiple_choice.addView(cb);
}
@ -795,11 +793,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
(holder.radio_group).removeAllViews();
for (PollOptions pollOption : poll.getOptionsList()) {
RadioButton rb = new RadioButton(context);
if (pollOption.getTitleSpan() != null) {
rb.setText(pollOption.getTitleSpan(), TextView.BufferType.SPANNABLE);
} else {
rb.setText(pollOption.getTitle());
}
makeEmojis(context, rb, pollOption.getTitleSpan(), poll.getEmojis());
holder.radio_group.addView(rb);
}
holder.single_choice.setVisibility(View.VISIBLE);
@ -1229,7 +1223,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
TooltipCompat.setTooltipText(holder.custom_feature_translate, context.getString(R.string.translate));
holder.custom_feature_translate.setOnClickListener(view -> {
translateToot(status);
translateToot(status, holder.status_content_translated);
status.setCustomFeaturesDisplayed(false);
notifyStatusChanged(status);
});
@ -1561,6 +1555,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
holder.status_spoiler.setText(status.getContentSpanCW(), TextView.BufferType.SPANNABLE);
}
makeEmojis(context, holder.status_content, status.getContentSpan(), status.getReblog()!=null?status.getReblog().getEmojis():status.getEmojis());
holder.status_content.setMovementMethod(LongClickLinkMovementMethod.getInstance());
@ -1613,10 +1608,12 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
context.startActivity(intent);
});
if (status.getReblog().getAccount().getDisplay_name().length() > 0)
if (status.getReblog().getAccount().getDisplay_name().length() > 0) {
holder.status_account_displayname_owner.setText(displayNameSpan, TextView.BufferType.SPANNABLE);
else
makeEmojis(context, holder.status_account_displayname_owner, status.getReblog() != null ? status.getReblog().getAccount().getDisplayNameSpan() : status.getAccount().getDisplayNameSpan(), status.getReblog() != null ? status.getReblog().getAccount().getEmojis() : status.getAccount().getEmojis());
}else
holder.status_account_displayname_owner.setText(status.getReblog().getAccount().getAcct().replace("@", ""));
holder.status_account_displayname_owner.setVisibility(View.VISIBLE);
if (holder.status_boosted_date != null) {
holder.status_boosted_date.setText(Helper.dateDiff(context, status.getCreated_at()));
@ -2891,7 +2888,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
if (translator == Helper.TRANS_NONE)
Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show();
else
translateToot(status);
translateToot(status, holder.status_content_translated);
return true;
case R.id.action_report:
builderInner = new AlertDialog.Builder(context, style);
@ -3911,7 +3908,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
private void translateToot(Status status) {
private void translateToot(Status status, TextView view) {
//Manages translations
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
int trans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
@ -3953,7 +3950,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
status.setTranslationShown(true);
status.setContentTranslated(translate.getTranslatedContent());
Status.transformTranslation(context, status);
Status.makeEmojisTranslation(context, StatusListAdapter.this, status);
makeEmojis(context, view, status.getContentSpan(), status.getReblog()!=null?status.getReblog().getEmojis():status.getEmojis());
notifyStatusChanged(status);
} else {
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();

View File

@ -56,11 +56,13 @@ import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.text.style.ImageSpan;
import android.text.style.URLSpan;
import android.util.DisplayMetrics;
import android.util.Log;
@ -82,6 +84,7 @@ import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
@ -1970,7 +1973,8 @@ public class Helper {
activity.startActivity(myIntent);
activity.finish(); //User is logged out to get a new token
} else {
Account.makeAccountNameEmoji(new WeakReference<>(activity), account);
makeEmojis(activity, username, account.getDisplayNameSpan(), account.getEmojis());
username.setText(String.format("@%s", account.getUsername() + "@" + account.getInstance()));
displayedName.setText(account.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
loadGiF(activity, account, profilePicture);
@ -4505,4 +4509,63 @@ public class Helper {
.show();
}
}
public static void makeEmojis(Context context, View customTextView, SpannableString contentSpan, List<Emojis> emojis) {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
if (emojis != null && emojis.size() > 0) {
for (final Emojis emoji : emojis) {
Glide.with(context)
.asDrawable()
.load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
.into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
final String targetedEmoji = ":" + emoji.getShortcode() + ":";
if (contentSpan != null && contentSpan.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = contentSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length();
if (endPosition <= contentSpan.toString().length() && endPosition >= startPosition) {
ImageSpan imageSpan;
try {
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
resource.setVisible(true, true);
imageSpan = new ImageSpan(resource);
contentSpan.setSpan(
imageSpan, startPosition,
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
Log.v(Helper.TAG,emoji.getShortcode() + " -> " + customTextView.getClass().getName());
if( customTextView instanceof CustomTextView) {
((CustomTextView)customTextView).setText(contentSpan, TextView.BufferType.SPANNABLE);
}else if (customTextView instanceof RadioButton){
((RadioButton)customTextView).setText(contentSpan, TextView.BufferType.SPANNABLE);
}else if (customTextView instanceof CheckBox){
((CheckBox)customTextView).setText(contentSpan, TextView.BufferType.SPANNABLE);
}else if (customTextView instanceof TextView){
((TextView)customTextView).setText(contentSpan, TextView.BufferType.SPANNABLE);
}
} catch (Exception ignored) {
}
}
}
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
}
}
}
}