File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
app/src/main/java/guide/graphql/toc/ui Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -17,17 +17,21 @@ import guide.graphql.toc.data.Status
17
17
import guide.graphql.toc.databinding.ChaptersFragmentBinding
18
18
19
19
class ChaptersFragment : Fragment () {
20
+ private var _binding : ChaptersFragmentBinding ? = null
21
+ // This property is only valid between onCreateView and
22
+ // onDestroyView.
23
+ private val binding get() = _binding !!
24
+
20
25
21
26
private val viewModel: ChaptersViewModel by viewModels()
22
27
23
- private lateinit var binding: ChaptersFragmentBinding
24
28
25
29
override fun onCreateView (
26
30
inflater : LayoutInflater ,
27
31
container : ViewGroup ? ,
28
32
savedInstanceState : Bundle ?
29
33
): View ? {
30
- binding = ChaptersFragmentBinding .inflate(inflater)
34
+ _binding = ChaptersFragmentBinding .inflate(inflater, container, false )
31
35
return binding.root
32
36
}
33
37
@@ -86,4 +90,9 @@ class ChaptersFragment : Fragment() {
86
90
}
87
91
})
88
92
}
93
+
94
+ override fun onDestroyView () {
95
+ super .onDestroyView()
96
+ _binding = null
97
+ }
89
98
}
Original file line number Diff line number Diff line change @@ -18,15 +18,20 @@ class SectionsFragment : Fragment() {
18
18
19
19
private val viewModel: SectionsViewModel by viewModels()
20
20
21
- private lateinit var binding: SectionsFragmentBinding
21
+ private var _binding : SectionsFragmentBinding ? = null
22
+ // This property is only valid between onCreateView and
23
+ // onDestroyView.
24
+ private val binding get() = _binding !!
25
+
26
+
22
27
private val args: SectionsFragmentArgs by navArgs()
23
28
24
29
override fun onCreateView (
25
30
inflater : LayoutInflater ,
26
31
container : ViewGroup ? ,
27
32
savedInstanceState : Bundle ?
28
33
): View ? {
29
- binding = SectionsFragmentBinding .inflate(inflater)
34
+ _binding = SectionsFragmentBinding .inflate(inflater, container, false )
30
35
return binding.root
31
36
}
32
37
@@ -78,6 +83,11 @@ class SectionsFragment : Fragment() {
78
83
viewModel.chapterId = args.chapterId
79
84
}
80
85
86
+ override fun onDestroyView () {
87
+ super .onDestroyView()
88
+ _binding = null
89
+ }
90
+
81
91
private fun showErrorMessage (error : String ) {
82
92
binding.spinner.visibility = View .GONE
83
93
binding.error.text = error
You can’t perform that action at this time.
0 commit comments