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:
kyori19 2019-03-16 22:33:16 +09:00 committed by Konrad Pozniak
commit d0f7f6f83c
3 changed files with 39 additions and 6 deletions

View file

@ -0,0 +1,18 @@
package com.keylesspalace.tusky.json
import com.google.gson.JsonDeserializationContext
import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import com.google.gson.JsonParseException
import com.keylesspalace.tusky.entity.Notification
import java.lang.reflect.Type
class NotificationTypeAdapter : JsonDeserializer<Notification.Type> {
@Throws(JsonParseException::class)
override fun deserialize(json: JsonElement, typeOfT: Type, context: JsonDeserializationContext): Notification.Type {
return Notification.Type.byString(json.asString)
}
}