mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
Prevent crashes on non-existing assets
This commit is contained in:
parent
f73e25ece6
commit
aaa2d7f08d
1 changed files with 11 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.futo.platformplayer.states
|
||||
|
||||
import android.content.Context
|
||||
import com.futo.platformplayer.logging.Logger
|
||||
import kotlin.streams.asSequence
|
||||
|
||||
/***
|
||||
|
@ -45,10 +46,16 @@ class StateAssets {
|
|||
var text: String?;
|
||||
synchronized(_cache) {
|
||||
if (!_cache.containsKey(path)) {
|
||||
text = context.assets
|
||||
?.open(path)
|
||||
?.bufferedReader()
|
||||
?.use { it.readText(); };
|
||||
try {
|
||||
text = context.assets
|
||||
?.open(path)
|
||||
?.bufferedReader()
|
||||
?.use { it.readText(); };
|
||||
}
|
||||
catch(ex: Throwable) {
|
||||
Logger.e("StateAssets", "Could not open asset: " + path, ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
_cache.put(path, text);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue