Update progress dialog

This commit is contained in:
topjohnwu
2016-11-23 18:33:16 +08:00
parent 403e30feba
commit 3b20747192
3 changed files with 46 additions and 65 deletions

View File

@@ -105,36 +105,38 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
new DownloadReceiver() {
@Override
public void task(Uri uri) {
// Process and sign the zip
try {
ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
ByteArrayInputStream inBuffer;
// First remove top folder (the folder with the repo name) in Github source zip
ZipUtils.removeTopFolder(mContext.getContentResolver().openInputStream(uri), outBuffer);
inBuffer = new ByteArrayInputStream(outBuffer.toByteArray());
outBuffer.reset();
// Then sign the zip for the first time
ZipUtils.signZip(mContext, inBuffer, outBuffer, false);
// Call zipadjust through JNI
inBuffer = new ByteArrayInputStream(ZipUtils.zipAdjust(outBuffer.toByteArray(), outBuffer.size()));
outBuffer.reset();
// Finally, sign the whole zip file again
ZipUtils.signZip(mContext, inBuffer, outBuffer, true);
// Write it back to the downloaded zip
OutputStream out = mContext.getContentResolver().openOutputStream(uri);
outBuffer.writeTo(out);
out.close();
} catch (IOException e) {
return;
}
// Flash the zip
new Async.FlashZIP(mContext, uri, mFilename).exec();
new Async.FlashZIP(mContext, uri, mFilename){
@Override
protected void preProcessing() throws Throwable {
// Process and sign the zip
publishProgress(mContext.getString(R.string.zip_install_process_zip_msg));
try {
ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
ByteArrayInputStream inBuffer;
// First remove top folder (the folder with the repo name) in Github source zip
ZipUtils.removeTopFolder(mContext.getContentResolver().openInputStream(mUri), outBuffer);
inBuffer = new ByteArrayInputStream(outBuffer.toByteArray());
outBuffer.reset();
// Then sign the zip for the first time
ZipUtils.signZip(mContext, inBuffer, outBuffer, false);
// Call zipadjust through JNI
inBuffer = new ByteArrayInputStream(ZipUtils.zipAdjust(outBuffer.toByteArray(), outBuffer.size()));
outBuffer.reset();
// Finally, sign the whole zip file again
ZipUtils.signZip(mContext, inBuffer, outBuffer, true);
// Write it back to the downloaded zip
OutputStream out = mContext.getContentResolver().openOutputStream(mUri);
outBuffer.writeTo(out);
out.close();
} catch (IOException ignored) {}
}
}.exec();
}
},
repo.getZipUrl(),