Change download folder

pull/69/head
FongMi 2 years ago
parent 7df9fe2259
commit 6bb350074f
  1. 6
      app/src/main/java/com/github/catvod/api/AliYun.java
  2. 2
      app/src/main/java/com/github/catvod/spider/Bili.java
  3. 5
      app/src/main/java/com/github/catvod/spider/Market.java
  4. 11
      app/src/main/java/com/github/catvod/utils/FileUtil.java

@ -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() {

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

@ -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());

@ -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) {

Loading…
Cancel
Save