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 1616
1717package com.example.android.drawableanimations
1818
19- import android.R
2019import android.view.View
21- import androidx.constraintlayout.widget.ConstraintLayout
2220import androidx.fragment.app.Fragment
2321import androidx.lifecycle.Lifecycle
2422import androidx.lifecycle.LifecycleEventObserver
2523import androidx.viewbinding.ViewBinding
2624
27-
2825/* *
2926 * Retrieves a view binding handle in a Fragment. The field is available only after
3027 * [Fragment.onViewCreated].
@@ -48,18 +45,12 @@ inline fun <reified BindingT : ViewBinding> Fragment.viewBindings(
4845 cached = null
4946 }
5047 }
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+ }
6354
6455 override fun isInitialized () = cached != null
6556}
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import com.example.android.drawableanimations.databinding.AnimatedFragmentBindin
2727import com.example.android.drawableanimations.viewBindings
2828
2929class AnimatedFragment : Fragment (R .layout.animated_fragment) {
30+
3031 private val binding by viewBindings(AnimatedFragmentBinding ::bind)
3132
3233 override fun onDestroyView () {
@@ -57,4 +58,3 @@ class AnimatedFragment : Fragment(R.layout.animated_fragment) {
5758 binding.stop.setOnClickListener { icon.stop() }
5859 }
5960}
60-
You can’t perform that action at this time.
0 commit comments