mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-12 05:07:46 +02:00
refactor: ModConfig lateInit
This commit is contained in:
@ -36,10 +36,11 @@ import me.rhunk.snapenhance.nativelib.NativeLib
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class ModContext {
|
||||
class ModContext(
|
||||
val androidContext: Context
|
||||
) {
|
||||
val coroutineScope = CoroutineScope(Dispatchers.IO)
|
||||
|
||||
lateinit var androidContext: Context
|
||||
lateinit var bridgeClient: BridgeClient
|
||||
var mainActivity: Activity? = null
|
||||
|
||||
@ -47,7 +48,7 @@ class ModContext {
|
||||
val resources: Resources get() = androidContext.resources
|
||||
val gson: Gson = GsonBuilder().create()
|
||||
|
||||
private val _config = ModConfig()
|
||||
private val _config = ModConfig(androidContext)
|
||||
val config by _config::root
|
||||
val log by lazy { CoreLogger(this.bridgeClient) }
|
||||
val translation = LocaleWrapper()
|
||||
|
@ -33,7 +33,7 @@ class SnapEnhance {
|
||||
SnapClassCache(classLoader)
|
||||
}
|
||||
}
|
||||
private val appContext = ModContext()
|
||||
private lateinit var appContext: ModContext
|
||||
private var isBridgeInitialized = false
|
||||
private var isActivityPaused = false
|
||||
|
||||
@ -47,9 +47,11 @@ class SnapEnhance {
|
||||
|
||||
init {
|
||||
Application::class.java.hook("attach", HookStage.BEFORE) { param ->
|
||||
appContext.apply {
|
||||
appContext = ModContext(
|
||||
androidContext = param.arg<Context>(0).also { classLoader = it.classLoader }
|
||||
bridgeClient = BridgeClient(appContext)
|
||||
)
|
||||
appContext.apply {
|
||||
bridgeClient = BridgeClient(this)
|
||||
bridgeClient.apply {
|
||||
connect(
|
||||
onFailure = {
|
||||
|
Reference in New Issue
Block a user