我已将zip4j
库添加到我的 Android 项目中。这是非常容易使用。
ZipFile zipFile = new ZipFile(downloadedFilePath);
zipFile.extractAll(context.getFilesDir().getPath());
但是有一个我担心的功能。他们没有订阅以获取解压缩的进度,而是使用while-loop
如下:
while (pm.getState() == ProgressMonitor.STATE_BUSY) {
// my progress handler is here
}
如果我需要知道解压缩是否完成,我应该按如下方式使用它:
while (pm.getState() == ProgressMonitor.STATE_BUSY) {
// the loop runs until progress monitor changes its status
}
if (pm.getResult() == ProgressMonitor.RESULT_SUCCESS) {
// my code to handle completion
}
对我来说,它看起来是反模式和糟糕的编码。我应该在我的项目中使用,还是切换到不同的 zip 库?