diff options
author | Dan Nizri <dsn5ft@virginia.edu> | 2016-06-20 10:35:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-20 10:35:10 -0400 |
commit | c74bd9186f3f8aa064a5b156da8d9554b9f13f15 (patch) | |
tree | 41f044378838044f2be5c8f0b4a598bbada6b634 | |
parent | b495257cf854ae511460132667753bee7f266753 (diff) | |
parent | 62f49549ed5959534cedcee51c8661929dacf91e (diff) | |
download | android-kotlin-demo-c74bd9186f3f8aa064a5b156da8d9554b9f13f15.tar.gz |
Merge pull request #16 from yodle/circular-reveal-animation-fix
surround ViewAnimationUtils.createCircularReveal with try catch
-rw-r--r-- | app/src/main/kotlin/com/yodle/android/kotlindemo/extension/ViewExtensions.kt | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/app/src/main/kotlin/com/yodle/android/kotlindemo/extension/ViewExtensions.kt b/app/src/main/kotlin/com/yodle/android/kotlindemo/extension/ViewExtensions.kt index 72f079e..071351c 100644 --- a/app/src/main/kotlin/com/yodle/android/kotlindemo/extension/ViewExtensions.kt +++ b/app/src/main/kotlin/com/yodle/android/kotlindemo/extension/ViewExtensions.kt @@ -7,6 +7,7 @@ import android.view.View import android.view.ViewAnimationUtils import android.webkit.WebChromeClient import android.webkit.WebView +import timber.log.Timber fun View.showIf(show: Boolean) { if (show) { @@ -44,14 +45,18 @@ fun View.circularReveal(backgroundColor: Int) { val cy = this.height / 2 val finalRadius = Math.hypot(cx.toDouble(), cy.toDouble()).toFloat() - val animator = ViewAnimationUtils.createCircularReveal(this, cx, cy, 0f, finalRadius) - animator.startDelay = 50 - animator.addListener(object : AnimatorListenerAdapter() { - override fun onAnimationStart(animation: Animator?) { - showAndSetBackgroundColorFunction.invoke() - } - }) - animator.start() + try { + val animator = ViewAnimationUtils.createCircularReveal(this, cx, cy, 0f, finalRadius) + animator.startDelay = 50 + animator.addListener(object : AnimatorListenerAdapter() { + override fun onAnimationStart(animation: Animator?) { + showAndSetBackgroundColorFunction.invoke() + } + }) + animator.start() + } catch(e: Exception) { + Timber.e(e, "Unable to perform circular reveal") + } } } else { showAndSetBackgroundColorFunction.invoke() |