Accept null value for Nextcloud News feed attribute folderId. Fixes #87

This commit is contained in:
Shinokuni 2020-11-11 21:59:05 +01:00
parent d4e546b6c1
commit cec3c467cf
2 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package com.readrops.api.services.nextcloudnews.adapters
import android.annotation.SuppressLint
import com.readrops.api.utils.nextNullableInt
import com.readrops.db.entities.Feed
import com.readrops.api.utils.nextNullableString
import com.squareup.moshi.FromJson
@ -43,8 +44,8 @@ class NextNewsFeedsAdapter {
2 -> name = reader.nextString()
3 -> iconUrl = reader.nextString()
4 -> {
val nextInt = reader.nextInt()
remoteFolderId = if (nextInt > 0) nextInt.toString() else null
val nextInt = reader.nextNullableInt()
remoteFolderId = if (nextInt != null && nextInt > 0) nextInt.toString() else null
}
5 -> siteUrl = reader.nextNullableString()
else -> reader.skipValue()

View File

@ -3,4 +3,7 @@ package com.readrops.api.utils
import com.squareup.moshi.JsonReader
fun JsonReader.nextNullableString(): String? =
if (peek() != JsonReader.Token.NULL) nextString() else nextNull()
if (peek() != JsonReader.Token.NULL) nextString() else nextNull()
fun JsonReader.nextNullableInt(): Int? =
if (peek() != JsonReader.Token.NULL) nextInt() else nextNull()