This repository was archived by the owner on Dec 9, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-16
lines changed
DrawableAnimations/app/src/main/java/com/example/android/drawableanimations Expand file tree Collapse file tree 2 files changed +7
-16
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package com.example.android.drawableanimations
18
18
19
- import android.R
20
19
import android.view.View
21
- import androidx.constraintlayout.widget.ConstraintLayout
22
20
import androidx.fragment.app.Fragment
23
21
import androidx.lifecycle.Lifecycle
24
22
import androidx.lifecycle.LifecycleEventObserver
25
23
import androidx.viewbinding.ViewBinding
26
24
27
-
28
25
/* *
29
26
* Retrieves a view binding handle in a Fragment. The field is available only after
30
27
* [Fragment.onViewCreated].
@@ -48,18 +45,12 @@ inline fun <reified BindingT : ViewBinding> Fragment.viewBindings(
48
45
cached = null
49
46
}
50
47
}
51
- // val mConstraintLayout: ConstraintLayout = findViewById(R.id.constraintLayoutParent)
52
- // var layout: View = layoutInflater.inflate(R.layout.activity_list_item, null)
53
- // override val value: BindingT
54
- // get() = cached ?: bind(requireView()).also {
55
- // viewLifecycleOwner.lifecycle.addObserver(observer)
56
- // cached = it
57
- // }
58
- override val value: BindingT
59
- get() = cached ? : bind(requireView()).also {
60
- viewLifecycleOwner.lifecycle.addObserver(observer)
61
- cached = it
62
- }
48
+
49
+ override val value: BindingT
50
+ get() = cached ? : bind(requireView()).also {
51
+ viewLifecycleOwner.lifecycle.addObserver(observer)
52
+ cached = it
53
+ }
63
54
64
55
override fun isInitialized () = cached != null
65
56
}
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import com.example.android.drawableanimations.databinding.AnimatedFragmentBindin
27
27
import com.example.android.drawableanimations.viewBindings
28
28
29
29
class AnimatedFragment : Fragment (R .layout.animated_fragment) {
30
+
30
31
private val binding by viewBindings(AnimatedFragmentBinding ::bind)
31
32
32
33
override fun onDestroyView () {
@@ -57,4 +58,3 @@ class AnimatedFragment : Fragment(R.layout.animated_fragment) {
57
58
binding.stop.setOnClickListener { icon.stop() }
58
59
}
59
60
}
60
-
You can’t perform that action at this time.
0 commit comments