refactored some code

This commit is contained in:
Chumva 2018-03-06 13:39:17 +02:00
parent 545bfc91f3
commit b41497611f

View file

@ -46,11 +46,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
public void createMenuItems(Bundle savedInstanceState) { public void createMenuItems(Bundle savedInstanceState) {
final OsmandApplication app = getMyApplication(); final OsmandApplication app = getMyApplication();
FavouritesDbHelper helper = app.getFavorites(); FavouritesDbHelper helper = app.getFavorites();
Bundle args = null; Bundle args = getArguments();
if (getArguments() != null) {
args = getArguments();
}
if (args != null) { if (args != null) {
String groupName = args.getString(GROUP_NAME_KEY); String groupName = args.getString(GROUP_NAME_KEY);
if (groupName != null) { if (groupName != null) {
@ -94,9 +90,9 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
R.layout.change_fav_color, null); R.layout.change_fav_color, null);
((ImageView) changeColorView.findViewById(R.id.change_color_icon)) ImageView colorIcon = ((ImageView) changeColorView.findViewById(R.id.change_color_icon));
.setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); colorIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_appearance));
updateColorView(changeColorView); updateColorView(colorIcon);
BaseBottomSheetItem changeColorItem = new BaseBottomSheetItem.Builder() BaseBottomSheetItem changeColorItem = new BaseBottomSheetItem.Builder()
.setCustomView(changeColorView) .setCustomView(changeColorView)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@ -237,8 +233,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
} }
} }
private void updateColorView(View colorView) { private void updateColorView(ImageView colorImageView) {
ImageView colorImageView = (ImageView) colorView.findViewById(R.id.colorImage);
int color = group.color == 0 ? getResources().getColor(R.color.color_favorite) : group.color; int color = group.color == 0 ? getResources().getColor(R.color.color_favorite) : group.color;
if (color == 0) { if (color == 0) {
colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle)); colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle));