I have added zip4j
library to my Android project. It is very easy to use.
ZipFile zipFile = new ZipFile(downloadedFilePath);
zipFile.extractAll(context.getFilesDir().getPath());
But there is one feature that I am concerned about. Instead of subscribing to get the progress of unzipping, they use while-loop
as follows:
while (pm.getState() == ProgressMonitor.STATE_BUSY) {
// my progress handler is here
}
And if I need to know that unzip is complete, I should use it as follows:
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
}
To me it looks as anti-pattern and poor coding. Should I use in my project, or switch to a different zip-library?
Aucun commentaire:
Enregistrer un commentaire