- Data.profile.addObserver(new Observer() {
- @Override
- public void update(Observable o, Object arg) {
- MobileLedgerProfile newProfile = Data.profile.get();
- MobileLedgerProfile profile = (MobileLedgerProfile) holder.itemView.getTag();
- holder.mRadioView.setChecked(
- newProfile != null && newProfile.getUuid().equals(profile.getUuid()));
+
+ holder.mRadioView.setOnCheckedChangeListener((buttonView, isChecked) -> {
+ if (!isChecked) return;
+ Log.d("profiles",
+ String.format("Item %d got checked", holder.getAdapterPosition()));
+ MobileLedgerProfile profile = (MobileLedgerProfile) holder.itemView.getTag();
+ if (profile != null) {
+ Log.d("profiles",
+ String.format("Setting current profile to %s", profile.getUuid()));
+ Data.setCurrentProfile(profile);
+ }
+ });
+ View.OnClickListener profileSelector = v -> holder.mRadioView.setChecked(true);
+ holder.mTitle.setOnClickListener(profileSelector);
+ holder.mSubTitle.setOnClickListener(profileSelector);
+ Data.profile.addObserver((o, arg) -> {
+ MobileLedgerProfile myProfile = (MobileLedgerProfile) holder.itemView.getTag();
+ final MobileLedgerProfile currentProfile = Data.profile.get();
+ final boolean sameProfile = currentProfile.equals(myProfile);
+ if (holder.mRadioView.isChecked() != sameProfile) {
+ holder.mRadioView.setChecked(sameProfile);