diff --git a/README.md b/README.md
index 39d2132..15de445 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ As simple as drag and drop can get.
And here is the [changelog](https://github.com/redwarp/9-Patch-Resizer/wiki/Changelog)
-Current version : *1.3.1*
+Current version : *1.3.2*
You're using 9patch resizer for your apps ? Don't hesitate and leave me a message!
diff --git a/launch4j_config.xml b/launch4j_config.xml
index 432c244..a3770f6 100644
--- a/launch4j_config.xml
+++ b/launch4j_config.xml
@@ -3,7 +3,7 @@
false
gui
C:\Users\Redwarp\workspace\Resizer\Resizer_proguard.jar
- C:\Users\Redwarp\workspace\Resizer\Resizer_1.3.2.exe
+ C:\Users\Redwarp\workspace\Resizer\Resizer_1.3.3.exe
@@ -26,12 +26,12 @@
64/32
- 1.3.2.0
- 1.3.2
+ 1.3.3.0
+ 1.3.3
9Patch Resizer
Redwarp - 2014
- 1.3.2.0
- 1.3.2
+ 1.3.3.0
+ 1.3.3
9Patch Resizer
Resizer
diff --git a/res/misc/preferences.properties b/res/misc/preferences.properties
index 5882032..e7528bd 100644
--- a/res/misc/preferences.properties
+++ b/res/misc/preferences.properties
@@ -1,3 +1,3 @@
#Created by JInto - www.guh-software.de
#Sun Oct 21 22:30:52 CEST 2012
-version=1.3.2
\ No newline at end of file
+version=1.3.3
\ No newline at end of file
diff --git a/src/net/redwarp/tool/resizer/FileProcessor.java b/src/net/redwarp/tool/resizer/FileProcessor.java
new file mode 100644
index 0000000..a78f471
--- /dev/null
+++ b/src/net/redwarp/tool/resizer/FileProcessor.java
@@ -0,0 +1,58 @@
+package net.redwarp.tool.resizer;
+
+import java.io.File;
+
+import net.redwarp.tool.resizer.table.Operation;
+import net.redwarp.tool.resizer.table.OperationStatus;
+import net.redwarp.tool.resizer.worker.ImageScaler;
+import net.redwarp.tool.resizer.worker.ScreenDensity;
+
+public class FileProcessor {
+
+ public interface FileProcessorStatusListener {
+ void onSuccess();
+
+ void onFailure(String msg);
+ }
+
+ private ImageScaler scaler;
+ FileProcessorStatusListener listener;
+ String fileName;
+
+ public FileProcessor(String name, FileProcessorStatusListener l) {
+ fileName = name;
+ listener = l;
+ if (name.endsWith(".png") || name.endsWith(".jpg")) {
+ Operation operation = new Operation(new File(name));
+
+ scaler = new ImageScaler(operation,
+ ScreenDensity.getDefaultInputDensity()) {
+ @Override
+ protected void process(java.util.List chunks) {
+ for (Operation operation : chunks) {
+ OperationStatus status = operation.getStatus();
+ if (status == OperationStatus.FINISH) {
+ if (listener != null) {
+ listener.onSuccess();
+ }
+ } else if (status == OperationStatus.ERROR) {
+ listener.onFailure(operation.getMessage());
+ }
+ }
+ }
+ };
+ }
+ }
+
+ public void process() {
+ if (scaler != null) {
+ scaler.post();
+ } else {
+ if (listener != null) {
+ listener.onFailure("processor for argument:" + fileName
+ + " is null");
+ }
+ }
+ }
+
+}
diff --git a/src/net/redwarp/tool/resizer/Main.java b/src/net/redwarp/tool/resizer/Main.java
index 9d947c4..ba6bd24 100644
--- a/src/net/redwarp/tool/resizer/Main.java
+++ b/src/net/redwarp/tool/resizer/Main.java
@@ -15,30 +15,74 @@
*/
package net.redwarp.tool.resizer;
+import java.util.ArrayList;
+
+import net.redwarp.tool.resizer.FileProcessor.FileProcessorStatusListener;
import net.redwarp.tool.resizer.misc.Localization;
import net.redwarp.tool.resizer.views.MainWindow;
import javax.swing.*;
public class Main {
- public static void main(String[] args) {
- // Apple only stuff
- System.setProperty("apple.laf.useScreenMenuBar", "true");
- System.setProperty("com.apple.mrj.application.apple.menu.about.name",
- Localization.get("app_name"));
-
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (UnsupportedLookAndFeelException e) {
- e.printStackTrace();
- }
-
- new MainWindow().setVisible(true);
- }
+ static class StatusListener implements FileProcessorStatusListener {
+ int count = 0;
+ int current = 0;
+ int failureCount = 0;
+
+ public StatusListener(int count) {
+ this.count = count;
+ }
+
+ @Override
+ public void onSuccess() {
+ this.current++;
+ if (this.current == this.count) {
+ System.exit(failureCount);
+ }
+ }
+
+ @Override
+ public void onFailure(String msg) {
+ System.err.print(msg + "\n");
+ this.current++;
+ this.failureCount++;
+ if (this.current == this.count) {
+ System.exit(failureCount);
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ // Apple only stuff
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ System.setProperty("com.apple.mrj.application.apple.menu.about.name",
+ Localization.get("app_name"));
+ if (args.length > 0) {
+ StatusListener l = new StatusListener(args.length);
+ ArrayList processors = new ArrayList();
+
+ for (String s : args) {
+ processors.add(new FileProcessor(s, l));
+ }
+ for (FileProcessor p : processors) {
+ p.process();
+ }
+ } else {
+
+ try {
+ UIManager.setLookAndFeel(UIManager
+ .getSystemLookAndFeelClassName());
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (UnsupportedLookAndFeelException e) {
+ e.printStackTrace();
+ }
+
+ new MainWindow().setVisible(true);
+ }
+ }
}