Add more improved fast scroller
This commit is contained in:
@@ -15,8 +15,10 @@ import android.view.ViewPropertyAnimator
|
||||
import android.view.Window
|
||||
import android.view.animation.Animation
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.constraintlayout.motion.widget.MotionScene
|
||||
import androidx.core.app.ActivityOptionsCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.children
|
||||
import androidx.core.view.descendants
|
||||
import androidx.lifecycle.Lifecycle
|
||||
@@ -122,6 +124,8 @@ fun Window.setNavigationBarTransparentCompat(context: Context, elevation: Float
|
||||
val Context.animatorDurationScale: Float
|
||||
get() = Settings.Global.getFloat(this.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f)
|
||||
|
||||
internal fun Context.getCompatDrawable(@DrawableRes drawableId: Int) = ContextCompat.getDrawable(this, drawableId)
|
||||
|
||||
fun ViewPropertyAnimator.applySystemAnimatorScale(context: Context): ViewPropertyAnimator = apply {
|
||||
this.duration = (this.duration * context.animatorDurationScale).toLong()
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.koitharu.kotatsu.utils.progress.ImageRequestIndicatorListener
|
||||
|
||||
fun ImageView.newImageRequest(url: String?) = ImageRequest.Builder(context)
|
||||
.data(url)
|
||||
.crossfade(true)
|
||||
.crossfade((300 * context.animatorDurationScale).toInt())
|
||||
.target(this)
|
||||
|
||||
fun ImageRequest.Builder.enqueueWith(loader: ImageLoader) = loader.enqueue(build())
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.koitharu.kotatsu.utils.ext
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
|
||||
internal fun Drawable.setCompatTint(@ColorInt color: Int) = DrawableCompat.setTint(this, color)
|
||||
|
||||
internal fun Drawable.wrap(): Drawable = DrawableCompat.wrap(this)
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.koitharu.kotatsu.utils.ext
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
|
||||
internal val RecyclerView.LayoutManager?.firstVisibleItemPosition
|
||||
get() = when (this) {
|
||||
is LinearLayoutManager -> findFirstVisibleItemPosition()
|
||||
is StaggeredGridLayoutManager -> findFirstVisibleItemPositions(null)[0]
|
||||
else -> 0
|
||||
}
|
||||
|
||||
internal val RecyclerView.LayoutManager?.isLayoutReversed
|
||||
get() = when (this) {
|
||||
is LinearLayoutManager -> reverseLayout
|
||||
is StaggeredGridLayoutManager -> reverseLayout
|
||||
else -> false
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import android.graphics.Rect
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.children
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@@ -144,4 +145,6 @@ fun RecyclerView.invalidateNestedItemDecorations() {
|
||||
findViewsByType(RecyclerView::class.java).forEach {
|
||||
it.invalidateItemDecorations()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal val View.compatPaddingStart get() = ViewCompat.getPaddingStart(this)
|
||||
Reference in New Issue
Block a user