From 4116d13f1d1512cf5b42f6a92279efe5f7208183 Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Sun, 18 Aug 2019 17:28:11 +0300 Subject: [PATCH] progress bar added to exporter --- .../java/konogonka/Workers/NspXciExtractor.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/konogonka/Workers/NspXciExtractor.java b/src/main/java/konogonka/Workers/NspXciExtractor.java index d683ab0..1b2f4aa 100644 --- a/src/main/java/konogonka/Workers/NspXciExtractor.java +++ b/src/main/java/konogonka/Workers/NspXciExtractor.java @@ -28,7 +28,7 @@ public class NspXciExtractor extends Task { } @Override - protected Void call() { // TODO: add cute progress bar + protected Void call() { for (IRowModel model : models) { logPrinter.print("\tStart extracting: "+model.getFileName(), EMsgType.INFO); File contentFile = new File(filesDestPath + model.getFileName()); @@ -38,9 +38,21 @@ public class NspXciExtractor extends Task { byte[] readBuf = new byte[0x800000]; // 8mb NOTE: consider switching to 1mb 1048576 int readSize; + //*** PROGRESS BAR VARS START + long progressHandleFSize = model.getFileSize(); + int progressHandleFRead = 0; + //*** PROGRESS BAR VARS END while ((readSize = pis.read(readBuf)) > -1) { extractedFileBOS.write(readBuf, 0, readSize); readBuf = new byte[0x800000]; + //*** PROGRESS BAR DECORCATIONS START + progressHandleFRead += readSize; + try { + logPrinter.updateProgress((progressHandleFRead)/(progressHandleFSize/100.0) / 100.0); + }catch (InterruptedException ie){ + getException().printStackTrace(); // TODO: Do something with this + } + //*** PROGRESS BAR DECORCATIONS END } extractedFileBOS.close(); } catch (IOException ioe) {