Change download folder
This commit is contained in:
parent
7df9fe2259
commit
6bb350074f
|
|
@ -72,15 +72,15 @@ public class AliYun {
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getUserCache() {
|
public File getUserCache() {
|
||||||
return FileUtil.getCacheFile("aliyundrive_user");
|
return FileUtil.cache("aliyundrive_user");
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getOAuthCache() {
|
public File getOAuthCache() {
|
||||||
return FileUtil.getCacheFile("aliyundrive_oauth");
|
return FileUtil.cache("aliyundrive_oauth");
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getDriveCache() {
|
public File getDriveCache() {
|
||||||
return FileUtil.getCacheFile("aliyundrive_drive");
|
return FileUtil.cache("aliyundrive_drive");
|
||||||
}
|
}
|
||||||
|
|
||||||
private AliYun() {
|
private AliYun() {
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class Bili extends Spider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getUserCache() {
|
private File getUserCache() {
|
||||||
return FileUtil.getCacheFile("bilibili_user");
|
return FileUtil.cache("bilibili_user");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,10 @@ public class Market extends Spider {
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
Init.run(this::setDialog, 500);
|
Init.run(this::setDialog, 500);
|
||||||
Response response = OkHttp.newCall(url);
|
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")));
|
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();
|
dismiss();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Utils.notify(e.getMessage());
|
Utils.notify(e.getMessage());
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.github.catvod.utils;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Environment;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.github.catvod.spider.Init;
|
import com.github.catvod.spider.Init;
|
||||||
|
|
@ -16,12 +17,16 @@ import java.net.URLConnection;
|
||||||
|
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
|
|
||||||
public static File getCacheDir() {
|
public static File cache() {
|
||||||
return Init.context().getCacheDir();
|
return Init.context().getCacheDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getCacheFile(String fileName) {
|
public static File cache(String name) {
|
||||||
return new File(getCacheDir(), fileName);
|
return new File(cache(), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File download() {
|
||||||
|
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void write(File file, String data) {
|
public static void write(File file, String data) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue