aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/github/daneren2005/dsub/fragments/SettingsFragment.java2
-rw-r--r--src/github/daneren2005/dsub/util/FileUtil.java8
-rw-r--r--src/github/daneren2005/dsub/util/Util.java20
3 files changed, 30 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SettingsFragment.java b/src/github/daneren2005/dsub/fragments/SettingsFragment.java
index 1d08796d..8dfca3b7 100644
--- a/src/github/daneren2005/dsub/fragments/SettingsFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SettingsFragment.java
@@ -197,6 +197,8 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared
protected Void doInBackground() throws Throwable {
FileUtil.deleteMusicDirectory(context);
FileUtil.deleteSerializedCache(context);
+ FileUtil.deleteArtworkCache(context);
+ FileUtil.deleteAvatarCache(context);
return null;
}
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java
index ac2c080b..f59f9363 100644
--- a/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/src/github/daneren2005/dsub/util/FileUtil.java
@@ -442,6 +442,14 @@ public class FileUtil {
}
}
}
+ public static boolean deleteArtworkCache(Context context) {
+ File artDirectory = FileUtil.getAlbumArtDirectory(context);
+ return Util.recursiveDelete(artDirectory);
+ }
+ public static boolean deleteAvatarCache(Context context) {
+ File artDirectory = FileUtil.getAvatarDirectory(context);
+ return Util.recursiveDelete(artDirectory);
+ }
public static void unpinSong(Context context, File saveFile) {
// Don't try to unpin a song which isn't actually pinned
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index 7b905d11..ae0d668c 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -585,6 +585,26 @@ public final class Util {
}
return true;
}
+ public static boolean recursiveDelete(File dir) {
+ if (dir != null && dir.exists()) {
+ File[] list = dir.listFiles();
+ if(list != null) {
+ for(File file: list) {
+ if(file.isDirectory()) {
+ if(!recursiveDelete(file)) {
+ return false;
+ }
+ } else if(file.exists()) {
+ if(!file.delete()) {
+ return false;
+ }
+ }
+ }
+ }
+ return dir.delete();
+ }
+ return false;
+ }
public static boolean recursiveDelete(File dir, MediaStoreService mediaStore) {
if (dir != null && dir.exists()) {
File[] list = dir.listFiles();