Fixed bug with null reference on long click at gpx in settings.
This commit is contained in:
parent
157b5b0209
commit
237036a7e4
2 changed files with 57 additions and 17 deletions
|
@ -328,7 +328,7 @@ public class GpxSelectionHelper {
|
|||
private void selectGpxFileImpl(GPXFile gpx, boolean show, boolean notShowNavigationDialog) {
|
||||
boolean displayed = false;
|
||||
SelectedGpxFile sf ;
|
||||
if(gpx.showCurrentTrack) {
|
||||
if(gpx != null && gpx.showCurrentTrack) {
|
||||
sf = savingTrackHelper.getCurrentTrack();
|
||||
sf.notShowNavigationDialog = notShowNavigationDialog;
|
||||
displayed = selectedGPXFiles.contains(sf);
|
||||
|
|
|
@ -398,9 +398,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
renameFile(info);
|
||||
} else if (resId == R.string.local_index_unselect_gpx_file ||
|
||||
resId == R.string.local_index_select_gpx_file) {
|
||||
if (info.gpx == null) {
|
||||
loadGpxAsync(info, resId == R.string.local_index_select_gpx_file);
|
||||
} else {
|
||||
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, resId == R.string.local_index_select_gpx_file, true);
|
||||
listAdapter.notifyDataSetChanged();
|
||||
selectedGpxHelper.runUiListeners();
|
||||
}
|
||||
} else if (resId == R.string.local_index_mi_delete) {
|
||||
Builder confirm = new AlertDialog.Builder(getActivity());
|
||||
confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||
|
@ -437,22 +441,20 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
};
|
||||
if(info.gpx != null){
|
||||
if (info.file == null) {
|
||||
if (info.gpx != null && info.file == null) {
|
||||
GpxSelectionHelper.SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedCurrentRecordingTrack();
|
||||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() == info.gpx) {
|
||||
adapter.item(R.string.local_index_unselect_gpx_file).listen(listener).reg();
|
||||
} else {
|
||||
adapter.item(R.string.local_index_select_gpx_file).listen(listener).reg();
|
||||
}
|
||||
} else {
|
||||
} else if (info.file != null) {
|
||||
if (getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(info.file.getAbsolutePath()) == null) {
|
||||
adapter.item(R.string.local_index_select_gpx_file).listen(listener).reg();
|
||||
} else {
|
||||
adapter.item(R.string.local_index_unselect_gpx_file).listen(listener).reg();
|
||||
}
|
||||
}
|
||||
}
|
||||
adapter.item(R.string.show_gpx_route).listen(listener).reg();
|
||||
if (info.file != null) {
|
||||
adapter.item(R.string.local_index_mi_rename).listen(listener).reg();
|
||||
|
@ -932,6 +934,44 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void loadGpxAsync(GpxInfo info, boolean isSelected){
|
||||
final boolean selected = isSelected;
|
||||
new AsyncTask<GpxInfo, Void, Void>() {
|
||||
GpxInfo info;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(GpxInfo... params) {
|
||||
if (params == null){
|
||||
return null;
|
||||
}
|
||||
info = params[0];
|
||||
params[0].updateGpxInfo(getMyApplication());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(Void... values) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
getSherlockActivity().setProgressBarIndeterminateVisibility(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
getSherlockActivity().setProgressBarIndeterminateVisibility(false);
|
||||
if (info.gpx != null){
|
||||
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, selected, true);
|
||||
listAdapter.notifyDataSetChanged();
|
||||
selectedGpxHelper.runUiListeners();
|
||||
}
|
||||
}
|
||||
}.execute(info);
|
||||
}
|
||||
|
||||
|
||||
private class SearchFilter extends Filter {
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue