diff --git a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java index a6c65f5b98..86b0e5bb1c 100644 --- a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java +++ b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java @@ -517,8 +517,11 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi @Override public boolean onPreferenceChange(Preference preference, Object newValue) { + final Context context = getContext(); + if (context == null) return true; + final int value = (Integer) newValue; - final MaterialColor selectedColor = MaterialColors.CONVERSATION_PALETTE.getByColor(getActivity(), value); + final MaterialColor selectedColor = MaterialColors.CONVERSATION_PALETTE.getByColor(context, value); final MaterialColor currentColor = recipient.getColor(); if (selectedColor == null) return true; @@ -527,7 +530,6 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi new AsyncTask() { @Override protected Void doInBackground(Void... params) { - Context context = getActivity(); DatabaseFactory.getRecipientDatabase(context).setColor(recipient, selectedColor); if (recipient.resolve().getRegistered() == RecipientDatabase.RegisteredState.REGISTERED) {