From 7ff9a42927fb8ddc9e1d913572dd86dea8734ef9 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 15 Mar 2019 03:12:45 +0200 Subject: [PATCH] fix crash when saving profile without bringing up the color selector --- .../ui/profiles/ProfileDetailFragment.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java index 8b4136a5..6f15fa7f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java @@ -196,6 +196,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue hookClearErrorOnFocusListener(userName, userNameLayout); hookClearErrorOnFocusListener(password, passwordLayout); + int profileThemeId; if (mProfile != null) { profileName.setText(mProfile.getName()); postingPermitted.setChecked(mProfile.isPostingPermitted()); @@ -204,10 +205,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue authParams.setVisibility(mProfile.isAuthEnabled() ? View.VISIBLE : View.GONE); userName.setText(mProfile.isAuthEnabled() ? mProfile.getAuthUserName() : ""); password.setText(mProfile.isAuthEnabled() ? mProfile.getAuthPassword() : ""); - - huePickerView.setBackgroundColor(Colors.getPrimaryColorForHue( - (mProfile.getThemeId() == -1) ? Colors.DEFAULT_HUE_DEG - : mProfile.getThemeId())); + profileThemeId = mProfile.getThemeId(); } else { profileName.setText(""); @@ -217,14 +215,14 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue authParams.setVisibility(View.GONE); userName.setText(""); password.setText(""); - huePickerView.setBackgroundColor(Colors.getPrimaryColorForHue(Colors.DEFAULT_HUE_DEG)); + profileThemeId = -1; } - int profileThemeId = (mProfile == null) ? -1 : mProfile.getThemeId(); final int hue = (profileThemeId == -1) ? Colors.DEFAULT_HUE_DEG : profileThemeId; final int profileColor = Colors.getPrimaryColorForHue(hue); huePickerView.setBackgroundColor(profileColor); + huePickerView.setTag(profileThemeId); huePickerView.setOnClickListener(v -> { HueRingDialog d = new HueRingDialog( Objects.requireNonNull(ProfileDetailFragment.this.getContext()), hue); -- 2.39.5