Change download folder

This commit is contained in:
FongMi 2023-10-19 17:11:53 +08:00
parent 7df9fe2259
commit 6bb350074f
4 changed files with 15 additions and 9 deletions

View File

@ -72,15 +72,15 @@ public class AliYun {
}
public File getUserCache() {
return FileUtil.getCacheFile("aliyundrive_user");
return FileUtil.cache("aliyundrive_user");
}
public File getOAuthCache() {
return FileUtil.getCacheFile("aliyundrive_oauth");
return FileUtil.cache("aliyundrive_oauth");
}
public File getDriveCache() {
return FileUtil.getCacheFile("aliyundrive_drive");
return FileUtil.cache("aliyundrive_drive");
}
private AliYun() {

View File

@ -78,7 +78,7 @@ public class Bili extends Spider {
}
private File getUserCache() {
return FileUtil.getCacheFile("bilibili_user");
return FileUtil.cache("bilibili_user");
}
@Override

View File

@ -82,9 +82,10 @@ public class Market extends Spider {
setBusy(true);
Init.run(this::setDialog, 500);
Response response = OkHttp.newCall(url);
File file = FileUtil.getCacheFile(Uri.parse(url).getLastPathSegment());
File file = new File(FileUtil.download(), Uri.parse(url).getLastPathSegment());
download(file, response.body().byteStream(), Double.parseDouble(response.header("Content-Length", "1")));
FileUtil.openFile(FileUtil.chmod(file));
if (file.getName().endsWith(".apk")) FileUtil.openFile(FileUtil.chmod(file));
else Utils.notify("下載完成");
dismiss();
} catch (Exception e) {
Utils.notify(e.getMessage());

View File

@ -3,6 +3,7 @@ package com.github.catvod.utils;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.text.TextUtils;
import com.github.catvod.spider.Init;
@ -16,12 +17,16 @@ import java.net.URLConnection;
public class FileUtil {
public static File getCacheDir() {
public static File cache() {
return Init.context().getCacheDir();
}
public static File getCacheFile(String fileName) {
return new File(getCacheDir(), fileName);
public static File cache(String name) {
return new File(cache(), name);
}
public static File download() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
}
public static void write(File file, String data) {