-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* -Added animation to "Hints Icon" * -Some nit changes
- Loading branch information
1 parent
ddcf9e9
commit 41eb10b
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
app/src/main/java/org/oppia/app/databinding/ViewBindingAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.oppia.app.databinding | ||
|
||
import android.animation.AnimatorSet | ||
import android.animation.ValueAnimator | ||
import android.view.View | ||
import androidx.core.animation.doOnEnd | ||
import androidx.databinding.BindingAdapter | ||
|
||
private val appearAnimator: ValueAnimator = ValueAnimator.ofFloat(0f, 1f) | ||
private val disappearAnimator: ValueAnimator = ValueAnimator.ofFloat(1f, 2f) | ||
private val animatorSet = AnimatorSet() | ||
|
||
@BindingAdapter("app:flashingAnimation") | ||
fun setFlashingAnimation(view: View, isFlashing: Boolean) { | ||
appearAnimator.addUpdateListener { | ||
view.scaleX = it.animatedValue as Float | ||
view.scaleY = it.animatedValue as Float | ||
view.alpha = it.animatedValue as Float | ||
} | ||
appearAnimator.duration = 1500 | ||
|
||
disappearAnimator.addUpdateListener { | ||
view.scaleX = it.animatedValue as Float | ||
view.scaleY = it.animatedValue as Float | ||
view.alpha = 2f - it.animatedValue as Float | ||
} | ||
disappearAnimator.duration = 500 | ||
|
||
if (isFlashing) { | ||
animatorSet.playSequentially(appearAnimator, disappearAnimator) | ||
animatorSet.start() | ||
animatorSet.doOnEnd { | ||
animatorSet.start() | ||
} | ||
} else { | ||
animatorSet.cancel() | ||
view.scaleX = 0f | ||
view.scaleY = 0f | ||
view.alpha = 0f | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="oval"> | ||
<stroke | ||
android:width="0.5dp" | ||
android:color="@color/radarColor" /> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters