use of net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem in project Osmand by osmandapp.
the class TracksCard method updateContent.
@SuppressLint("DefaultLocale")
@Override
protected void updateContent() {
LinearLayout tracks = view.findViewById(R.id.items);
tracks.removeAllViews();
int minCardHeight = getDimen(R.dimen.route_info_card_item_height);
int listContentPadding = getDimen(R.dimen.list_content_padding);
int listTextPadding = getDimen(R.dimen.route_info_list_text_padding);
int mainFontColor = getMainFontColor();
int descriptionColor = getSecondaryColor();
int dividerColor = ColorUtilities.getDividerColor(mapActivity, nightMode);
boolean showLimitExceeds = gpxItems.size() > 4;
ContextThemeWrapper ctx = new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
LayoutInflater inflater = LayoutInflater.from(ctx);
for (int i = 0; i < gpxItems.size(); i++) {
GpxItem item = gpxItems.get(i);
if (showLimitExceeds && i >= 3 && showLimited) {
break;
}
View v = inflater.inflate(R.layout.gpx_track_item, tracks, false);
GpxDataItem dataItem = getDataItem(item.info);
GPXTrackAnalysis analysis = null;
if (dataItem != null) {
analysis = dataItem.getAnalysis();
}
GpxUiHelper.updateGpxInfoView(v, item.title, item.info, analysis, app);
View div = v.findViewById(R.id.divider);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(div.getLayoutParams().width, div.getLayoutParams().height);
p.setMargins(listTextPadding, 0, 0, 0);
div.setBackgroundColor(dividerColor);
div.setLayoutParams(p);
div.setVisibility(i == 0 ? View.GONE : View.VISIBLE);
((TextView) v.findViewById(R.id.name)).setTextColor(mainFontColor);
((TextView) v.findViewById(R.id.distance)).setTextColor(descriptionColor);
((TextView) v.findViewById(R.id.points_count)).setTextColor(descriptionColor);
((TextView) v.findViewById(R.id.time)).setTextColor(descriptionColor);
ImageView img = v.findViewById(R.id.icon);
img.setImageDrawable(getActiveIcon(R.drawable.ic_action_polygom_dark));
img.setVisibility(View.VISIBLE);
LinearLayout container = v.findViewById(R.id.container);
container.setMinimumHeight(minCardHeight);
AndroidUtils.setPadding(container, listContentPadding, 0, 0, 0);
v.setOnClickListener(v1 -> mapActivity.getMapRouteInfoMenu().selectTrack(item.file));
tracks.addView(v);
}
View showAllButton = view.findViewById(R.id.show_all_button);
if (showLimited && showLimitExceeds) {
((TextView) view.findViewById(R.id.show_all_title)).setText(String.format("%s — %d", app.getString(R.string.shared_string_show_all).toUpperCase(), gpxItems.size()));
showAllButton.setVisibility(View.VISIBLE);
showAllButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showLimited = false;
updateContent();
setLayoutNeeded();
}
});
} else {
showAllButton.setVisibility(View.GONE);
}
((TextView) view.findViewById(R.id.gpx_card_title)).setText(String.format("%s (%d)", app.getString(R.string.tracks_on_map), gpxItems.size()));
}
use of net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem in project Osmand by osmandapp.
the class AddTracksGroupBottomSheetDialogFragment method onItemClick.
@Override
protected void onItemClick(int position) {
GpxDataItem dataItem = gpxList.get(position - 1);
GPXTrackAnalysis analysis = dataItem.getAnalysis();
if (analysis != null && analysis.wptCategoryNames != null && analysis.wptCategoryNames.size() > 1) {
Bundle args = new Bundle();
args.putString(SelectWptCategoriesBottomSheetDialogFragment.GPX_FILE_PATH_KEY, dataItem.getFile().getAbsolutePath());
SelectWptCategoriesBottomSheetDialogFragment fragment = new SelectWptCategoriesBottomSheetDialogFragment();
fragment.setArguments(args);
fragment.setUsedOnMap(false);
fragment.show(getParentFragment().getChildFragmentManager(), SelectWptCategoriesBottomSheetDialogFragment.TAG);
} else {
OsmandApplication app = getMyApplication();
if (app != null) {
GpxSelectionHelper selectionHelper = app.getSelectedGpxHelper();
File gpx = dataItem.getFile();
if (selectionHelper.getSelectedFileByPath(gpx.getAbsolutePath()) == null) {
GPXFile res = GPXUtilities.loadGPXFile(gpx);
selectionHelper.selectGpxFile(res, true, false, false, false, false);
}
app.getMapMarkersHelper().addOrEnableGpxGroup(gpx);
}
}
dismiss();
}
use of net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem in project Osmand by osmandapp.
the class MapMarkersHelper method updateGpxShowAsMarkers.
private void updateGpxShowAsMarkers(File file) {
GpxDataItem dataItem = ctx.getGpxDbHelper().getItem(file);
if (dataItem != null) {
ctx.getGpxDbHelper().updateShowAsMarkers(dataItem, true);
dataItem.setShowAsMarkers(true);
}
}
use of net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem in project Osmand by osmandapp.
the class GpxTrackAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder.getItemViewType() == TRACK_INFO_VIEW_TYPE) {
TrackViewHolder trackViewHolder = (TrackViewHolder) holder;
int listPosition = mapToListPosition(position);
boolean currentlyRecordingTrack = (showCurrentGpx && isFirstListItem(position));
if (currentlyRecordingTrack) {
trackViewHolder.icon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_track_recordable));
} else {
trackViewHolder.icon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_polygom_dark));
}
GPXInfo info = gpxInfoList.get(listPosition);
GpxDataItem dataItem = getDataItem(info);
String itemTitle = GpxUiHelper.getGpxTitle(info.getFileName());
if (!showFolderName) {
itemTitle = Algorithms.getFileWithoutDirs(itemTitle);
}
updateGpxInfoView(trackViewHolder, itemTitle, info, dataItem, currentlyRecordingTrack, app);
trackViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onItemClickListener != null) {
onItemClickListener.onItemClick(listPosition);
}
}
});
} else {
TrackCategoriesViewHolder categoriesViewHolder = (TrackCategoriesViewHolder) holder;
categoriesViewHolder.trackCategories.notifyDataSetChanged();
}
}
use of net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem in project Osmand by osmandapp.
the class GpsFiltersCard method fetchGpxDataItem.
@Nullable
private GpxDataItem fetchGpxDataItem() {
File file = new File(filteredSelectedGpxFile.getGpxFile().path);
GpxDataItemCallback callback = new GpxDataItemCallback() {
@Override
public boolean isCancelled() {
return false;
}
@Override
public void onGpxDataItemReady(GpxDataItem item) {
if (item != null) {
gpxDataItem = item;
}
}
};
return gpxDbHelper.getItem(file, callback);
}
Aggregations