From 2c9601c763805df628328312468278404f448663 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 19 Apr 2019 18:45:26 +0300 Subject: [PATCH] more animations when collapsing profile list and when starting/editting list edit --- .../ui/activity/MainActivity.java | 27 ++++++++++++++++--- .../profiles/ProfilesRecyclerViewAdapter.java | 19 ++++++++++++- app/src/main/res/anim/fade_in.xml | 3 +-- app/src/main/res/anim/fade_out.xml | 24 +++++++++++++++++ 4 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 app/src/main/res/anim/fade_out.xml diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index 1eb8f458..aad6b506 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -271,15 +271,25 @@ public class MainActivity extends ProfileThemedActivity { profileListHeadArrow.clearAnimation(); profileListHeadArrow.setVisibility(View.GONE); profileListHeadMore.setVisibility(View.GONE); + profileListHeadMore + .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out)); profileListHeadCancel.setVisibility(View.VISIBLE); + profileListHeadCancel + .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in)); } else { profileListHeadArrow.setRotation(180f); profileListHeadArrow.setVisibility(View.VISIBLE); profileListHeadCancel.setVisibility(View.GONE); + profileListHeadCancel + .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out)); profileListHeadMore.setVisibility(View.GONE); - profileListHeadMore - .setVisibility(profileListExpanded ? View.VISIBLE : View.GONE); + if (profileListExpanded) { + profileListHeadMore.setVisibility(View.VISIBLE); + profileListHeadMore + .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in)); + } + else profileListHeadMore.setVisibility(View.GONE); } }; mProfileListAdapter.addEditingProfilesObserver(editingProfilesObserver); @@ -699,7 +709,18 @@ public class MainActivity extends ProfileThemedActivity { profileListHeadArrow.setRotation(0f); profileListHeadArrow .startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180_back)); - profileListHeadMore.setVisibility(View.GONE); + 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); } public void onAccountSummaryRowViewClicked(View view) { ViewGroup row; diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java index d1ee5fd7..8ee0dd96 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java @@ -23,6 +23,8 @@ import android.graphics.drawable.ColorDrawable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -68,7 +70,8 @@ public class ProfilesRecyclerViewAdapter @NonNull RecyclerView.ViewHolder target) { Data.profiles.blockNotifications(); try { - Collections.swap(Data.profiles, viewHolder.getAdapterPosition(), target.getAdapterPosition()); + Collections.swap(Data.profiles, viewHolder.getAdapterPosition(), + target.getAdapterPosition()); MobileLedgerProfile.storeProfilesOrder(); notifyItemMoved(viewHolder.getAdapterPosition(), target.getAdapterPosition()); } @@ -193,12 +196,26 @@ public class ProfilesRecyclerViewAdapter holder.itemView .setBackground(sameProfile ? new ColorDrawable(Colors.tableRowDarkBG) : null); if (editingProfiles.get()) { + boolean wasHidden = holder.mEditButton.getVisibility() == View.GONE; holder.mRearrangeHandle.setVisibility(View.VISIBLE); holder.mEditButton.setVisibility(View.VISIBLE); + if (wasHidden) { + Animation a = AnimationUtils + .loadAnimation(holder.mRearrangeHandle.getContext(), R.anim.fade_in); + holder.mRearrangeHandle.startAnimation(a); + holder.mEditButton.startAnimation(a); + } } else { + boolean wasShown = holder.mEditButton.getVisibility() == View.VISIBLE; holder.mRearrangeHandle.setVisibility(View.INVISIBLE); holder.mEditButton.setVisibility(View.GONE); + if (wasShown) { + Animation a = AnimationUtils + .loadAnimation(holder.mRearrangeHandle.getContext(), R.anim.fade_out); + holder.mRearrangeHandle.startAnimation(a); + holder.mEditButton.startAnimation(a); + } } } @Override diff --git a/app/src/main/res/anim/fade_in.xml b/app/src/main/res/anim/fade_in.xml index 9e2c56ce..047f26c1 100644 --- a/app/src/main/res/anim/fade_in.xml +++ b/app/src/main/res/anim/fade_in.xml @@ -16,8 +16,7 @@ --> + android:duration="@android:integer/config_mediumAnimTime"> diff --git a/app/src/main/res/anim/fade_out.xml b/app/src/main/res/anim/fade_out.xml new file mode 100644 index 00000000..32b42a8b --- /dev/null +++ b/app/src/main/res/anim/fade_out.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file -- 2.39.5