]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix crash when saving profile without bringing up the color selector
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 15 Mar 2019 01:12:45 +0000 (03:12 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 25 Mar 2019 06:17:36 +0000 (06:17 +0000)
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java

index 8b4136a593bb30e026f618265104933541cb87fc..6f15fa7fb6fc2ec5b673d3f3f00d56c8107eee3d 100644 (file)
@@ -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);