fix crash on old mastodon instances
This commit is contained in:
parent
71f4f0ad2d
commit
0930fab72b
3 changed files with 8 additions and 8 deletions
|
@ -325,8 +325,8 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF
|
||||||
.load(account.header)
|
.load(account.header)
|
||||||
.into(accountHeaderImageView)
|
.into(accountHeaderImageView)
|
||||||
|
|
||||||
accountFieldAdapter.fields = account.fields
|
accountFieldAdapter.fields = account.fields ?: emptyList()
|
||||||
accountFieldAdapter.emojis = account.emojis
|
accountFieldAdapter.emojis = account.emojis ?: emptyList()
|
||||||
accountFieldAdapter.notifyDataSetChanged()
|
accountFieldAdapter.notifyDataSetChanged()
|
||||||
|
|
||||||
if (account.moved != null) {
|
if (account.moved != null) {
|
||||||
|
|
|
@ -41,8 +41,8 @@ data class Account(
|
||||||
@SerializedName("statuses_count") val statusesCount: Int,
|
@SerializedName("statuses_count") val statusesCount: Int,
|
||||||
val source: AccountSource?,
|
val source: AccountSource?,
|
||||||
val bot: Boolean,
|
val bot: Boolean,
|
||||||
val emojis: List<Emoji> = emptyList(),
|
val emojis: List<Emoji>?, // nullable for backward compatibility
|
||||||
val fields: List<Field> = emptyList(),
|
val fields: List<Field>?, //nullable for backward compatibility
|
||||||
val moved: Account? = null
|
val moved: Account? = null
|
||||||
|
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
|
@ -42,13 +42,13 @@ public class CustomEmojiHelper {
|
||||||
/**
|
/**
|
||||||
* replaces emoji shortcodes in a text with EmojiSpans
|
* replaces emoji shortcodes in a text with EmojiSpans
|
||||||
* @param text the text containing custom emojis
|
* @param text the text containing custom emojis
|
||||||
* @param emojis a list of the custom emojis
|
* @param emojis a list of the custom emojis (nullable for backward compatibility with old mastodon instances)
|
||||||
* @param textView a reference to the textView the emojis will be shown in
|
* @param textView a reference to the textView the emojis will be shown in
|
||||||
* @return the text with the shortcodes replaced by EmojiSpans
|
* @return the text with the shortcodes replaced by EmojiSpans
|
||||||
*/
|
*/
|
||||||
public static Spanned emojifyText(@NonNull Spanned text, @NonNull List<Emoji> emojis, @NonNull final TextView textView) {
|
public static Spanned emojifyText(@NonNull Spanned text, @Nullable List<Emoji> emojis, @NonNull final TextView textView) {
|
||||||
|
|
||||||
if (!emojis.isEmpty()) {
|
if (emojis != null && !emojis.isEmpty()) {
|
||||||
|
|
||||||
SpannableStringBuilder builder = new SpannableStringBuilder(text);
|
SpannableStringBuilder builder = new SpannableStringBuilder(text);
|
||||||
for (Emoji emoji : emojis) {
|
for (Emoji emoji : emojis) {
|
||||||
|
@ -71,7 +71,7 @@ public class CustomEmojiHelper {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spanned emojifyString(@NonNull String string, @NonNull List<Emoji> emojis, @NonNull final TextView textView) {
|
public static Spanned emojifyString(@NonNull String string, @Nullable List<Emoji> emojis, @NonNull final TextView textView) {
|
||||||
return emojifyText(new SpannedString(string), emojis, textView);
|
return emojifyText(new SpannedString(string), emojis, textView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue