]> git.ktnx.net Git - mobile-ledger.git/commitdiff
animate save transaction button icon change
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 5 Dec 2018 21:14:26 +0000 (21:14 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 5 Dec 2018 21:14:26 +0000 (21:14 +0000)
app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java
app/src/main/res/animator/new_trans_animation.xml [new file with mode: 0644]

index 148eacb1a46f56e4d056534fc538df531280c667..b229c0ff44b0de9a2ae76ca61adb55f528b44f8e 100644 (file)
@@ -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 (file)
index 0000000..408e7e6
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    android:ordering="sequentially">
+    <objectAnimator
+        android:duration="500"
+        android:propertyName="alpha"
+        android:repeatCount="3"
+        android:repeatMode="reverse"
+        android:valueFrom="1f"
+        android:valueTo="0f" />
+</set>
\ No newline at end of file