cordova-plugin-mserviceinterface-2.0 1.0.56 → 1.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-mserviceinterface-2.0",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
4
4
  "description": "This plugin establishes the connection to the native interface and performs the requested task.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/plugin.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
3
3
  xmlns:android="http://schemas.android.com/apk/res/android"
4
4
  id="cordova-plugin-mserviceinterface-2.0"
5
- version="1.0.56">
5
+ version="1.0.57">
6
6
  <name>mserviceinterface-2.0</name>
7
7
  <description>This plugin establishes the connection to the native interface and performs the requested task.</description>
8
8
  <author>selfservit@gmail.com</author>
@@ -149,7 +149,6 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
149
149
  @RequiresApi(api = Build.VERSION_CODES.O)
150
150
  @Override
151
151
  public boolean execute(final String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
152
- callback = callbackContext;
153
152
  mInterfaceUtil.rootDirectory = new File(cordova.getActivity().getExternalFilesDir(""), "");
154
153
  if (mInterfaceUtil.packageName.equals("")) {
155
154
  mInterfaceUtil.packageName = cordova.getActivity().getApplicationContext().getPackageName().split("\\.")[2];
@@ -720,7 +719,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
720
719
  }
721
720
  } else if (action.equals("DownloadFile")) {
722
721
  callback = callbackContext;
723
- final DownloadTask downloadTask = new DownloadTask(cordova.getActivity());
722
+ final DownloadTask downloadTask = new DownloadTask(cordova.getActivity(),callback);
724
723
  downloadTask.execute(args.optJSONObject(0).optString("url"), args.optJSONObject(0).optString("filePath"), args.optJSONObject(0).optString("thumbnailInd"));
725
724
  return true;
726
725
  } else if ("QueueProcessor".equals(action)) {
@@ -2187,9 +2186,11 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
2187
2186
  private class DownloadTask extends AsyncTask<String, Integer, String> {
2188
2187
 
2189
2188
  private final Context context;
2189
+ private final CallbackContext downloadFileCallback;
2190
2190
 
2191
- public DownloadTask(Context context) {
2191
+ public DownloadTask(Context context, CallbackContext callback) {
2192
2192
  this.context = context;
2193
+ this.downloadFileCallback = callback;
2193
2194
  }
2194
2195
 
2195
2196
  @Override
@@ -2234,7 +2235,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
2234
2235
  output.write(data, 0, count);
2235
2236
  }
2236
2237
  } catch (Exception e) {
2237
- callback.error("Failure..." + e.getMessage());
2238
+ downloadFileCallback.error("Failure..." + e.getMessage());
2238
2239
  }
2239
2240
  if (sUrl[2].equalsIgnoreCase("true")) {
2240
2241
  return sUrl[1];
@@ -2251,13 +2252,13 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
2251
2252
  String extension = "." + result.substring(result.lastIndexOf(".") + 1).toLowerCase(),
2252
2253
  filePath = mInterfaceUtil.rootDirectory + "/" + result;
2253
2254
  String thumbnail = getFileThumbnail(filePath, extension);
2254
- callback.success(thumbnail);
2255
+ downloadFileCallback.success(thumbnail);
2255
2256
  } else {
2256
- callback.error("Failure...");
2257
+ downloadFileCallback.error("Failure...");
2257
2258
  }
2258
2259
  } else {
2259
2260
  System.out.println("success");
2260
- callback.success("");
2261
+ downloadFileCallback.success("");
2261
2262
  }
2262
2263
  } catch (Exception e) {
2263
2264
  e.printStackTrace();