From beab36eb5707ed25e11ade17de2540a447b22bcd Mon Sep 17 00:00:00 2001 From: Keeperorowner Date: Sun, 10 Nov 2024 14:08:00 +0800 Subject: [PATCH] Update LockPremiumFeatures.kt --- .../tmoe/hook/func/LockPremiumFeatures.kt | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/cc/ioctl/tmoe/hook/func/LockPremiumFeatures.kt b/app/src/main/java/cc/ioctl/tmoe/hook/func/LockPremiumFeatures.kt index 681fe819..de827746 100644 --- a/app/src/main/java/cc/ioctl/tmoe/hook/func/LockPremiumFeatures.kt +++ b/app/src/main/java/cc/ioctl/tmoe/hook/func/LockPremiumFeatures.kt @@ -10,12 +10,30 @@ import de.robv.android.xposed.XposedHelpers @FunctionHookEntry class LockPremiumFeatures : CommonDynamicHook() { - companion object { + companion object : BaseDynamicHook { + private val instance { LockPremiumFeatures() } + private var initialized = false + + @JvmStatic + override fun getInstance(): BaseDynamicHook = instance + @JvmStatic - val INSTANCE: BaseDynamicHook by lazy { - LockPremiumFeatures().apply { - initialize() + override fun initialize(): Boolean { + if (!initialized) { + initialized = instance.initOnce() } + return initialized + } + + @JvmStatic + override fun isInitialized(): Boolean = initialized + + @JvmStatic + override fun isEnabledByUser(): Boolean = instance.isEnabledByUser + + @JvmStatic + override fun setEnabledByUser(enabled: Boolean) { + instance.setEnabledByUser(enabled) } }