Some small cleanup
This commit is contained in:
parent
7d29d01ff3
commit
fb77141140
@ -60,15 +60,15 @@ public class Printer extends CordovaPlugin {
|
||||
* cordova.getActivity().runOnUiThread(runnable);
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param rawArgs The exec() arguments in JSON form.
|
||||
* @param callbackContext The callback context used when calling back into JavaScript.
|
||||
* @param args The exec() arguments in JSON form.
|
||||
* @param callback The callback context used when calling back into JavaScript.
|
||||
* @return Whether the action was valid.
|
||||
*/
|
||||
@Override
|
||||
public boolean execute (String action, JSONArray args,
|
||||
CallbackContext callbackContext) throws JSONException {
|
||||
CallbackContext callback) throws JSONException {
|
||||
|
||||
command = callbackContext;
|
||||
command = callback;
|
||||
|
||||
if (action.equalsIgnoreCase("isAvailable")) {
|
||||
isAvailable();
|
||||
@ -105,12 +105,12 @@ public class Printer extends CordovaPlugin {
|
||||
*/
|
||||
private void print (final JSONArray args) {
|
||||
final String content = args.optString(0, "<html></html>");
|
||||
final JSONObject props = args.optJSONObject(1);;
|
||||
final JSONObject props = args.optJSONObject(1);
|
||||
|
||||
cordova.getActivity().runOnUiThread( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initWebView(content, props);
|
||||
initWebView(props);
|
||||
loadContent(content);
|
||||
}
|
||||
});
|
||||
@ -138,29 +138,25 @@ public class Printer extends CordovaPlugin {
|
||||
* Configures the WebView components which will call the Google Cloud Print
|
||||
* Service.
|
||||
*
|
||||
* @param content
|
||||
* HTML encoded string
|
||||
* @param props
|
||||
* The JSON object with the containing page properties
|
||||
*/
|
||||
private void initWebView (String content, JSONObject props) {
|
||||
private void initWebView (JSONObject props) {
|
||||
Activity ctx = cordova.getActivity();
|
||||
view = new WebView(ctx);
|
||||
|
||||
view.getSettings().setDatabaseEnabled(true);
|
||||
|
||||
setWebViewClient(content, props);
|
||||
setWebViewClient(props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the web view client which sets the print document.
|
||||
*
|
||||
* @param content
|
||||
* HTML encoded string
|
||||
* @param props
|
||||
* The JSON object with the containing page properties
|
||||
*/
|
||||
private void setWebViewClient (final String content, JSONObject props) {
|
||||
private void setWebViewClient (JSONObject props) {
|
||||
final String docName = props.optString("name", DEFAULT_DOC_NAME);
|
||||
final boolean landscape = props.optBoolean("landscape", false);
|
||||
final boolean graystyle = props.optBoolean("graystyle", false);
|
||||
@ -212,8 +208,6 @@ public class Printer extends CordovaPlugin {
|
||||
cordova.getThreadPool().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Looper.prepare();
|
||||
|
||||
for (;;) {
|
||||
if (job.isCancelled() || job.isCompleted() || job.isFailed()) {
|
||||
command.success();
|
||||
|
Loading…
Reference in New Issue
Block a user