mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-14 21:18:56 +01:00
More core-ktx usages
This commit is contained in:
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.core.view.forEach
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
|
||||
/**
|
||||
@@ -14,13 +15,11 @@ class MaxHeightViewPager(context: Context, attrs: AttributeSet?) : ViewPager(con
|
||||
var measuredHeight = heightMeasureSpec
|
||||
|
||||
var height = 0
|
||||
for (i in 0 until childCount) {
|
||||
val child = getChildAt(i)
|
||||
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED))
|
||||
val h = child.measuredHeight
|
||||
forEach {
|
||||
it.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED))
|
||||
val h = it.measuredHeight
|
||||
if (h > height) height = h
|
||||
}
|
||||
|
||||
if (height != 0) {
|
||||
measuredHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package eu.kanade.tachiyomi.widget
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewAnimationUtils
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
|
||||
@@ -32,12 +32,9 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
anim.duration = 500
|
||||
|
||||
// make the view invisible when the animation is done
|
||||
anim.addListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
super.onAnimationEnd(animation)
|
||||
this@RevealAnimationView.isInvisible = true
|
||||
}
|
||||
})
|
||||
anim.doOnEnd {
|
||||
this@RevealAnimationView.isInvisible = true
|
||||
}
|
||||
|
||||
anim.start()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user