add internal preference for custom storage locations

This commit is contained in:
dkanada 2021-05-13 19:19:39 +09:00
commit d2afefe595
5 changed files with 23 additions and 26 deletions

View file

@ -11,6 +11,7 @@ import com.dkanada.gramophone.BuildConfig;
import com.dkanada.gramophone.database.Cache;
import com.dkanada.gramophone.model.Song;
import com.dkanada.gramophone.util.MusicUtil;
import com.dkanada.gramophone.util.PreferenceUtil;
import java.io.File;
import java.io.FileInputStream;
@ -51,7 +52,9 @@ public class DownloadService extends Service {
try {
URL url = new URL(MusicUtil.getDownloadUri(song));
URLConnection connection = url.openConnection();
File download = new File(getCacheDir(), "download/" + song.id);
String cache = PreferenceUtil.getInstance(App.getInstance()).getLocationCache();
File download = new File(cache, "download/" + song.id);
File audio = new File(MusicUtil.getFileUri(song));
download.getParentFile().mkdirs();

View file

@ -90,7 +90,7 @@ public class LocalPlayer implements Playback {
LeastRecentlyUsedCacheEvictor recentlyUsedCache = new LeastRecentlyUsedCacheEvictor(cacheSize);
ExoDatabaseProvider databaseProvider = new ExoDatabaseProvider(context);
File cacheDirectory = new File(context.getCacheDir(), "exoplayer");
File cacheDirectory = new File(PreferenceUtil.getInstance(context).getLocationCache(), "exoplayer");
simpleCache = new SimpleCache(cacheDirectory, recentlyUsedCache, databaseProvider);
}