pull/1072/head
gedoor 3 years ago
parent 12f2e2a9a3
commit 33f022aefb
  1. 2
      app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
  2. 16
      app/src/main/java/io/legado/app/utils/viewbindingdelegate/ActivityViewBindings.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<FileAssociationViewModel>()
override fun onActivityCreated(savedInstanceState: Bundle?) {
binding.rotateLoading.show()

@ -6,8 +6,16 @@ import android.view.LayoutInflater
import androidx.core.app.ComponentActivity
import androidx.viewbinding.ViewBinding
inline fun <T : ViewBinding> ComponentActivity.viewBinding(crossinline bindingInflater: (LayoutInflater) -> T) =
lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
val invoke = bindingInflater.invoke(layoutInflater)
invoke
/**
*
*/
inline fun <T : ViewBinding> ComponentActivity.viewBinding(
crossinline bindingInflater: (LayoutInflater) -> T,
setContentView: Boolean = false
) = lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
val binding = bindingInflater.invoke(layoutInflater)
if (setContentView) {
setContentView(binding.root)
}
binding
}

Loading…
Cancel
Save