diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-01-03 12:24:50 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-01-03 12:24:50 -0800 |
commit | a8d2fcf7aa8466007965dd64aa4b567723cd89d0 (patch) | |
tree | 4616081f08b0ca0c8db3d779c0caabe33a09a77c /src | |
parent | 4a63563b47710fb1cdc214bbc8ad71fd961a1db6 (diff) | |
download | dsub-a8d2fcf7aa8466007965dd64aa4b567723cd89d0.tar.gz dsub-a8d2fcf7aa8466007965dd64aa4b567723cd89d0.tar.bz2 dsub-a8d2fcf7aa8466007965dd64aa4b567723cd89d0.zip |
Delete artwork/avatars from cache on clear cache as well
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SettingsFragment.java | 2 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/FileUtil.java | 8 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/Util.java | 20 |
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(); |