use of net.osmand.plus.mapmarkers.MapMarkersGroup in project Osmand by osmandapp.
the class EditTrackGroupDialogFragment method updateGroupWptCategory.
private void updateGroupWptCategory(GPXFile gpxFile, boolean synced) {
SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileByPath(gpxFile.path);
if (selectedGpxFile == null) {
selectedGpxHelper.selectGpxFile(gpxFile, true, false, false, false, false);
}
boolean groupCreated = false;
MapMarkersGroup markersGroup = mapMarkersHelper.getMarkersGroup(gpxFile);
if (markersGroup == null) {
groupCreated = true;
markersGroup = mapMarkersHelper.addOrEnableGroup(gpxFile);
}
Set<String> categories = markersGroup.getWptCategories();
Set<String> selectedCategories = new HashSet<>();
if (categories != null) {
selectedCategories.addAll(categories);
}
if (synced) {
selectedCategories.remove(group.getName());
} else {
selectedCategories.add(group.getName());
}
if (Algorithms.isEmpty(selectedCategories)) {
mapMarkersHelper.removeMarkersGroup(markersGroup);
} else {
mapMarkersHelper.updateGroupWptCategories(markersGroup, selectedCategories);
if (!groupCreated) {
mapMarkersHelper.runSynchronization(markersGroup);
}
}
}
use of net.osmand.plus.mapmarkers.MapMarkersGroup in project Osmand by osmandapp.
the class FavouritesHelper method removeFromMarkers.
private boolean removeFromMarkers(FavoriteGroup favGroup) {
MapMarkersHelper helper = app.getMapMarkersHelper();
MapMarkersGroup group = helper.getMarkersGroup(favGroup);
if (group != null) {
helper.removeMarkersGroup(group);
return true;
}
return false;
}
use of net.osmand.plus.mapmarkers.MapMarkersGroup in project Osmand by osmandapp.
the class FavouritesHelper method runSyncWithMarkers.
private void runSyncWithMarkers(FavoriteGroup favGroup) {
MapMarkersHelper helper = app.getMapMarkersHelper();
MapMarkersGroup group = helper.getMarkersGroup(favGroup);
if (group != null) {
helper.runSynchronization(group);
}
}
use of net.osmand.plus.mapmarkers.MapMarkersGroup in project Osmand by osmandapp.
the class DeletePointsTask method syncGpx.
private void syncGpx(GPXFile gpxFile) {
MapMarkersHelper helper = app.getMapMarkersHelper();
MapMarkersGroup group = helper.getMarkersGroup(gpxFile);
if (group != null) {
helper.runSynchronization(group);
}
}
use of net.osmand.plus.mapmarkers.MapMarkersGroup in project Osmand by osmandapp.
the class DuplicatesSettingsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
Object currentItem = items.get(position);
if (holder instanceof HeaderViewHolder) {
HeaderViewHolder headerHolder = (HeaderViewHolder) holder;
headerHolder.title.setText((String) currentItem);
headerHolder.subTitle.setText(String.format(app.getString(R.string.listed_exist), currentItem));
headerHolder.divider.setVisibility(View.VISIBLE);
} else if (holder instanceof ItemViewHolder) {
ItemViewHolder itemHolder = (ItemViewHolder) holder;
itemHolder.subTitle.setVisibility(View.GONE);
if (currentItem instanceof ApplicationModeBean) {
ApplicationModeBean modeBean = (ApplicationModeBean) currentItem;
String profileName = modeBean.userProfileName;
if (Algorithms.isEmpty(profileName)) {
ApplicationMode appMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
if (appMode != null) {
profileName = appMode.toHumanString();
} else {
profileName = Algorithms.capitalizeFirstLetter(modeBean.stringKey);
}
}
itemHolder.title.setText(profileName);
String routingProfile = "";
String routingProfileValue = modeBean.routingProfile;
if (!routingProfileValue.isEmpty()) {
try {
routingProfile = app.getString(RoutingProfilesResources.valueOf(routingProfileValue.toUpperCase()).getStringRes());
routingProfile = Algorithms.capitalizeFirstLetterAndLowercase(routingProfile);
} catch (IllegalArgumentException e) {
routingProfile = Algorithms.capitalizeFirstLetterAndLowercase(routingProfileValue);
LOG.error("Error trying to get routing resource for " + routingProfileValue + "\n" + e);
}
}
if (Algorithms.isEmpty(routingProfile)) {
itemHolder.subTitle.setVisibility(View.GONE);
} else {
itemHolder.subTitle.setText(String.format(app.getString(R.string.ltr_or_rtl_combine_via_colon), app.getString(R.string.nav_type_hint), routingProfile));
itemHolder.subTitle.setVisibility(View.VISIBLE);
}
int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName);
ProfileIconColors iconColor = modeBean.iconColor;
Integer customIconColor = modeBean.customIconColor;
int actualIconColor = customIconColor != null ? customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode));
itemHolder.icon.setImageDrawable(uiUtilities.getPaintedIcon(profileIconRes, actualIconColor));
} else if (currentItem instanceof QuickAction) {
QuickAction action = (QuickAction) currentItem;
itemHolder.title.setText(action.getName(app));
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(action.getIconRes(), activeColorRes));
} else if (currentItem instanceof PoiUIFilter) {
PoiUIFilter filter = (PoiUIFilter) currentItem;
itemHolder.title.setText(filter.getName());
int iconRes = RenderingIcons.getBigIconResourceId(filter.getIconId());
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_action_user, activeColorRes));
} else if (currentItem instanceof ITileSource) {
itemHolder.title.setText(((ITileSource) currentItem).getName());
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_map, activeColorRes));
} else if (currentItem instanceof File) {
File file = (File) currentItem;
FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath());
itemHolder.title.setText(file.getName());
if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) {
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_map_style, activeColorRes));
} else if (file.getAbsolutePath().contains(IndexConstants.ROUTING_PROFILES_DIR)) {
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
} else if (file.getAbsolutePath().contains(IndexConstants.GPX_INDEX_DIR)) {
itemHolder.title.setText(GpxUiHelper.getGpxTitle(file.getName()));
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
} else if (file.getAbsolutePath().contains(IndexConstants.AV_INDEX_DIR)) {
int iconId = AudioVideoNotesPlugin.getIconIdForRecordingFile(file);
if (iconId == -1) {
iconId = R.drawable.ic_action_photo_dark;
}
itemHolder.title.setText(new Recording(file).getName(app, true));
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconId, activeColorRes));
} else if (fileSubtype.isMap() || fileSubtype == FileSubtype.TTS_VOICE || fileSubtype == FileSubtype.VOICE) {
itemHolder.title.setText(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName()));
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(fileSubtype.getIconId(), activeColorRes));
}
} else if (currentItem instanceof AvoidRoadInfo) {
itemHolder.title.setText(((AvoidRoadInfo) currentItem).name);
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_alert, activeColorRes));
} else if (currentItem instanceof FavoriteGroup) {
itemHolder.title.setText(((FavoriteGroup) currentItem).getDisplayName(app));
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_favorite, activeColorRes));
} else if (currentItem instanceof MapMarker) {
MapMarker mapMarker = (MapMarker) currentItem;
itemHolder.title.setText(mapMarker.getName(app));
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_flag, activeColorRes));
} else if (currentItem instanceof HistoryEntry) {
itemHolder.title.setText(((HistoryEntry) currentItem).getName().getName());
} else if (currentItem instanceof OnlineRoutingEngine) {
itemHolder.title.setText(((OnlineRoutingEngine) currentItem).getName(app));
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_world_globe_dark, activeColorRes));
} else if (currentItem instanceof MapMarkersGroup) {
MapMarkersGroup markersGroup = (MapMarkersGroup) currentItem;
String groupName = markersGroup.getName();
if (Algorithms.isEmpty(groupName)) {
if (markersGroup.getType() == ItineraryType.FAVOURITES) {
groupName = app.getString(R.string.shared_string_favorites);
} else if (markersGroup.getType() == ItineraryType.MARKERS) {
groupName = app.getString(R.string.map_markers);
}
}
itemHolder.title.setText(groupName);
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_flag, activeColorRes));
}
itemHolder.divider.setVisibility(shouldShowDivider(position) ? View.VISIBLE : View.GONE);
}
}
Aggregations