print returns boolean to inform about the result

This commit is contained in:
Sebastián Katzer 2016-07-23 13:18:24 +02:00
parent 13c9d3dbef
commit 43c325317a
3 changed files with 11 additions and 4 deletions

View File

@ -4,6 +4,7 @@
- [__change__:] Plugin requires Android KitKat or newer - [__change__:] Plugin requires Android KitKat or newer
- [__change__:] `isAvailable` returns false if no enabled print services can be found (Android) - [__change__:] `isAvailable` returns false if no enabled print services can be found (Android)
- [enhancement:] `isAvailable` returns additional list of available print services (Android) - [enhancement:] `isAvailable` returns additional list of available print services (Android)
- [enhancement:] `print` returns bool value to indicate the result
- [enhancement:] Support `duplex` attribute (Android) - [enhancement:] Support `duplex` attribute (Android)

View File

@ -229,7 +229,10 @@ public class Printer extends CordovaPlugin {
public void run() { public void run() {
for (;;) { for (;;) {
if (job.isCancelled() || job.isCompleted() || job.isFailed()) { if (job.isCancelled() || job.isCompleted() || job.isFailed()) {
command.success(); PluginResult res = new PluginResult(
PluginResult.Status.OK, job.isCompleted());
command.sendPluginResult(res);
break; break;
} }
} }

View File

@ -206,7 +206,8 @@
[controller presentFromRect:rect inView:self.webView animated:YES completionHandler: [controller presentFromRect:rect inView:self.webView animated:YES completionHandler:
^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) { ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) {
CDVPluginResult* pluginResult = CDVPluginResult* pluginResult =
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsBool:ok];
[self.commandDelegate sendPluginResult:pluginResult [self.commandDelegate sendPluginResult:pluginResult
callbackId:_callbackId]; callbackId:_callbackId];
@ -216,7 +217,8 @@
[controller presentAnimated:YES completionHandler: [controller presentAnimated:YES completionHandler:
^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) { ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) {
CDVPluginResult* pluginResult = CDVPluginResult* pluginResult =
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsBool:ok];
[self.commandDelegate sendPluginResult:pluginResult [self.commandDelegate sendPluginResult:pluginResult
callbackId:_callbackId]; callbackId:_callbackId];
@ -241,7 +243,8 @@
[controller printToPrinter:printer completionHandler: [controller printToPrinter:printer completionHandler:
^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) { ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) {
CDVPluginResult* pluginResult = CDVPluginResult* pluginResult =
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsBool:ok];
[self.commandDelegate sendPluginResult:pluginResult [self.commandDelegate sendPluginResult:pluginResult
callbackId:_callbackId]; callbackId:_callbackId];