]> git.ktnx.net Git - mobile-ledger.git/commitdiff
disable profile list animations while the drawer is closing/closed
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 5 May 2019 13:28:29 +0000 (16:28 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 5 May 2019 13:28:43 +0000 (16:28 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java

index 4d1f07dbd534222d36f194940f5c0b92a5c28fa4..5a8e198f778400ef00ef9aac6cbe1fd8336056dd 100644 (file)
@@ -290,7 +290,22 @@ public class MainActivity extends ProfileThemedActivity {
         profileListHeadCancel.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
         profileListHeadMoreAndCancel
                 .setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
-
+        if (drawerListener == null) {
+            drawerListener = new DrawerLayout.SimpleDrawerListener() {
+                @Override
+                public void onDrawerClosed(View drawerView) {
+                    super.onDrawerClosed(drawerView);
+                    mProfileListAdapter.setAnimationsEnabled(false);
+                    mProfileListAdapter.editingProfiles.setValue(false);
+                }
+                @Override
+                public void onDrawerOpened(View drawerView) {
+                    super.onDrawerOpened(drawerView);
+                    mProfileListAdapter.setAnimationsEnabled(true);
+                }
+            };
+            drawer.addDrawerListener(drawerListener);
+        }
         setupProfile();
     }
     private void scheduleDataRetrievalIfStale(Date lastUpdate) {
index 80e0dcdcbcedfd23132012d333701c4eb0d22be7..50fb32cf7d45acbecfa9e441f82d5c6308599451 100644 (file)
@@ -56,6 +56,7 @@ public class ProfilesRecyclerViewAdapter
     public MutableLiveData<Boolean> editingProfiles = new MutableLiveData<>(false);
     private RecyclerView recyclerView;
     private ItemTouchHelper rearrangeHelper;
+    private boolean animationsEnabled = true;
     public ProfilesRecyclerViewAdapter() {
         debug("flow", "ProfilesRecyclerViewAdapter.new()");
 
@@ -83,6 +84,9 @@ public class ProfilesRecyclerViewAdapter
         };
         rearrangeHelper = new ItemTouchHelper(cb);
     }
+    public void setAnimationsEnabled(boolean animationsEnabled) {
+        this.animationsEnabled = animationsEnabled;
+    }
     @Override
     public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
         rearrangeHelper.attachToRecyclerView(null);
@@ -98,13 +102,11 @@ public class ProfilesRecyclerViewAdapter
     public void startEditingProfiles() {
         if (editingProfiles.getValue()) return;
         this.editingProfiles.setValue(true);
-        notifyDataSetChanged();
         rearrangeHelper.attachToRecyclerView(recyclerView);
     }
     public void stopEditingProfiles() {
         if (!editingProfiles.getValue()) return;
         this.editingProfiles.setValue(false);
-        notifyDataSetChanged();
         rearrangeHelper.attachToRecyclerView(null);
     }
     public void flipEditingProfiles() {
@@ -187,7 +189,7 @@ public class ProfilesRecyclerViewAdapter
             boolean wasHidden = holder.mEditButton.getVisibility() == View.GONE;
             holder.mRearrangeHandle.setVisibility(View.VISIBLE);
             holder.mEditButton.setVisibility(View.VISIBLE);
-            if (wasHidden) {
+            if (wasHidden && animationsEnabled) {
                 Animation a = AnimationUtils
                         .loadAnimation(holder.mRearrangeHandle.getContext(), R.anim.fade_in);
                 holder.mRearrangeHandle.startAnimation(a);
@@ -198,7 +200,7 @@ public class ProfilesRecyclerViewAdapter
             boolean wasShown = holder.mEditButton.getVisibility() == View.VISIBLE;
             holder.mRearrangeHandle.setVisibility(View.INVISIBLE);
             holder.mEditButton.setVisibility(View.GONE);
-            if (wasShown) {
+            if (wasShown && animationsEnabled) {
                 Animation a = AnimationUtils
                         .loadAnimation(holder.mRearrangeHandle.getContext(), R.anim.fade_out);
                 holder.mRearrangeHandle.startAnimation(a);