Created
July 29, 2019 10:19
-
-
Save zarinfam/639e9fc95e4136eb9b366a4ff44263ff to your computer and use it in GitHub Desktop.
Created with Copy to Gist
This file contains hidden or 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
public synchronized void printText(String text) throws PrintingException { | |
final PrintTask printTask = new PrintTask(); | |
PrintingListener printingListener = new PrintingListener() { | |
@Override | |
public void onSuccess(SuccessResult successResult) { | |
printTask.setResult(PrintTask.RESULT_SUCCESS); | |
} | |
@Override | |
public void onFailure(FailureResult failureResult) { | |
printTask.setResult(PrintTask.RESULT_FAILURE); | |
} | |
@Override | |
public void onTimeout(TimeoutResult timeoutResult) { | |
printTask.setResult(PrintTask.RESULT_TIMEOUT); | |
} | |
}; | |
printerApi.startPrinting(text, printingListener); | |
printTask.getResult(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment