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=d1ee5fd723f60c8c269fff13b5be8bede2f54f13;hp=ddefc65c3a66cc64848b651bd208d60a1ba09d99;hb=a02949cb1f740a4ed13355b5c58e8823fdd06439;hpb=bd5da50ef980c0c9657ec1e9c3e681ab5092f438 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 ddefc65c..d1ee5fd7 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 @@ -38,6 +38,7 @@ import java.util.Collections; import java.util.Observer; import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; @@ -125,6 +126,14 @@ 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"); + debug("profiles", "Setting profile to " + profile.getName()); + Data.setCurrentProfile(profile); + } @NonNull @Override public ProfileListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { @@ -132,13 +141,14 @@ public class ProfilesRecyclerViewAdapter .inflate(R.layout.profile_list_content, parent, false); ProfileListViewHolder holder = new ProfileListViewHolder(view); + holder.mRow.setOnClickListener(this::onProfileRowClicked); holder.mTitle.setOnClickListener(v -> { View row = (View) v.getParent(); - MobileLedgerProfile profile = (MobileLedgerProfile) row.getTag(); - if (profile == null) - throw new IllegalStateException("Profile row without associated profile"); - debug("profiles", "Setting profile to " + profile.getName()); - Data.setCurrentProfile(profile); + onProfileRowClicked(row); + }); + holder.mColorTag.setOnClickListener(v -> { + View row = (View) v.getParent().getParent(); + onProfileRowClicked(row); }); holder.mTitle.setOnLongClickListener(v -> { flipEditingProfiles(); @@ -203,6 +213,7 @@ public class ProfilesRecyclerViewAdapter final TextView mTitle, mColorTag; final LinearLayout tagAndHandleLayout; final ImageView mRearrangeHandle; + final ConstraintLayout mRow; ProfileListViewHolder(View view) { super(view); @@ -211,6 +222,7 @@ public class ProfilesRecyclerViewAdapter mColorTag = view.findViewById(R.id.colorTag); mRearrangeHandle = view.findViewById(R.id.profile_list_rearrange_handle); tagAndHandleLayout = view.findViewById(R.id.handle_and_tag); + mRow = (ConstraintLayout) view; } } }