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