@@ -11,18 +11,29 @@ import androidx.fragment.app.Fragment
1111import com.crocodic.core.helper.ImagePreviewHelper
1212import com.crocodic.core.helper.util.ClickPrevention
1313
14- abstract class CoreFragment <VB : ViewDataBinding >(@LayoutRes private val layoutRes : Int ): Fragment(), ClickPrevention {
14+ abstract class CoreFragment <VB : ViewDataBinding >(@LayoutRes private val layoutRes : Int ) :
15+ Fragment (), ClickPrevention {
1516
16- protected lateinit var binding: VB
17+ private var _binding : VB ? = null
18+ protected val binding get() = _binding !!
1719
1820 open var title: String = " "
1921 open var hasLoadedOnce = false
2022
2123 val imagePreview by lazy { context?.let { ImagePreviewHelper (it) } }
2224
23- override fun onCreateView (inflater : LayoutInflater , container : ViewGroup ? , savedInstanceState : Bundle ? ): View ? {
24- binding = DataBindingUtil .inflate(inflater, layoutRes, container, false )
25+ override fun onCreateView (
26+ inflater : LayoutInflater ,
27+ container : ViewGroup ? ,
28+ savedInstanceState : Bundle ?
29+ ): View ? {
30+ _binding = DataBindingUtil .inflate(inflater, layoutRes, container, false )
2531 binding.lifecycleOwner = this
2632 return binding.root
2733 }
34+
35+ override fun onDestroyView () {
36+ super .onDestroyView()
37+ _binding = null
38+ }
2839}
0 commit comments