This repository has been archived by the owner on Nov 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
129 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#Created by JInto - www.guh-software.de | ||
#Sun Oct 21 22:30:52 CEST 2012 | ||
version=1.3.2 | ||
version=1.3.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Operation> 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"); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters