Update config

pull/69/head
FongMi 3 years ago
parent 2756d9acc0
commit 7ec4a6bed6
  1. 8
      app/src/main/java/com/github/catvod/spider/Market.java
  2. BIN
      jar/custom_spider.jar
  3. 2
      jar/custom_spider.jar.md5

@ -61,20 +61,24 @@ public class Market extends Spider {
Utils.notify("正在下載...");
Response response = OkHttp.newCall(url);
File file = FileUtil.getCacheFile(Uri.parse(url).getLastPathSegment());
download(file, response.body().byteStream());
download(file, response.body().byteStream(), Double.parseDouble(response.header("Content-Length", "1")));
FileUtil.openFile(FileUtil.chmod(file));
} catch (Exception e) {
Utils.notify(e.getMessage());
}
}
private void download(File file, InputStream is) throws Exception {
private void download(File file, InputStream is, double length) throws Exception {
FileOutputStream os = new FileOutputStream(file);
try (BufferedInputStream input = new BufferedInputStream(is)) {
byte[] buffer = new byte[4096];
int readBytes;
long totalBytes = 0;
while ((readBytes = input.read(buffer)) != -1) {
totalBytes += readBytes;
os.write(buffer, 0, readBytes);
int progress = (int) (totalBytes / length * 100.0);
if (progress % 10 < 5) Utils.notify("正在下載..." + progress + "%");
}
}
}

Binary file not shown.

@ -1 +1 @@
f78dde289126840ebdd4abaf0cb7841d
e387f38428b7c337475b2827c56949f5

Loading…
Cancel
Save