diff --git a/app/src/main/java/org/autojs/autojs/ui/fragment/BindingDelegates.kt b/app/src/main/java/org/autojs/autojs/ui/fragment/BindingDelegates.kt index ed38922b..bcd0aaa6 100644 --- a/app/src/main/java/org/autojs/autojs/ui/fragment/BindingDelegates.kt +++ b/app/src/main/java/org/autojs/autojs/ui/fragment/BindingDelegates.kt @@ -1,22 +1,32 @@ package org.autojs.autojs.ui.fragment -import androidx.fragment.app.Fragment import android.view.View +import androidx.fragment.app.Fragment +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.LifecycleOwner +import androidx.viewbinding.ViewBinding import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KProperty object BindingDelegates { - fun Fragment.viewBinding(bindView: (View) -> T) = object : ReadOnlyProperty { + // @Created by JetBrains AI Assistant on Mar 12, 2025. + // @Modified by JetBrains AI Assistant as of Mar 13, 2025. + inline fun Fragment.viewBinding(crossinline bindView: (View) -> T) = object : ReadOnlyProperty { private var binding: T? = null override fun getValue(thisRef: Fragment, property: KProperty<*>): T { - return binding ?: bindView(thisRef.requireView()).also { binding = it } + return binding ?: bindView(requireView()).also { + binding = it + + viewLifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver { + override fun onDestroy(owner: LifecycleOwner) { + binding = null + } + }) + } } - - override fun toString() = "Binding for ${this@viewBinding.javaClass.name}: $binding" - } } \ No newline at end of file diff --git a/app/src/main/java/org/autojs/autojs/ui/main/scripts/ExplorerFragment.kt b/app/src/main/java/org/autojs/autojs/ui/main/scripts/ExplorerFragment.kt index c2304f19..fc7b18fb 100644 --- a/app/src/main/java/org/autojs/autojs/ui/main/scripts/ExplorerFragment.kt +++ b/app/src/main/java/org/autojs/autojs/ui/main/scripts/ExplorerFragment.kt @@ -42,21 +42,22 @@ import org.greenrobot.eventbus.Subscribe * Modified by SuperMonster003 as of Mar 20, 2022. * Transformed by SuperMonster003 on Mar 31, 2023. */ -open class ExplorerFragment : ViewPagerFragment(0), OnFloatingActionButtonClickListener, ViewStatesManageable { +class ExplorerFragment : ViewPagerFragment(0), OnFloatingActionButtonClickListener, ViewStatesManageable { - private var mBottomInset: Int = 0 private val binding by viewBinding(FragmentExplorerBinding::bind) private var mExplorerView: ExplorerView? = null private var mFloatingActionMenu: FloatingActionMenu? = null private var mIsCurrentPageFiles = false + + private var mBottomInset: Int = 0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) EventBus.getDefault().register(this) } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { return FragmentExplorerBinding.inflate(inflater, container, false).root } diff --git a/version.properties b/version.properties index 026773d2..4e6e49a5 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Thu Mar 13 01:24:48 CST 2025 -BUILD_TIME=1741800288640 +#Thu Mar 13 12:06:20 CST 2025 +BUILD_TIME=1741838780961 COMPILE_SDK_VERSION=35 JAVA_VERSION=23 JAVA_VERSION_MIN_RADICAL=0 @@ -17,6 +17,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13 RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3 TARGET_SDK_VERSION=35 TARGET_SDK_VERSION_INRT=29 -VERSION_BUILD=3022 +VERSION_BUILD=3023 VERSION_NAME=6.6.2 Alpha4 VSCODE_EXT_REQUIRED_VERSION=1.0.8