run all Android work on separate thread, add HotReloadPathHelper, separate loadTexture/setTexture

This commit is contained in:
Nick Fisher
2022-08-25 17:09:54 +10:00
parent 051085f440
commit f4c1f59399
12 changed files with 392 additions and 227 deletions

View File

@@ -0,0 +1,35 @@
import java.io.*
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Path
import kotlin.io.path.absolutePathString
import kotlin.io.path.listDirectoryEntries
import android.util.Log
class HotReloadPathHelper {
companion object {
fun getAssetPath(path: String, packageName: String): String? {
// iterate over evr
val shortName = packageName.split(".").last().split("_").last()
val packagePath = "/data/user/0/${packageName}/code_cache/"
Log.v("FFI", "Looking for shortName ${shortName} under package path ${packagePath}")
val files = File(packagePath).listFiles().filter {
it.path.split("/").last().startsWith(shortName)
}.map {
val f = File(it.path + "/${shortName}/build/${path}")
Log.v("FFI", "Looking for ${f.path.toString()}")
f
}.filter {
it.exists()
}.sortedBy {
Log.v("FFI", it.path.toString())
it.lastModified()
}
Log.v("FFI", files.size.toString())
if(files.size > 0)
return files.first().path;
return null;
}
}
}