forked from upstream-mirrors/OpenTracks
TrackDeleteActivity: keep a wakelock while deletion is ongoing.
This commit is contained in:
@@ -18,9 +18,11 @@ package de.dennisguse.opentracks;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.view.View;
|
||||
|
||||
import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.util.SystemUtils;
|
||||
|
||||
/**
|
||||
* An activity for deleting tracks.
|
||||
@@ -46,13 +48,20 @@ public class TrackDeleteActivity extends AbstractActivity {
|
||||
deleteThread = new Thread(() -> {
|
||||
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(TrackDeleteActivity.this);
|
||||
|
||||
PowerManager.WakeLock wakeLock = SystemUtils.acquireWakeLock(TrackDeleteActivity.this, null);
|
||||
|
||||
for (long id : trackIds) {
|
||||
if (Thread.interrupted()) {
|
||||
return;
|
||||
break;
|
||||
}
|
||||
contentProviderUtils.deleteTrack(TrackDeleteActivity.this, id);
|
||||
}
|
||||
|
||||
wakeLock = SystemUtils.releaseWakeLock(wakeLock);
|
||||
if (Thread.interrupted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
runOnUiThread(TrackDeleteActivity.this::onAsyncTaskCompleted);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ public class KmlFileTrackImporter extends AbstractFileTrackImporter {
|
||||
private ArrayList<Float> powerList;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param context the context
|
||||
* @param importTrackId track id to import to. This should not be -1L so that images in the kmz file can be imported.
|
||||
*/
|
||||
@Deprecated //TODO Do not pass importTrackId here; get it from somewhere else
|
||||
public KmlFileTrackImporter(Context context, long importTrackId) {
|
||||
this(context, importTrackId, new ContentProviderUtils(context));
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ public class KmzTrackImporter implements TrackImporter {
|
||||
* @param importTrackId track id to import to. This should not be -1L so that images in the kmz file can be imported.
|
||||
* @param uriFile URI of the kmz file.
|
||||
*/
|
||||
@Deprecated //TODO Do not pass importTrackId here; get it from somewhere else
|
||||
public KmzTrackImporter(Context context, long importTrackId, Uri uriFile) {
|
||||
this.context = context;
|
||||
this.importTrackId = importTrackId;
|
||||
|
||||
Reference in New Issue
Block a user