diff --git a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt index 0fa73e39e..b5e27b72a 100644 --- a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt +++ b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt @@ -15,7 +15,7 @@ class FileAssociationActivity : override val binding by viewBinding(ActivityTranslucenceBinding::inflate) - override val viewModel: FileAssociationViewModel by viewModels() + override val viewModel by viewModels() override fun onActivityCreated(savedInstanceState: Bundle?) { binding.rotateLoading.show() diff --git a/app/src/main/java/io/legado/app/utils/viewbindingdelegate/ActivityViewBindings.kt b/app/src/main/java/io/legado/app/utils/viewbindingdelegate/ActivityViewBindings.kt index 5ace190cc..bc52f95ba 100644 --- a/app/src/main/java/io/legado/app/utils/viewbindingdelegate/ActivityViewBindings.kt +++ b/app/src/main/java/io/legado/app/utils/viewbindingdelegate/ActivityViewBindings.kt @@ -6,8 +6,16 @@ import android.view.LayoutInflater import androidx.core.app.ComponentActivity import androidx.viewbinding.ViewBinding -inline fun ComponentActivity.viewBinding(crossinline bindingInflater: (LayoutInflater) -> T) = - lazy(LazyThreadSafetyMode.SYNCHRONIZED) { - val invoke = bindingInflater.invoke(layoutInflater) - invoke +/** + * + */ +inline fun ComponentActivity.viewBinding( + crossinline bindingInflater: (LayoutInflater) -> T, + setContentView: Boolean = false +) = lazy(LazyThreadSafetyMode.SYNCHRONIZED) { + val binding = bindingInflater.invoke(layoutInflater) + if (setContentView) { + setContentView(binding.root) } + binding +}