Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,11 @@ class V8Plugin {
}
}
}
fun executeString(js: String) : String? = busy {
catchScriptErrors("Plugin[${config.name}]") {
executeTyped<V8ValueString>(js).value
}
}
fun <T : V8Value> executeTyped(js: String) : T {
warnIfMainThread("V8Plugin.executeTyped");
if(isStopped)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ class StatePlugins {
return iconsDir.getIconBinary(id);
return null;
}

suspend fun getDynamicIcon(id: String): String? = withContext(Dispatchers.IO) {
val client = StatePlatform.instance.getClientOrNull(id) as? JSClient ?: return@withContext null;
return@withContext client.getUnderlyingPlugin().executeString("source.getIcon()")
}
fun reloadPluginFile(){


_plugins = FragmentedStorage.storeJson<SourcePluginDescriptor>("plugins")
.load();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,20 @@ class SourceHeaderView : LinearLayout {
val loadedIcon = StatePlugins.instance.getPluginIconOrNull(config.id);
if(loadedIcon != null)
loadedIcon.setImageView(_sourceImage);
else
Glide.with(_sourceImage)
.load(config.absoluteIconUrl)
.into(_sourceImage);
else {
StateApp.instance.scope.launch {
val dynamicIcon = StatePlugins.instance.getDynamicIcon(config.id)
val iconToLoad = dynamicIcon ?: config.absoluteIconUrl
withContext(Dispatchers.Main) {
Glide.with(_sourceImage)
.load(iconToLoad)
.into(_sourceImage);
}
}
}

_sourceTitle.text = config.name;

_sourceBy.text = config.author
_sourceDescription.text = config.description;
_sourceVersion.text = config.version.toString();
Expand Down