Fix home/work bottom sheet

This commit is contained in:
max-klaus 2019-12-11 16:52:56 +03:00
parent 88b3eb5686
commit 79367587f8

View file

@ -362,23 +362,11 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
private void loadFavoritesItems(List<Object> items, FavouritesDbHelper helper) { private void loadFavoritesItems(List<Object> items, FavouritesDbHelper helper) {
items.clear(); items.clear();
addMainScrollItems(items, helper); addMainScrollItems(items, helper);
items.addAll(helper.getNonPersonalVisibleFavouritePoints()); items.addAll(helper.getVisibleFavouritePoints());
if (items.isEmpty()) {
items.addAll(helper.getNonPersonalFavouritePoints());
}
} }
private void addMainScrollItems(List<Object> items, FavouritesDbHelper favorites) { private void addMainScrollItems(List<Object> items, FavouritesDbHelper favorites) {
items.add(FAVORITES); items.add(FAVORITES);
if (favorites.getHomePoint() != null) {
items.add(PointType.HOME);
}
if (favorites.getWorkPoint() != null) {
items.add(PointType.WORK);
}
if (favorites.getParkingPoint() != null) {
items.add(PointType.PARKING);
}
} }
private void createFavoritesScrollItem() { private void createFavoritesScrollItem() {
@ -657,31 +645,15 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
favoriteViewHolder.icon.setImageDrawable(getContentIcon(R.drawable.ic_action_fav_dark)); favoriteViewHolder.icon.setImageDrawable(getContentIcon(R.drawable.ic_action_fav_dark));
favoriteViewHolder.description.setVisibility(View.GONE); favoriteViewHolder.description.setVisibility(View.GONE);
} else { } else {
if (item instanceof PointType) { if (item instanceof PersonalFavouritePoint) {
FavouritePoint point = null; PersonalFavouritePoint point = (PersonalFavouritePoint) item;
boolean light = app.getSettings().isLightContent(); boolean light = app.getSettings().isLightContent();
int iconColor = light ? R.color.icon_color_default_light : R.color.icon_color_default_dark; int iconColor = light ? R.color.icon_color_default_light : R.color.icon_color_default_dark;
if (item == PointType.HOME) { favoriteViewHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(point.getType().getIconId(), iconColor));
point = favorites.getHomePoint(); favoriteViewHolder.title.setText(point.getName());
} else if (item == PointType.WORK) { favoriteViewHolder.description.setText(point.getDescription());
point = favorites.getWorkPoint();
} else if (item == PointType.PARKING) {
point = favorites.getParkingPoint();
}
Drawable icon = null;
String title = "";
String description = "";
if (point != null) {
PersonalFavouritePoint personalPoint = (PersonalFavouritePoint) point;
icon = app.getUIUtilities().getIcon(personalPoint.getType().getIconId(), iconColor);
title = point.getName();
description = point.getDescription();
}
favoriteViewHolder.icon.setImageDrawable(icon);
favoriteViewHolder.title.setText(title);
favoriteViewHolder.description.setText(description);
} else if (item instanceof FavouritePoint) { } else if (item instanceof FavouritePoint) {
FavouritePoint point = (FavouritePoint) getItem(position); FavouritePoint point = (FavouritePoint) item;
favoriteViewHolder.title.setText(point.getName()); favoriteViewHolder.title.setText(point.getName());
if (point.getCategory().equals("")) { if (point.getCategory().equals("")) {
favoriteViewHolder.description.setText(R.string.shared_string_favorites); favoriteViewHolder.description.setText(R.string.shared_string_favorites);