Refactoring SelectGpxTaskListener
This commit is contained in:
parent
8e872492c7
commit
a58c0069a7
2 changed files with 6 additions and 15 deletions
|
@ -57,11 +57,6 @@ public class GpxSelectionHelper {
|
|||
private SavingTrackHelper savingTrackHelper;
|
||||
private final static Log LOG = PlatformUtil.getLog(GpxSelectionHelper.class);
|
||||
private SelectGpxTask selectGpxTask;
|
||||
private SelectGpxTaskListener gpxTaskListener;
|
||||
|
||||
public void setGpxTaskListener(SelectGpxTaskListener gpxTaskListener) {
|
||||
this.gpxTaskListener = gpxTaskListener;
|
||||
}
|
||||
|
||||
public GpxSelectionHelper(OsmandApplication osmandApplication, SavingTrackHelper trackHelper) {
|
||||
this.app = osmandApplication;
|
||||
|
@ -967,12 +962,12 @@ public class GpxSelectionHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void runSelection(Map<String, Boolean> selectedItems) {
|
||||
public void runSelection(Map<String, Boolean> selectedItems, SelectGpxTaskListener gpxTaskListener) {
|
||||
if (selectGpxTask != null && (selectGpxTask.getStatus() == AsyncTask.Status.RUNNING
|
||||
|| selectGpxTask.getStatus() == AsyncTask.Status.PENDING)) {
|
||||
selectGpxTask.cancel(false);
|
||||
}
|
||||
selectGpxTask = new SelectGpxTask(selectedItems);
|
||||
selectGpxTask = new SelectGpxTask(selectedItems, gpxTaskListener);
|
||||
selectGpxTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
|
@ -990,9 +985,11 @@ public class GpxSelectionHelper {
|
|||
|
||||
private Set<GPXFile> originalSelectedItems = new HashSet<>();
|
||||
private Map<String, Boolean> selectedItems;
|
||||
private SelectGpxTaskListener gpxTaskListener;
|
||||
|
||||
SelectGpxTask(Map<String, Boolean> selectedItems) {
|
||||
SelectGpxTask(Map<String, Boolean> selectedItems, SelectGpxTaskListener gpxTaskListener) {
|
||||
this.selectedItems = selectedItems;
|
||||
this.gpxTaskListener = gpxTaskListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1012,17 +1009,13 @@ public class GpxSelectionHelper {
|
|||
|
||||
@Override
|
||||
protected void onProgressUpdate(Void... values) {
|
||||
if (gpxTaskListener != null) {
|
||||
gpxTaskListener.gpxSelectionInProgress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
collectSelectedItems();
|
||||
if (gpxTaskListener != null) {
|
||||
gpxTaskListener.gpxSelectionStarted();
|
||||
}
|
||||
}
|
||||
|
||||
private void collectSelectedItems() {
|
||||
|
|
|
@ -205,7 +205,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
selectedGpxHelper.setGpxTaskListener(gpxTaskListener);
|
||||
if (!importing) {
|
||||
if (asyncLoader == null || asyncLoader.getResult() == null) {
|
||||
asyncLoader = new LoadGpxTask();
|
||||
|
@ -225,7 +224,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
|||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
selectedGpxHelper.setGpxTaskListener(null);
|
||||
updateEnable = false;
|
||||
if (operationTask != null) {
|
||||
operationTask.cancel(true);
|
||||
|
@ -657,7 +655,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
|||
String path = gpxInfo.currentlyRecordingTrack ? CURRENT_TRACK : gpxInfo.file.getAbsolutePath();
|
||||
selectedItemsFileNames.put(path, selectedItems.contains(gpxInfo));
|
||||
}
|
||||
selectedGpxHelper.runSelection(selectedItemsFileNames);
|
||||
selectedGpxHelper.runSelection(selectedItemsFileNames, gpxTaskListener);
|
||||
}
|
||||
|
||||
public void openSelectionMode(final int actionResId, int darkIcon, int lightIcon,
|
||||
|
|
Loading…
Reference in a new issue