Fix selected gpx renaming
This commit is contained in:
parent
b8ea172ccd
commit
da4c08c05d
3 changed files with 9 additions and 6 deletions
|
@ -10,6 +10,8 @@ import android.widget.Toast;
|
|||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.SQLiteTileSource;
|
||||
|
@ -128,7 +130,13 @@ public class FileUtils {
|
|||
dest.getParentFile().mkdirs();
|
||||
}
|
||||
if (source.renameTo(dest)) {
|
||||
GpxSelectionHelper helper = ctx.getSelectedGpxHelper();
|
||||
SelectedGpxFile selected = helper.getSelectedFileByPath(source.getAbsolutePath());
|
||||
ctx.getGpxDbHelper().rename(source, dest);
|
||||
if (selected != null && selected.getGpxFile() != null) {
|
||||
selected.getGpxFile().path = dest.getAbsolutePath();
|
||||
helper.updateSelectedGpxFile(selected);
|
||||
}
|
||||
if (callback != null) {
|
||||
callback.renamedTo(dest);
|
||||
}
|
||||
|
|
|
@ -1604,7 +1604,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
if (mapActivity != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) {
|
||||
if (AndroidUtils.isActivityNotDestroyed(mapActivity)) {
|
||||
FileUtils.renameFile(mapActivity, toSave, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1500,16 +1500,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
|||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileByPath(gpxInfo.file.getPath());
|
||||
FileUtils.renameFile(getActivity(), gpxInfo.file, new RenameCallback() {
|
||||
@Override
|
||||
public void renamedTo(File file) {
|
||||
asyncLoader = new LoadGpxTask();
|
||||
asyncLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getActivity());
|
||||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
|
||||
selectedGpxFile.getGpxFile().path = file.getPath();
|
||||
selectedGpxHelper.updateSelectedGpxFile(selectedGpxFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue