fix crash on old mastodon instances

main
Conny Duck 7 years ago
parent a03df86c66
commit edec387e53
  1. 4
      app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt
  2. 4
      app/src/main/java/com/keylesspalace/tusky/entity/Account.kt
  3. 8
      app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.java

@ -325,8 +325,8 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF
.load(account.header)
.into(accountHeaderImageView)
accountFieldAdapter.fields = account.fields
accountFieldAdapter.emojis = account.emojis
accountFieldAdapter.fields = account.fields ?: emptyList()
accountFieldAdapter.emojis = account.emojis ?: emptyList()
accountFieldAdapter.notifyDataSetChanged()
if (account.moved != null) {

@ -41,8 +41,8 @@ data class Account(
@SerializedName("statuses_count") val statusesCount: Int,
val source: AccountSource?,
val bot: Boolean,
val emojis: List<Emoji> = emptyList(),
val fields: List<Field> = emptyList(),
val emojis: List<Emoji>?, // nullable for backward compatibility
val fields: List<Field>?, //nullable for backward compatibility
val moved: Account? = null
) : Parcelable {

@ -42,13 +42,13 @@ public class CustomEmojiHelper {
/**
* replaces emoji shortcodes in a text with EmojiSpans
* @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
* @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);
for (Emoji emoji : emojis) {
@ -71,7 +71,7 @@ public class CustomEmojiHelper {
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);
}

Loading…
Cancel
Save