Update action
This commit is contained in:
parent
b6d8ad47da
commit
0256823cd1
|
|
@ -95,6 +95,10 @@ public class Result {
|
|||
return Result.get().vod(Collections.emptyList()).msg(msg).string();
|
||||
}
|
||||
|
||||
public static String notify(String msg) {
|
||||
return Result.get().msg(msg).string();
|
||||
}
|
||||
|
||||
public static Result get() {
|
||||
return new Result();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ public abstract class Spider {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void action(String action) {
|
||||
|
||||
public String action(String action) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import com.github.catvod.bean.market.Item;
|
|||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.FileUtil;
|
||||
import com.github.catvod.utils.Notify;
|
||||
import com.github.catvod.utils.Path;
|
||||
import com.github.catvod.utils.Util;
|
||||
|
||||
|
|
@ -60,26 +59,23 @@ public class Market extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void action(String action) {
|
||||
Init.execute(() -> download(action));
|
||||
}
|
||||
|
||||
private void download(String url) {
|
||||
public String action(String action) {
|
||||
try {
|
||||
if (isBusy()) return;
|
||||
if (isBusy()) return "";
|
||||
setBusy(true);
|
||||
Init.run(this::setDialog, 500);
|
||||
Response response = OkHttp.newCall(url);
|
||||
File file = Path.create(new File(Path.download(), Uri.parse(url).getLastPathSegment()));
|
||||
Response response = OkHttp.newCall(action);
|
||||
File file = Path.create(new File(Path.download(), Uri.parse(action).getLastPathSegment()));
|
||||
download(file, response.body().byteStream(), Double.parseDouble(response.header("Content-Length", "1")));
|
||||
if (file.getName().endsWith(".zip")) FileUtil.unzip(file, Path.download());
|
||||
if (file.getName().endsWith(".apk")) FileUtil.openFile(file);
|
||||
else Notify.show("下載完成");
|
||||
checkCopy(url);
|
||||
else Result.notify("下載完成");
|
||||
checkCopy(action);
|
||||
dismiss();
|
||||
return "";
|
||||
} catch (Exception e) {
|
||||
Notify.show(e.getMessage());
|
||||
dismiss();
|
||||
return Result.notify(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
e0b5490f5bced400cec1f2513431f1d3
|
||||
3569e45ba9e1c3200bff36d96acf4241
|
||||
|
|
|
|||
Loading…
Reference in New Issue