cordova-plugin-netcontroll-integration-getnet 1.0.104

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.
@@ -0,0 +1,70 @@
1
+ package cordova.plugin.netcontroll.integration.getnet;
2
+
3
+ import org.apache.cordova.CordovaPlugin;
4
+ import org.apache.cordova.CallbackContext;
5
+ import org.apache.cordova.CordovaInterface;
6
+ import org.apache.cordova.CordovaWebView;
7
+
8
+ import org.json.JSONArray;
9
+ import org.json.JSONException;
10
+
11
+ import android.app.Activity;
12
+ import android.content.Context;
13
+
14
+ public class NetControllCordovaPluginsIntegrationGetNet extends CordovaPlugin {
15
+ //GetNet
16
+ public GetNetSumni getNetSumni;
17
+
18
+ //Cordova/Java Params
19
+ private Activity mActivity;
20
+ private Context mContext;
21
+ private CordovaInterface mCordova;
22
+ private CordovaWebView webView;
23
+
24
+ @Override
25
+ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
26
+ super.initialize(cordova, webView);
27
+
28
+ this.webView = webView;
29
+ mActivity = cordova.getActivity();
30
+ mContext = cordova.getActivity().getApplicationContext();
31
+ mCordova = cordova;
32
+ }
33
+
34
+ private void initializeGetNetSumni() {
35
+ if (this.getNetSumni == null) {
36
+ this.getNetSumni = new GetNetSumni();
37
+ this.getNetSumni.initialize(this.cordova, this.webView);
38
+ }
39
+ }
40
+
41
+ @Override
42
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
43
+ try {
44
+ String result = "Sem resultado";
45
+ String[] actionProviderList = action.split("\\.");
46
+ String provider = actionProviderList[0];
47
+
48
+ switch (provider.toLowerCase()) {
49
+ case "getnet":
50
+ String getNetProduct = actionProviderList[1];
51
+ switch (getNetProduct.toLowerCase()) {
52
+ case "sumni":
53
+ this.initializeGetNetSumni();
54
+ String getNetSuminAction = actionProviderList[2];
55
+ boolean resultGetNetSuminExecute = this.getNetSumni.execute(getNetSuminAction, args, callbackContext);
56
+ return resultGetNetSuminExecute;
57
+ default:
58
+ break;
59
+ }
60
+ default:
61
+ break;
62
+ }
63
+ callbackContext.success(result);
64
+ return true;
65
+ } catch (Exception e) {
66
+ callbackContext.error("NetControllCordovaPluginsIntegrationGetNet excute error: " + e.toString());
67
+ }
68
+ return false;
69
+ }
70
+ }
@@ -0,0 +1,21 @@
1
+ package cordova.plugin.netcontroll.integration.getnet;
2
+
3
+ import com.google.gson.Gson;
4
+
5
+ import java.lang.reflect.Type;
6
+
7
+ public class NetControllHelpers {
8
+
9
+ public static <T> T parseJsonStringToObj(String objJson, Type objectClass) {
10
+ Gson gson = new Gson();
11
+ T result = gson.fromJson(objJson, objectClass);
12
+ return result;
13
+ }
14
+
15
+ public static String parseObjToJsonSrtring(Object obj) {
16
+ Gson gson = new Gson();
17
+ String result = gson.toJson(obj);
18
+ return result;
19
+ }
20
+ }
21
+