use of net.osmand.plus.helpers.GpxUiHelper.GPXInfo in project Osmand by osmandapp.
the class DashTrackFragment method setupGpxFiles.
private void setupGpxFiles() {
View mainView = getView();
final File dir = getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
final OsmandApplication app = getMyApplication();
if (app == null) {
return;
}
final List<String> list = new ArrayList<String>();
for (SelectedGpxFile sg : app.getSelectedGpxHelper().getSelectedGPXFiles()) {
if (!sg.isShowCurrentTrack()) {
GPXFile gpxFile = sg.getGpxFile();
if (gpxFile != null) {
list.add(gpxFile.path);
}
}
}
int totalCount = 3 + list.size() / 2;
if (app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) {
totalCount--;
}
if (list.size() < totalCount) {
final List<GPXInfo> res = GpxUiHelper.getSortedGPXFilesInfoByDate(dir, true);
for (GPXInfo r : res) {
String name = r.getFileName();
if (!list.contains(name)) {
list.add(name);
if (list.size() >= totalCount) {
break;
}
}
}
}
if (list.size() == 0 && OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
DashboardOnMap.handleNumberOfRows(list, getMyApplication().getSettings(), ROW_NUMBER_TAG);
}
LinearLayout tracks = (LinearLayout) mainView.findViewById(R.id.items);
tracks.removeAllViews();
LayoutInflater inflater = getActivity().getLayoutInflater();
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
View view = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
createCurrentTrackView(view, app);
((TextView) view.findViewById(R.id.name)).setText(R.string.shared_string_currently_recording_track);
updateCurrentTrack(view, getActivity(), app);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AvailableGPXFragment.openTrack(getActivity(), null);
}
});
view.findViewById(R.id.divider_dash).setVisibility(View.VISIBLE);
tracks.addView(view);
startHandler(view);
}
for (String filename : list) {
final File f = new File(filename);
AvailableGPXFragment.GpxInfo info = new AvailableGPXFragment.GpxInfo();
info.subfolder = "";
info.file = f;
View v = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
AvailableGPXFragment.updateGpxInfoView(v, info, app, true);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AvailableGPXFragment.openTrack(getActivity(), f);
}
});
ImageButton showOnMap = ((ImageButton) v.findViewById(R.id.show_on_map));
showOnMap.setVisibility(View.VISIBLE);
showOnMap.setContentDescription(getString(R.string.shared_string_show_on_map));
updateShowOnMap(app, f, v, showOnMap);
tracks.addView(v);
}
}
Aggregations