From 83325300aec19050bfc09b5143f4b1bc4712bf55 Mon Sep 17 00:00:00 2001 From: ottoptj Date: Tue, 24 Sep 2024 23:52:33 +0300 Subject: [PATCH] Disabled gestures during the animation of something disappearing. Prevents a minor blank screen bug. --- .../java/eu/ottop/yamlauncher/MainActivity.kt | 3 +++ .../eu/ottop/yamlauncher/utils/Animations.kt | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index f91a19e..c991d57 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -1015,6 +1015,9 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh velocityX: Float, velocityY: Float ): Boolean { + if (animations.isInAnim) { + return false + } if (e1 != null) { val deltaY = e2.y - e1.y val deltaX = e2.x - e1.x diff --git a/app/src/main/java/eu/ottop/yamlauncher/utils/Animations.kt b/app/src/main/java/eu/ottop/yamlauncher/utils/Animations.kt index 75c16ec..a0b3c2d 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/utils/Animations.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/utils/Animations.kt @@ -13,6 +13,7 @@ import eu.ottop.yamlauncher.settings.SharedPreferenceManager class Animations (context: Context) { private val sharedPreferenceManager = SharedPreferenceManager(context) + var isInAnim = false // fadeViewIn and fadeViewOut are for smaller item transitions, such as the action menu @@ -93,7 +94,7 @@ class Animations (context: Context) { private fun View.slideOutToBottom(duration: Long) { if (visibility == View.VISIBLE) { - + isInAnim = true animate() .translationY(height.toFloat() / 5) .scaleY(1.2f) @@ -101,7 +102,14 @@ class Animations (context: Context) { .setDuration(duration/2) .setListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator) { + super.onAnimationEnd(animation) visibility = View.INVISIBLE + isInAnim = false + } + override fun onAnimationCancel(animation: Animator) { + super.onAnimationCancel(animation) + visibility = View.INVISIBLE + isInAnim = false } }) } @@ -118,12 +126,12 @@ class Animations (context: Context) { .translationY(0f) .setDuration(duration) .setListener(null) - } } private fun View.fadeOut() { if (visibility == View.VISIBLE) { + isInAnim = true val duration = sharedPreferenceManager.getAnimationSpeed() animate() @@ -132,7 +140,14 @@ class Animations (context: Context) { .setDuration(duration/2) .setListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator) { + super.onAnimationEnd(animation) visibility = View.INVISIBLE + isInAnim = false + } + override fun onAnimationCancel(animation: Animator) { + super.onAnimationCancel(animation) + visibility = View.INVISIBLE + isInAnim = false } })