Take capability below API 24, and add comment.

Change-Id: I86d99fa9e74a8475c0b2bad202cfb4697ab1016b
pull/1837/head
Jaehwa Noh 1 year ago
parent 6af76eeea5
commit 19374bced5

@ -51,7 +51,10 @@ class DemoNiaNetworkDataSource @Inject constructor(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
assets.open(TOPICS_ASSET).use(networkJson::decodeFromStream)
} else {
networkJson.decodeFromString(assets.open(TOPICS_ASSET).toString())
// Use decodeFromString to capability with API 24 below.
// https://github.com/Kotlin/kotlinx.serialization/issues/2457#issuecomment-1786923342
val topicsJsonString = convertStreamToString(assets.open(TOPICS_ASSET))
networkJson.decodeFromString(topicsJsonString)
}
}
@ -61,7 +64,10 @@ class DemoNiaNetworkDataSource @Inject constructor(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
assets.open(NEWS_ASSET).use(networkJson::decodeFromStream)
} else {
networkJson.decodeFromString(assets.open(TOPICS_ASSET).toString())
// Use decodeFromString to capability with API 24 below.
// https://github.com/Kotlin/kotlinx.serialization/issues/2457#issuecomment-1786923342
val newsJsonString = convertStreamToString(assets.open(NEWS_ASSET))
networkJson.decodeFromString(newsJsonString)
}
}

Loading…
Cancel
Save