Only play animation for crop if crop has changed

Not when switching reading mode
This commit is contained in:
Jays2Kings 2021-04-15 03:30:26 -04:00
parent 73281871f9
commit 5a4632a99c

View File

@ -189,6 +189,8 @@ class ReaderActivity :
var indexPageToShift: Int? = null var indexPageToShift: Int? = null
var indexChapterToShift: Long? = null var indexChapterToShift: Long? = null
var lastCropRes = 0
companion object { companion object {
@Suppress("unused") @Suppress("unused")
const val LEFT_TO_RIGHT = 1 const val LEFT_TO_RIGHT = 1
@ -410,15 +412,17 @@ class ReaderActivity :
} }
with(binding.chaptersSheet.cropBordersSheetButton) { with(binding.chaptersSheet.cropBordersSheetButton) {
setImageResource( val drawableRes = if (enabled) {
if (enabled) {
R.drawable.free_to_crop R.drawable.free_to_crop
} else { } else {
R.drawable.crop_to_free R.drawable.crop_to_free
} }
) if (lastCropRes != drawableRes) {
setImageResource(drawableRes)
val animDrawable = drawable as AnimatedVectorDrawable val animDrawable = drawable as AnimatedVectorDrawable
animDrawable.start() animDrawable.start()
lastCropRes = drawableRes
}
compatToolTipText = compatToolTipText =
getString( getString(
if (enabled) R.string.remove_crop if (enabled) R.string.remove_crop