aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-01-03 12:32:09 -0800
committerScott Jackson <daneren2005@gmail.com>2015-01-03 12:32:09 -0800
commitec63a0fc0c28c5b9d8af6c972e8ef6ec5ab4e0cf (patch)
treeb855ed6780aa58455cbb7d1fa6bea19deddc0194 /src/github/daneren2005
parenta8d2fcf7aa8466007965dd64aa4b567723cd89d0 (diff)
downloaddsub-ec63a0fc0c28c5b9d8af6c972e8ef6ec5ab4e0cf.tar.gz
dsub-ec63a0fc0c28c5b9d8af6c972e8ef6ec5ab4e0cf.tar.bz2
dsub-ec63a0fc0c28c5b9d8af6c972e8ef6ec5ab4e0cf.zip
Put delete in a background loader
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index 6e588ec4..5a190439 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -1343,25 +1343,35 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
}
public void deleteRecursively(Artist artist) {
- File dir = FileUtil.getArtistDirectory(context, artist);
- if(dir == null) return;
-
- MediaStoreService mediaStore = new MediaStoreService(context);
- Util.recursiveDelete(dir, mediaStore);
- if(Util.isOffline(context)) {
- refresh();
- }
+ deleteRecursively(FileUtil.getArtistDirectory(context, artist));
}
public void deleteRecursively(Entry album) {
- File dir = FileUtil.getAlbumDirectory(context, album);
- if(dir == null) return;
+ deleteRecursively(FileUtil.getAlbumDirectory(context, album));
- MediaStoreService mediaStore = new MediaStoreService(context);
- Util.recursiveDelete(dir, mediaStore);
- if(Util.isOffline(context)) {
- refresh();
+ }
+ public void deleteRecursively(final File dir) {
+ if(dir == null) {
+ return;
}
+
+ new LoadingTask<Void>(context) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MediaStoreService mediaStore = new MediaStoreService(context);
+ Util.recursiveDelete(dir, mediaStore);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ if(Util.isOffline(context)) {
+ refresh();
+ } else {
+ UpdateView.triggerUpdate();
+ }
+ }
+ }.execute();
}
public void showAlbumArtist(Entry entry) {