use of net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup in project Osmand by osmandapp.
the class TrackActivity method getGpxFile.
public List<GpxDisplayGroup> getGpxFile(boolean useDisplayGroups) {
if (gpxFile == null) {
return new ArrayList<>();
}
if (gpxFile.modifiedTime != modifiedTime) {
modifiedTime = gpxFile.modifiedTime;
GpxSelectionHelper selectedGpxHelper = ((OsmandApplication) getApplication()).getSelectedGpxHelper();
displayGroups = selectedGpxHelper.collectDisplayGroups(gpxFile);
originalGroups.clear();
for (GpxDisplayGroup g : displayGroups) {
originalGroups.add(g.cloneInstance());
}
if (file != null) {
SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByPath(gpxFile.path);
if (sf != null && file != null && sf.getDisplayGroups() != null) {
displayGroups = sf.getDisplayGroups();
}
}
}
if (useDisplayGroups) {
return displayGroups;
} else {
return originalGroups;
}
}
use of net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup in project Osmand by osmandapp.
the class GPXLayer method drawSelectedFilesSplits.
private void drawSelectedFilesSplits(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
if (tileBox.getZoom() >= startZoom) {
// request to load
for (SelectedGpxFile g : selectedGPXFiles) {
List<GpxDisplayGroup> groups = g.getDisplayGroups();
if (groups != null && !groups.isEmpty()) {
GpxDataItem gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(g.getGpxFile().path));
int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
if (color == 0) {
color = g.getModifiableGpxFile().getColor(0);
}
if (color == 0) {
color = cachedColor;
}
paintInnerRect.setColor(color);
paintInnerRect.setAlpha(179);
List<GpxDisplayItem> items = groups.get(0).getModifiableList();
drawSplitItems(canvas, tileBox, items, settings);
}
}
}
}
use of net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup in project Osmand by osmandapp.
the class SplitSegmentDialogFragment method getOverviewSegment.
private GpxDisplayItem getOverviewSegment() {
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(false);
GpxDisplayItem overviewSegment = null;
if (result.size() > 0) {
overviewSegment = result.get(0).getModifiableList().get(0);
}
return overviewSegment;
}
use of net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup in project Osmand by osmandapp.
the class SplitSegmentDialogFragment method updateHeader.
private void updateHeader() {
final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
if (getGpx() != null && !getGpx().showCurrentTrack && adapter.getCount() > 0) {
setupSplitIntervalView(splitIntervalView);
if (options.size() == 0) {
prepareSplitIntervalAdapterData();
}
updateSplitIntervalView(splitIntervalView);
splitIntervalView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ListPopupWindow popup = new ListPopupWindow(getActivity());
popup.setAnchorView(splitIntervalView);
popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
popup.setModal(true);
popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
popup.setAdapter(new ArrayAdapter<>(getTrackActivity(), R.layout.popup_list_text_item, options));
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectedSplitInterval = position;
GpxSelectionHelper.SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), true, false);
final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, sf);
}
popup.dismiss();
updateSplitIntervalView(splitIntervalView);
}
});
popup.show();
}
});
splitIntervalView.setVisibility(View.VISIBLE);
} else {
splitIntervalView.setVisibility(View.GONE);
}
}
use of net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup in project Osmand by osmandapp.
the class TrackSegmentFragment method setupSplitIntervalView.
private void setupSplitIntervalView(View view) {
final TextView title = (TextView) view.findViewById(R.id.split_interval_title);
final TextView text = (TextView) view.findViewById(R.id.split_interval_text);
final ImageView img = (ImageView) view.findViewById(R.id.split_interval_arrow);
int colorId;
final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) {
colorId = app.getSettings().isLightContent() ? R.color.primary_text_light : R.color.primary_text_dark;
} else {
colorId = app.getSettings().isLightContent() ? R.color.secondary_text_light : R.color.secondary_text_dark;
}
int color = app.getResources().getColor(colorId);
title.setTextColor(color);
text.setTextColor(color);
img.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_drop_down, colorId));
}
Aggregations