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