mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-22 19:25:11 +00:00
create BindingBottomSheetDialogFragment
This commit is contained in:
parent
52bb26b3e0
commit
a1d4cdbbe5
1 changed files with 37 additions and 0 deletions
|
@ -0,0 +1,37 @@
|
|||
package com.vanced.manager.ui.core
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
|
||||
abstract class BindingBottomSheetDialogFragment<VB : ViewBinding> : BottomSheetDialogFragment() {
|
||||
|
||||
private var _binding: VB? = null
|
||||
protected val binding: VB get() = requireNotNull(_binding)
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = binding(inflater, container, savedInstanceState)
|
||||
otherSetups()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
protected abstract fun binding(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): VB
|
||||
|
||||
protected open fun otherSetups() = Unit
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue