mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-30 06:34:34 +02:00
Prevent crashes on non-existing assets
This commit is contained in:
parent
f73e25ece6
commit
aaa2d7f08d
@ -1,6 +1,7 @@
|
|||||||
package com.futo.platformplayer.states
|
package com.futo.platformplayer.states
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import com.futo.platformplayer.logging.Logger
|
||||||
import kotlin.streams.asSequence
|
import kotlin.streams.asSequence
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@ -45,10 +46,16 @@ class StateAssets {
|
|||||||
var text: String?;
|
var text: String?;
|
||||||
synchronized(_cache) {
|
synchronized(_cache) {
|
||||||
if (!_cache.containsKey(path)) {
|
if (!_cache.containsKey(path)) {
|
||||||
text = context.assets
|
try {
|
||||||
?.open(path)
|
text = context.assets
|
||||||
?.bufferedReader()
|
?.open(path)
|
||||||
?.use { it.readText(); };
|
?.bufferedReader()
|
||||||
|
?.use { it.readText(); };
|
||||||
|
}
|
||||||
|
catch(ex: Throwable) {
|
||||||
|
Logger.e("StateAssets", "Could not open asset: " + path, ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
_cache.put(path, text);
|
_cache.put(path, text);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user