don't crash on unparseable date (#3129)

This commit is contained in:
Konrad Pozniak 2023-01-09 21:24:04 +01:00 committed by GitHub
parent 59fb710f64
commit 95631069b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -16,6 +16,8 @@
*/
package com.keylesspalace.tusky.json
import android.util.Log
import com.google.gson.JsonParseException
import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken
@ -42,7 +44,12 @@ class Rfc3339DateJsonAdapter : TypeAdapter<Date?>() {
null
}
else -> {
reader.nextString().parseIsoDate()
try {
reader.nextString().parseIsoDate()
} catch (jpe: JsonParseException) {
Log.w("Rfc3339DateJsonAdapter", jpe)
null
}
}
}
}