fix crash when Account.displayName is null (#1667)

This commit is contained in:
Konrad Pozniak 2020-02-07 20:23:51 +01:00 committed by GitHub
parent fde23f25d2
commit 88b8eca16a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -458,7 +458,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
loadAvatar(movedAccount.avatar, accountMovedAvatar, avatarRadius, animateAvatar) loadAvatar(movedAccount.avatar, accountMovedAvatar, avatarRadius, animateAvatar)
accountMovedText.text = getString(R.string.account_moved_description, movedAccount.displayName) accountMovedText.text = getString(R.string.account_moved_description, movedAccount.name)
// this is necessary because API 19 can't handle vector compound drawables // this is necessary because API 19 can't handle vector compound drawables
val movedIcon = ContextCompat.getDrawable(this, R.drawable.ic_briefcase)?.mutate() val movedIcon = ContextCompat.getDrawable(this, R.drawable.ic_briefcase)?.mutate()

View File

@ -166,7 +166,7 @@ fun Account.toEntity() =
ConversationAccountEntity( ConversationAccountEntity(
id, id,
username, username,
displayName, displayName.orEmpty(),
avatar, avatar,
emojis ?: emptyList() emojis ?: emptyList()
) )

View File

@ -31,7 +31,7 @@ data class Account(
val id: String, val id: String,
@SerializedName("username") val localUsername: String, @SerializedName("username") val localUsername: String,
@SerializedName("acct") val username: String, @SerializedName("acct") val username: String,
@SerializedName("display_name") val displayName: String, @SerializedName("display_name") val displayName: String?, // should never be null per Api definition, but some servers break the contract
val note: @WriteWith<SpannedParceler>() Spanned, val note: @WriteWith<SpannedParceler>() Spanned,
val url: String, val url: String,
val avatar: String, val avatar: String,
@ -49,7 +49,7 @@ data class Account(
) : Parcelable { ) : Parcelable {
val name: String val name: String
get() = if (displayName.isEmpty()) { get() = if (displayName.isNullOrEmpty()) {
localUsername localUsername
} else displayName } else displayName

View File

@ -298,7 +298,7 @@ fun Account.toEntity(accountId: Long, gson: Gson): TimelineAccountEntity {
timelineUserId = accountId, timelineUserId = accountId,
localUsername = localUsername, localUsername = localUsername,
username = username, username = username,
displayName = displayName, displayName = displayName.orEmpty(),
url = url, url = url,
avatar = avatar, avatar = avatar,
emojis = gson.toJson(emojis), emojis = gson.toJson(emojis),