From 89020c287f5ac0e9670cd1183f17c527ceb263de Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Wed, 5 Dec 2018 21:14:26 +0000 Subject: [PATCH] animate save transaction button icon change --- .../mobileledger/NewTransactionActivity.java | 26 ++++++++++++++----- .../main/res/animator/new_trans_animation.xml | 11 ++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/animator/new_trans_animation.xml diff --git a/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java index 148eacb1..b229c0ff 100644 --- a/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java @@ -1,5 +1,7 @@ package net.ktnx.mobileledger; +import android.animation.AnimatorInflater; +import android.animation.AnimatorSet; import android.annotation.TargetApi; import android.database.Cursor; import android.database.MatrixCursor; @@ -225,16 +227,26 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal public void done() { fab.setEnabled(true); - fab.setImageResource(R.drawable.ic_thick_check_white); - progress.setVisibility(View.INVISIBLE); - reset_form(); - final Handler handler = new Handler(); - handler.postDelayed(new Runnable() { + AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.new_trans_animation); + set.setTarget(fab); + set.start(); + final Handler at_fade_out = new Handler(); + at_fade_out.postDelayed(new Runnable() { @Override public void run() { - fab.setImageResource(R.drawable.ic_save_white_24dp); + fab.setImageResource(R.drawable.ic_thick_check_white); + + final Handler at_fade_in = new Handler(); + at_fade_in.postDelayed(new Runnable() { + @Override + public void run() { + fab.setImageResource(R.drawable.ic_save_white_24dp); + } + }, 1000); } - }, 1500); + }, 500); + progress.setVisibility(View.INVISIBLE); + reset_form(); } private void reset_form() { diff --git a/app/src/main/res/animator/new_trans_animation.xml b/app/src/main/res/animator/new_trans_animation.xml new file mode 100644 index 00000000..408e7e68 --- /dev/null +++ b/app/src/main/res/animator/new_trans_animation.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file -- 2.39.5