]> git.ktnx.net Git - mobile-ledger.git/commitdiff
collapseProfileList(): short-cut animations if the list was already collapsed
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 19 Apr 2019 16:39:36 +0000 (19:39 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 19 Apr 2019 20:56:43 +0000 (23:56 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java

index 24784ffd4ec39956b9f961b1e2ddd32bbb7fb3d4..54dd0c21c29576308c176d7bc845258d095ddbb4 100644 (file)
@@ -685,41 +685,51 @@ public class MainActivity extends ProfileThemedActivity {
                        Data.profiles.size()));
     }
     private void collapseProfileList() {
+        boolean wasExpanded = profileListExpanded;
         profileListExpanded = false;
 
-        final Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_up);
-        animation.setAnimationListener(new Animation.AnimationListener() {
-            @Override
-            public void onAnimationStart(Animation animation) {
+        if (wasExpanded) {
+            final Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_up);
+            animation.setAnimationListener(new Animation.AnimationListener() {
+                @Override
+                public void onAnimationStart(Animation animation) {
 
-            }
-            @Override
-            public void onAnimationEnd(Animation animation) {
-                profileListContainer.setVisibility(View.GONE);
-            }
-            @Override
-            public void onAnimationRepeat(Animation animation) {
+                }
+                @Override
+                public void onAnimationEnd(Animation animation) {
+                    profileListContainer.setVisibility(View.GONE);
+                }
+                @Override
+                public void onAnimationRepeat(Animation animation) {
 
-            }
-        });
-        mProfileListAdapter.stopEditingProfiles();
-
-        profileListContainer.startAnimation(animation);
-        profileListHeadArrow.setRotation(0f);
-        profileListHeadArrow
-                .startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180_back));
-        final Animation moreAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
-        moreAnimation.setAnimationListener(new Animation.AnimationListener() {
-            @Override
-            public void onAnimationStart(Animation animation) {}
-            @Override
-            public void onAnimationEnd(Animation animation) {
-                profileListHeadMore.setVisibility(View.GONE);
-            }
-            @Override
-            public void onAnimationRepeat(Animation animation) {}
-        });
-        profileListHeadMore.startAnimation(moreAnimation);
+                }
+            });
+            mProfileListAdapter.stopEditingProfiles();
+
+            profileListContainer.startAnimation(animation);
+            profileListHeadArrow.setRotation(0f);
+            profileListHeadArrow
+                    .startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180_back));
+            final Animation moreAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
+            moreAnimation.setAnimationListener(new Animation.AnimationListener() {
+                @Override
+                public void onAnimationStart(Animation animation) {
+                }
+                @Override
+                public void onAnimationEnd(Animation animation) {
+                    profileListHeadMore.setVisibility(View.GONE);
+                }
+                @Override
+                public void onAnimationRepeat(Animation animation) {
+                }
+            });
+            profileListHeadMore.startAnimation(moreAnimation);
+        }
+        else {
+            profileListContainer.setVisibility(View.GONE);
+            profileListHeadArrow.setRotation(0f);
+            profileListHeadMore.setVisibility(View.GONE);
+        }
     }
     public void onAccountSummaryRowViewClicked(View view) {
         ViewGroup row;