Fix crash with unknown notification type (#1123)
* Fix crash with unknown notification type * Add NotificationTypeAdapter to handle unknown type * Remove unneeded SerializedName
This commit is contained in:
parent
4f7c989b2d
commit
d0f7f6f83c
3 changed files with 39 additions and 6 deletions
|
@ -15,7 +15,8 @@
|
|||
|
||||
package com.keylesspalace.tusky.entity
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.google.gson.annotations.JsonAdapter
|
||||
import com.keylesspalace.tusky.json.NotificationTypeAdapter
|
||||
|
||||
data class Notification(
|
||||
val type: Type,
|
||||
|
@ -23,15 +24,28 @@ data class Notification(
|
|||
val account: Account,
|
||||
val status: Status?) {
|
||||
|
||||
@JsonAdapter(NotificationTypeAdapter::class)
|
||||
enum class Type {
|
||||
@SerializedName("mention")
|
||||
UNKNOWN,
|
||||
MENTION,
|
||||
@SerializedName("reblog")
|
||||
REBLOG,
|
||||
@SerializedName("favourite")
|
||||
FAVOURITE,
|
||||
@SerializedName("follow")
|
||||
FOLLOW
|
||||
FOLLOW;
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
fun byString(s: String): Type {
|
||||
return when (s) {
|
||||
"mention" -> MENTION
|
||||
"reblog" -> REBLOG
|
||||
"favourite" -> FAVOURITE
|
||||
"follow" -> FOLLOW
|
||||
else -> UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue