NullPointExcepionFix

This commit is contained in:
androiddevkotlin 2021-03-06 13:51:03 +02:00
parent 1625a05a27
commit 53e284d843

View file

@ -23,12 +23,24 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routing.RouteService;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.DialogButtonType;
@ -42,7 +54,7 @@ import net.osmand.plus.profiles.SelectProfileBottomSheet.DialogMode;
import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback;
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
import net.osmand.plus.routing.RouteProvider;
import net.osmand.plus.routing.RouteService;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.backup.ProfileSettingsItem;
import net.osmand.plus.settings.backend.backup.SettingsHelper;
@ -59,21 +71,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import androidx.recyclerview.widget.RecyclerView;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
import static net.osmand.plus.profiles.SelectProfileBottomSheet.PROFILES_LIST_UPDATED_ARG;
import static net.osmand.plus.profiles.SelectProfileBottomSheet.PROFILE_KEY_ARG;
@ -313,7 +310,9 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
outState.putString(PROFILE_STRINGKEY_KEY, changedProfile.stringKey);
outState.putInt(PROFILE_ICON_RES_KEY, changedProfile.iconRes);
outState.putSerializable(PROFILE_COLOR_KEY, changedProfile.color);
outState.putInt(PROFILE_CUSTOM_COLOR_KEY, changedProfile.customColor);
if (changedProfile.customColor != null) {
outState.putInt(PROFILE_CUSTOM_COLOR_KEY, changedProfile.customColor);
}
if (changedProfile.parent != null) {
outState.putString(PROFILE_PARENT_KEY, changedProfile.parent.getStringKey());
}
@ -387,7 +386,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
profileName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
if (hasFocus) {
profileName.setSelection(profileName.getText().length());
AndroidUtils.showSoftKeyboard(getMyActivity(), profileName);
}
@ -511,7 +510,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
ImageView coloredCircle = iconItemView.findViewById(R.id.background);
AndroidUtils.setBackground(coloredCircle,
UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.circle_background_light),
UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, R.color.icon_color_default_light), 0.1f)));
UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, R.color.icon_color_default_light), 0.1f)));
coloredCircle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -859,11 +858,11 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
}
return false;
}
private boolean nameIsEmpty() {
return changedProfile.name.trim().isEmpty();
}
private void disableSaveButtonWithErrorMessage(String errorMessage) {
saveButton.setEnabled(false);
profileNameOtfb.setError(errorMessage, true);
@ -1039,7 +1038,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
if (parent != null ? !parent.equals(that.parent) : that.parent != null) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (color != that.color) return false;
if (customColor != null ? !customColor.equals(that.customColor) : that.customColor != null) return false;
if (customColor != null ? !customColor.equals(that.customColor) : that.customColor != null)
return false;
if (routingProfile != null ? !routingProfile.equals(that.routingProfile) : that.routingProfile != null)
return false;
if (routeService != that.routeService) return false;