File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
android/src/main/java/com/rnziparchive Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -149,11 +149,26 @@ public void run() {
149
149
zipFile = new net .lingala .zip4j .ZipFile (zipFilePath );
150
150
}
151
151
152
+ ProgressMonitor progressMonitor = zipFile .getProgressMonitor ();
153
+
154
+ zipFile .setRunInThread (true );
152
155
zipFile .extractAll (destDirectory );
153
156
154
- zipFile .close ();
155
- updateProgress (1 , 1 , zipFilePath ); // force 100%
156
- promise .resolve (destDirectory );
157
+ while (!progressMonitor .getState ().equals (ProgressMonitor .State .READY )) {
158
+ updateProgress (progressMonitor .getWorkCompleted (), progressMonitor .getTotalWork (), zipFilePath );
159
+
160
+ Thread .sleep (100 );
161
+ }
162
+
163
+ if (progressMonitor .getResult ().equals (ProgressMonitor .Result .SUCCESS )) {
164
+ zipFile .close ();
165
+ updateProgress (1 , 1 , zipFilePath ); // force 100%
166
+ promise .resolve (destDirectory );
167
+ } else if (progressMonitor .getResult ().equals (ProgressMonitor .Result .ERROR )) {
168
+ throw new Exception ("Error occurred. Error message: " + progressMonitor .getException ().getMessage ());
169
+ } else if (progressMonitor .getResult ().equals (ProgressMonitor .Result .CANCELLED )) {
170
+ throw new Exception ("Task cancelled" );
171
+ }
157
172
} catch (Exception ex ) {
158
173
updateProgress (0 , 1 , zipFilePath ); // force 0%
159
174
promise .reject (null , "Failed to extract file " + ex .getLocalizedMessage ());
You can’t perform that action at this time.
0 commit comments