Simplify loadJSONFromAsset()
This commit is contained in:
parent
997f2be5e5
commit
4c54a12af2
@ -20,9 +20,9 @@ import android.net.Uri
|
|||||||
import androidx.media3.common.MediaItem
|
import androidx.media3.common.MediaItem
|
||||||
import androidx.media3.common.MediaItem.SubtitleConfiguration
|
import androidx.media3.common.MediaItem.SubtitleConfiguration
|
||||||
import androidx.media3.common.MediaMetadata
|
import androidx.media3.common.MediaMetadata
|
||||||
import androidx.media3.common.util.Util
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import java.io.BufferedReader
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sample media catalog that represents media items as a tree.
|
* A sample media catalog that represents media items as a tree.
|
||||||
@ -91,10 +91,8 @@ object MediaItemTree {
|
|||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadJSONFromAsset(assets: AssetManager): String {
|
private fun loadJSONFromAsset(assets: AssetManager): String =
|
||||||
val buffer = assets.open("catalog.json").use { Util.toByteArray(it) }
|
assets.open("catalog.json").bufferedReader().use(BufferedReader::readText)
|
||||||
return String(buffer, Charsets.UTF_8)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun initialize(assets: AssetManager) {
|
fun initialize(assets: AssetManager) {
|
||||||
if (isInitialized) return
|
if (isInitialized) return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user