use of net.osmand.plus.track.helpers.GpxDbHelper.GpxDataItemCallback in project Osmand by osmandapp.
the class GpxUiHelper method updateSelectedTracksAppearance.
private static void updateSelectedTracksAppearance(final OsmandApplication app, List<String> fileNames, final Map<String, String> params) {
GpxDataItemCallback callback = new GpxDataItemCallback() {
@Override
public boolean isCancelled() {
return false;
}
@Override
public void onGpxDataItemReady(GpxDataItem item) {
updateTrackAppearance(app, item, params);
}
};
GpxDbHelper gpxDbHelper = app.getGpxDbHelper();
for (String name : fileNames) {
GpxDataItem item = gpxDbHelper.getItem(new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), name), callback);
if (item != null) {
updateTrackAppearance(app, item, params);
}
}
}
use of net.osmand.plus.track.helpers.GpxDbHelper.GpxDataItemCallback in project Osmand by osmandapp.
the class AvailableGPXFragment method getGpxTrackAnalysis.
@Nullable
public static GPXTrackAnalysis getGpxTrackAnalysis(@NonNull GpxInfo gpxInfo, @NonNull OsmandApplication app, @Nullable final GpxInfoViewCallback callback) {
SelectedGpxFile sgpx = getSelectedGpxFile(gpxInfo, app);
GPXTrackAnalysis analysis = null;
if (sgpx != null && sgpx.isLoaded()) {
analysis = sgpx.getTrackAnalysis(app);
} else if (gpxInfo.currentlyRecordingTrack) {
analysis = app.getSavingTrackHelper().getCurrentTrack().getTrackAnalysis(app);
} else if (gpxInfo.file != null) {
GpxDataItemCallback analyserCallback = null;
if (callback != null) {
analyserCallback = new GpxDataItemCallback() {
@Override
public boolean isCancelled() {
return callback.isCancelled();
}
@Override
public void onGpxDataItemReady(GpxDataItem item) {
callback.onGpxDataItemChanged(item);
}
};
}
GpxDataItem dataItem = app.getGpxDbHelper().getItem(gpxInfo.file, analyserCallback);
if (dataItem != null) {
analysis = dataItem.getAnalysis();
}
}
return analysis;
}
use of net.osmand.plus.track.helpers.GpxDbHelper.GpxDataItemCallback in project Osmand by osmandapp.
the class GPXAction method setupGpxTrackInfo.
private void setupGpxTrackInfo(@NonNull final View container, @NonNull final OsmandApplication app) {
String gpxFilePath = getSelectedGpxFilePath(false);
if (gpxFilePath == null) {
return;
}
View trackInfoContainer = container.findViewById(R.id.selected_track_file_container);
boolean currentTrack = gpxFilePath.isEmpty();
File file = new File(gpxFilePath);
String gpxName = currentTrack ? app.getString(R.string.current_track) : GpxUiHelper.getGpxTitle(file.getName());
SelectedGpxFile selectedGpxFile = currentTrack ? app.getSavingTrackHelper().getCurrentTrack() : app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath);
if (selectedGpxFile != null) {
setupGpxTrackInfo(trackInfoContainer, gpxName, selectedGpxFile.getTrackAnalysis(app), app);
} else {
GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(file, new GpxDataItemCallback() {
@Override
public boolean isCancelled() {
return false;
}
@Override
public void onGpxDataItemReady(GpxDataItem item) {
if (item != null && item.getAnalysis() != null) {
setupGpxTrackInfo(trackInfoContainer, gpxName, item.getAnalysis(), app);
}
}
});
if (gpxDataItem != null && gpxDataItem.getAnalysis() != null) {
setupGpxTrackInfo(trackInfoContainer, gpxName, gpxDataItem.getAnalysis(), app);
}
}
}
use of net.osmand.plus.track.helpers.GpxDbHelper.GpxDataItemCallback 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);
}
use of net.osmand.plus.track.helpers.GpxDbHelper.GpxDataItemCallback in project Osmand by osmandapp.
the class TrackAppearanceFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = requireMyApplication();
settings = app.getSettings();
gpxDbHelper = app.getGpxDbHelper();
if (savedInstanceState != null) {
trackDrawInfo = new TrackDrawInfo(savedInstanceState);
if (selectedGpxFile == null) {
restoreSelectedGpxFile(trackDrawInfo.getFilePath(), trackDrawInfo.isCurrentRecording());
}
if (!trackDrawInfo.isCurrentRecording()) {
gpxDataItem = gpxDbHelper.getItem(new File(trackDrawInfo.getFilePath()));
}
showStartFinishIconsInitialValue = savedInstanceState.getBoolean(SHOW_START_FINISH_ICONS_INITIAL_VALUE_KEY, settings.SHOW_START_FINISH_ICONS.get());
} else {
showStartFinishIconsInitialValue = settings.SHOW_START_FINISH_ICONS.get();
if (selectedGpxFile.isShowCurrentTrack()) {
trackDrawInfo = new TrackDrawInfo(app, true);
} else {
GpxDataItemCallback callback = new GpxDataItemCallback() {
@Override
public boolean isCancelled() {
return false;
}
@Override
public void onGpxDataItemReady(GpxDataItem item) {
if (item != null) {
gpxDataItem = item;
trackDrawInfo.updateParams(item);
}
if (view != null) {
initContent();
}
}
};
String filePath = selectedGpxFile.getGpxFile().path;
gpxDataItem = gpxDbHelper.getItem(new File(filePath), callback);
trackDrawInfo = new TrackDrawInfo(filePath, gpxDataItem, false);
}
}
requireMyActivity().getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
public void handleOnBackPressed() {
dismiss();
}
});
}
Aggregations