fix: Fix potential NPE in `ConversationViewHolder`
`ConversationViewHolder` calls `getDisplayName()`, which may return null. Replace with `getName()`, which is consistent with usage in other classes. Mark `getDisplayName()` as deprecated to prevent future usage.
This commit is contained in:
parent
da808793f5
commit
1a817d9b29
|
@ -81,7 +81,7 @@ public class ConversationViewHolder extends StatusBaseViewHolder {
|
|||
|
||||
setupCollapsedState(statusViewData.isCollapsible(), statusViewData.isCollapsed(), statusViewData.isExpanded(), statusViewData.getSpoilerText(), listener);
|
||||
|
||||
setDisplayName(account.getDisplayName(), account.getEmojis(), statusDisplayOptions);
|
||||
setDisplayName(account.getName(), account.getEmojis(), statusDisplayOptions);
|
||||
setUsername(account.getUsername());
|
||||
setMetaData(statusViewData, statusDisplayOptions, listener);
|
||||
setIsReply(status.getInReplyToId() != null);
|
||||
|
|
|
@ -25,7 +25,10 @@ data class TimelineAccount(
|
|||
val id: String,
|
||||
@SerializedName("username") val localUsername: String,
|
||||
@SerializedName("acct") val username: String,
|
||||
@SerializedName("display_name") val displayName: String?, // should never be null per Api definition, but some servers break the contract
|
||||
|
||||
@Deprecated("prefer the `name` property, which is not-null and not-empty")
|
||||
@SerializedName("display_name")
|
||||
val displayName: String?, // should never be null per Api definition, but some servers break the contract
|
||||
val url: String,
|
||||
val avatar: String,
|
||||
val note: String,
|
||||
|
@ -33,6 +36,7 @@ data class TimelineAccount(
|
|||
val emojis: List<Emoji>? = emptyList(), // nullable for backward compatibility
|
||||
) {
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val name: String
|
||||
get() = if (displayName.isNullOrEmpty()) {
|
||||
localUsername
|
||||
|
|
Loading…
Reference in New Issue