X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Fprofiles%2FProfilesRecyclerViewAdapter.java;h=a4221cddc460a3d4deabc91e8bfe70806f1661de;hp=4531e9fad92681096259a3e8e8c4b53f6d07de19;hb=23b8360d4f884bbdb20cc2de1825486ef42f37d6;hpb=aef08f9dbd6b28d320dec8b1f1a51dc1e2c344d6 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 4531e9fa..a4221cdd 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; @@ -35,6 +37,7 @@ import net.ktnx.mobileledger.utils.Colors; import net.ktnx.mobileledger.utils.ObservableValue; import java.util.Collections; +import java.util.Locale; import java.util.Observer; import androidx.annotation.NonNull; @@ -68,7 +71,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()); } @@ -127,6 +131,7 @@ public class ProfilesRecyclerViewAdapter context.startActivity(intent); } private void onProfileRowClicked(View v) { + if (editingProfiles.get()) return; MobileLedgerProfile profile = (MobileLedgerProfile) v.getTag(); if (profile == null) throw new IllegalStateException("Profile row without associated profile"); @@ -153,11 +158,6 @@ public class ProfilesRecyclerViewAdapter flipEditingProfiles(); return true; }); - Data.profile.addObserver((o, arg) -> { - MobileLedgerProfile myProfile = (MobileLedgerProfile) holder.itemView.getTag(); - final MobileLedgerProfile currentProfile = Data.profile.get(); - final boolean sameProfile = currentProfile.equals(myProfile); - }); View.OnTouchListener dragStarter = (v, event) -> { if (rearrangeHelper != null && editingProfiles.get()) { @@ -174,7 +174,7 @@ public class ProfilesRecyclerViewAdapter public void onBindViewHolder(@NonNull final ProfileListViewHolder holder, int position) { final MobileLedgerProfile profile = Data.profiles.get(position); final MobileLedgerProfile currentProfile = Data.profile.get(); - debug("profiles", String.format("pos %d: %s, current: %s", position, profile.getUuid(), + debug("profiles", String.format(Locale.ENGLISH,"pos %d: %s, current: %s", position, profile.getUuid(), (currentProfile == null) ? "" : currentProfile.getUuid())); holder.itemView.setTag(profile); @@ -192,12 +192,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