6.6.2 - Alpha4 - 修复 ExplorerFragment 的 binding 对象未及时回收问题
This commit is contained in:
@@ -1,22 +1,32 @@
|
|||||||
package org.autojs.autojs.ui.fragment
|
package org.autojs.autojs.ui.fragment
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import android.view.View
|
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.properties.ReadOnlyProperty
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
object BindingDelegates {
|
object BindingDelegates {
|
||||||
|
|
||||||
fun <T> Fragment.viewBinding(bindView: (View) -> T) = object : ReadOnlyProperty<Fragment, T> {
|
// @Created by JetBrains AI Assistant on Mar 12, 2025.
|
||||||
|
// @Modified by JetBrains AI Assistant as of Mar 13, 2025.
|
||||||
|
inline fun <reified T : ViewBinding> Fragment.viewBinding(crossinline bindView: (View) -> T) = object : ReadOnlyProperty<Fragment, T> {
|
||||||
|
|
||||||
private var binding: T? = null
|
private var binding: T? = null
|
||||||
|
|
||||||
override fun getValue(thisRef: Fragment, property: KProperty<*>): T {
|
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"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -42,21 +42,22 @@ import org.greenrobot.eventbus.Subscribe
|
|||||||
* Modified by SuperMonster003 as of Mar 20, 2022.
|
* Modified by SuperMonster003 as of Mar 20, 2022.
|
||||||
* Transformed by SuperMonster003 on Mar 31, 2023.
|
* 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 val binding by viewBinding(FragmentExplorerBinding::bind)
|
||||||
|
|
||||||
private var mExplorerView: ExplorerView? = null
|
private var mExplorerView: ExplorerView? = null
|
||||||
private var mFloatingActionMenu: FloatingActionMenu? = null
|
private var mFloatingActionMenu: FloatingActionMenu? = null
|
||||||
private var mIsCurrentPageFiles = false
|
private var mIsCurrentPageFiles = false
|
||||||
|
|
||||||
|
private var mBottomInset: Int = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
EventBus.getDefault().register(this)
|
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
|
return FragmentExplorerBinding.inflate(inflater, container, false).root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#Thu Mar 13 01:24:48 CST 2025
|
#Thu Mar 13 12:06:20 CST 2025
|
||||||
BUILD_TIME=1741800288640
|
BUILD_TIME=1741838780961
|
||||||
COMPILE_SDK_VERSION=35
|
COMPILE_SDK_VERSION=35
|
||||||
JAVA_VERSION=23
|
JAVA_VERSION=23
|
||||||
JAVA_VERSION_MIN_RADICAL=0
|
JAVA_VERSION_MIN_RADICAL=0
|
||||||
@@ -17,6 +17,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
|
|||||||
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
||||||
TARGET_SDK_VERSION=35
|
TARGET_SDK_VERSION=35
|
||||||
TARGET_SDK_VERSION_INRT=29
|
TARGET_SDK_VERSION_INRT=29
|
||||||
VERSION_BUILD=3022
|
VERSION_BUILD=3023
|
||||||
VERSION_NAME=6.6.2 Alpha4
|
VERSION_NAME=6.6.2 Alpha4
|
||||||
VSCODE_EXT_REQUIRED_VERSION=1.0.8
|
VSCODE_EXT_REQUIRED_VERSION=1.0.8
|
||||||
|
|||||||
Reference in New Issue
Block a user