<lambda>null1package com.airbnb.lottie.samples.views 2 3 import android.content.Context 4 import android.util.AttributeSet 5 import android.view.ViewGroup 6 import android.widget.FrameLayout 7 import androidx.core.view.children 8 import com.airbnb.lottie.FontAssetDelegate 9 import com.airbnb.lottie.ImageAssetDelegate 10 import com.airbnb.lottie.LottieAnimationView 11 import com.airbnb.lottie.LottieComposition 12 import com.airbnb.lottie.samples.R 13 import com.airbnb.lottie.samples.inflate 14 15 class FilmStripView @JvmOverloads constructor( 16 context: Context, 17 attrs: AttributeSet? = null, 18 defStyleAttr: Int = 0 19 ) : FrameLayout(context, attrs, defStyleAttr) { 20 21 private val animationViews by lazy { 22 findViewById<ViewGroup>(R.id.grid_layout).children.filterIsInstance(LottieAnimationView::class.java) 23 } 24 25 init { 26 inflate(R.layout.film_strip_view) 27 } 28 29 fun setComposition(composition: LottieComposition) { 30 animationViews.forEachIndexed { i, view -> 31 view.setComposition(composition) 32 view.progress = i / 24f 33 } 34 } 35 36 fun setImageAssetDelegate(delegate: ImageAssetDelegate) { 37 animationViews.forEach { it.setImageAssetDelegate(delegate) } 38 } 39 40 fun setFontAssetDelegate(delegate: FontAssetDelegate) { 41 animationViews.forEach { it.setFontAssetDelegate(delegate) } 42 } 43 44 fun setApplyingOpacityToLayersEnabled(isApplyingOpacityToLayersEnabled: Boolean) { 45 animationViews.forEach { it.setApplyingOpacityToLayersEnabled(isApplyingOpacityToLayersEnabled) } 46 } 47 } 48