當前位置: 首頁>>代碼示例>>Java>>正文


Java CallbackContext類代碼示例

本文整理匯總了Java中org.apache.cordova.CallbackContext的典型用法代碼示例。如果您正苦於以下問題:Java CallbackContext類的具體用法?Java CallbackContext怎麽用?Java CallbackContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CallbackContext類屬於org.apache.cordova包,在下文中一共展示了CallbackContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if (action.equals("hide")) {
        cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                webView.postMessage("splashscreen", "hide");
            }
        });
    } else if (action.equals("show")) {
        cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                webView.postMessage("splashscreen", "show");
            }
        });
    } else {
        return false;
    }

    callbackContext.success();
    return true;
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:22,代碼來源:SplashScreen.java

示例2: installUpdate

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
/**
 * Install update if any available.
 *
 * @param jsCallback callback where to send the result;
 *                   used, when installation os requested manually from JavaScript
 */
private void installUpdate(CallbackContext jsCallback) {
    if (!isPluginReadyForWork) {
        return;
    }

    ChcpError error = UpdatesInstaller.install(cordova.getActivity(), pluginInternalPrefs.getReadyForInstallationReleaseVersionName(), pluginInternalPrefs.getCurrentReleaseVersionName());
    if (error != ChcpError.NONE) {
        if (jsCallback != null) {
            PluginResult errorResult = PluginResultHelper.createPluginResult(UpdateInstallationErrorEvent.EVENT_NAME, null, error);
            jsCallback.sendPluginResult(errorResult);
        }

        return;
    }

    if (jsCallback != null) {
        installJsCallback = jsCallback;
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:26,代碼來源:HotCodePushPlugin.java

示例3: jsInit

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
/**
 * Initialize default callback, received from the web side.
 *
 * @param callback callback to use for events broadcasting
 */
private void jsInit(CallbackContext callback) {
    jsDefaultCallback = callback;
    dispatchDefaultCallbackStoredResults();

    // Clear web history.
    // In some cases this is necessary, because on the launch we redirect user to the
    // external storage. And if he presses back button - browser will lead him back to
    // assets folder, which we don't want.
    handler.post(new Runnable() {
        @Override
        public void run() {
            webView.clearHistory();

        }
    });

    // fetch update when we are initialized
    if (chcpXmlConfig.isAutoDownloadIsAllowed() &&
            !UpdatesInstaller.isInstalling() && !UpdatesLoader.isExecuting()) {
        fetchUpdate();
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:28,代碼來源:HotCodePushPlugin.java

示例4: getIdToken

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
private void getIdToken(final boolean forceRefresh, final CallbackContext callbackContext) throws JSONException {
    cordova.getThreadPool().execute(new Runnable() {
        @Override
        public void run() {
            FirebaseUser user = firebaseAuth.getCurrentUser();

            if (user == null) {
                callbackContext.error("User is not authorized");
            } else {
                user.getIdToken(forceRefresh)
                    .addOnCompleteListener(cordova.getActivity(), new OnCompleteListener<GetTokenResult>() {
                        @Override
                        public void onComplete(Task<GetTokenResult> task) {
                            if (task.isSuccessful()) {
                                callbackContext.success(task.getResult().getToken());
                            } else {
                                callbackContext.error(task.getException().getMessage());
                            }
                        }
                    });
            }
        }
    });
}
 
開發者ID:chemerisuk,項目名稱:cordova-plugin-firebase-authentication,代碼行數:25,代碼來源:FirebaseAuthenticationPlugin.java

示例5: execute

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
@Override
public boolean execute(final String action, final JSONArray data,
                       final CallbackContext callbackContext) throws JSONException {
  if (methodList.contains(action)) {
    threadPool.execute(new Runnable() {
      @Override
      public void run() {
        try {
          Method method = NXTPushPlugin.class.getDeclaredMethod(action,
            JSONArray.class, CallbackContext.class);
          method.invoke(NXTPushPlugin.this, data, callbackContext);
        } catch (Exception e) {
          Log.e(TAG, e.toString());
        }
      }
    });
  }

  return true;
}
 
開發者ID:pengkobe,項目名稱:nxtpush-cordova-plugin,代碼行數:21,代碼來源:NXTPushPlugin.java

示例6: onRestoreStateForActivityResult

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
public void onRestoreStateForActivityResult(Bundle state, CallbackContext callbackContext) {
    this.destType = state.getInt("destType");
    this.srcType = state.getInt("srcType");
    this.mQuality = state.getInt("mQuality");
    this.targetWidth = state.getInt("targetWidth");
    this.targetHeight = state.getInt("targetHeight");
    this.encodingType = state.getInt("encodingType");
    this.mediaType = state.getInt("mediaType");
    this.numPics = state.getInt("numPics");
    this.allowEdit = state.getBoolean("allowEdit");
    this.correctOrientation = state.getBoolean("correctOrientation");
    this.saveToPhotoAlbum = state.getBoolean("saveToPhotoAlbum");

    if (state.containsKey("croppedUri")) {
        this.croppedUri = Uri.parse(state.getString("croppedUri"));
    }

    if (state.containsKey("imageUri")) {
        //I have no idea what type of URI is being passed in
        this.imageUri = new CordovaUri(Uri.parse(state.getString("imageUri")));
    }

    this.callbackContext = callbackContext;
}
 
開發者ID:disit,項目名稱:siiMobilityAppKit,代碼行數:25,代碼來源:CameraLauncher.java

示例7: hideCamera

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
private boolean hideCamera(CallbackContext callbackContext) {
  if(this.hasView(callbackContext) == false){
    return true;
  }

  FragmentManager fragmentManager = cordova.getActivity().getFragmentManager();
  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  fragmentTransaction.hide(fragment);
  fragmentTransaction.commit();

  callbackContext.success();
  return true;
}
 
開發者ID:MrShakes,項目名稱:cameraPreviewStream,代碼行數:14,代碼來源:CameraPreview.java

示例8: jsIsUpdateAvailableForInstallation

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
/**
 * Check if new version was loaded and can be installed.
 *
 * @param callback callback where to send the result
 */
private void jsIsUpdateAvailableForInstallation(final CallbackContext callback) {
    Map<String, Object> data = null;
    ChcpError error = null;
    final String readyForInstallationVersionName = pluginInternalPrefs.getReadyForInstallationReleaseVersionName();
    if (!TextUtils.isEmpty(readyForInstallationVersionName)) {
        data = new HashMap<String, Object>();
        data.put("readyToInstallVersion", readyForInstallationVersionName);
        data.put("currentVersion", pluginInternalPrefs.getCurrentReleaseVersionName());
    } else {
        error = ChcpError.NOTHING_TO_INSTALL;
    }

    PluginResult pluginResult = PluginResultHelper.createPluginResult(null, data, error);
    callback.sendPluginResult(pluginResult);
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:21,代碼來源:HotCodePushPlugin.java

示例9: deleteApp

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
private void deleteApp(final CallbackContext callbackContext, final String appName) {
    if (!appAuth.containsKey(appName)) {
        callbackContext.error("There is no app named " + appName);
        return;
    }

    try {
        final AuthComponent authComponent = appAuth.get(appName);
        authComponent.reset();
        appAuth.remove(appName);

        final DatabaseComponent databaseComponent = appDatabase.get(appName);
        databaseComponent.reset();
        appDatabase.remove(appName);
    } catch (Exception e) {
        callbackContext.error(e.getMessage());
    }
}
 
開發者ID:jsayol,項目名稱:cordova-plugin-firebase-sdk,代碼行數:19,代碼來源:Firebase.java

示例10: initializeComponentsWithApp

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
private void initializeComponentsWithApp(final CallbackContext callbackContext, final String appName,
                                         final FirebaseApp firebaseApp) {
    final Firebase self = this;
    final Bundle extras = this.cordova.getActivity().getIntent().getExtras();
    this.cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            Log.i(TAG, "Initializing plugin components for " + appName);

            if (appName.equals("[DEFAULT]")) {
                mAnalyticsComponent.initialize(context);
                MessagingComponent.initialize(extras);
            }

            appAuth.put(appName, new AuthComponent(self, firebaseApp));
            appDatabase.put(appName, new DatabaseComponent(self, firebaseApp));

            callbackContext.success();
        }
    });

}
 
開發者ID:jsayol,項目名稱:cordova-plugin-firebase-sdk,代碼行數:22,代碼來源:Firebase.java

示例11: sendEvent

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
private void sendEvent(String type, String msg) {
    JSONObject response = new JSONObject();
    try {
        response.put("type", type);
        response.put("message", msg);

        PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, response);
        pluginResult.setKeepCallback(true);
        CallbackContext pushCallback = getCurrentCallbackContext();
        if (pushCallback != null) {
            pushCallback.sendPluginResult(pluginResult);
        }

    } catch (JSONException e) {
        sendError(e.getMessage());
    }
}
 
開發者ID:rxnh8255,項目名稱:aiui,代碼行數:18,代碼來源:AIUIPlugin.java

示例12: execute

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if ("update".equals(action)) {
        update(args.getLong(0), callbackContext);
    } else if ("getBoolean".equals(action)) {
        getBoolean(args.getString(0), args.getString(1), callbackContext);
    } else if ("getBytes".equals(action)) {
        getBytes(args.getString(0), args.getString(1), callbackContext);
    } else if ("getNumber".equals(action)) {
        getNumber(args.getString(0), args.getString(1), callbackContext);
    } else if ("getString".equals(action)) {
        getString(args.getString(0), args.getString(1), callbackContext);
    } else {
        return false;
    }

    return true;
}
 
開發者ID:chemerisuk,項目名稱:cordova-plugin-firebase-config,代碼行數:19,代碼來源:FirebaseConfigPlugin.java

示例13: removeListeners

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
public void removeListeners(final CallbackContext callbackContext, final JSONArray listenerIDs) {
    mFirebase.cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            try {
                int size = listenerIDs.length();
                Log.i(TAG, "Removing " + size + "listeners");
                for (int i = 0; i < size; i++) {
                    String listenerID = listenerIDs.optString(i);
                    if (listenerID != null) {
                        DatabaseListener listener = listeners.get(listenerID);
                        listener.removeListener();
                        removeListener(listenerID);
                    }
                }
                callbackContext.success();
            } catch (Exception e) {
                Log.e(TAG, "Error removing listeners");
                callbackContext.error(e.getMessage());
            }
        }
    });
}
 
開發者ID:jsayol,項目名稱:cordova-plugin-firebase-sdk,代碼行數:23,代碼來源:DatabaseComponent.java

示例14: getByteArray

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
public void getByteArray(final CallbackContext callbackContext, final String key, final String namespace) {
    mFirebase.cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            try {
                Log.i(TAG, "Getting byte array " + key);
                byte[] bytes = namespace == null ? FirebaseRemoteConfig.getInstance().getByteArray(key)
                        : FirebaseRemoteConfig.getInstance().getByteArray(key, namespace);
                JSONObject object = new JSONObject();
                object.put("base64", Base64.encodeToString(bytes, Base64.DEFAULT));
                object.put("array", new JSONArray(bytes));
                callbackContext.success(object);
            } catch (Exception e) {
                Log.e(TAG, "Error getting byte array " + key, e);
                callbackContext.error(e.getMessage());
            }
        }
    });
}
 
開發者ID:jsayol,項目名稱:cordova-plugin-firebase-sdk,代碼行數:19,代碼來源:RemoteConfigComponent.java

示例15: getInfo

import org.apache.cordova.CallbackContext; //導入依賴的package包/類
public void getInfo(final CallbackContext callbackContext) {
    mFirebase.cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            try {
                Log.i(TAG, "Getting info");
                FirebaseRemoteConfigInfo remoteConfigInfo = FirebaseRemoteConfig.getInstance().getInfo();

                JSONObject settings = new JSONObject();
                settings.put("developerModeEnabled", remoteConfigInfo.getConfigSettings().isDeveloperModeEnabled());

                JSONObject info = new JSONObject();
                info.put("configSettings", settings);
                info.put("fetchTimeMillis", remoteConfigInfo.getFetchTimeMillis());
                info.put("lastFetchStatus", remoteConfigInfo.getLastFetchStatus());

                callbackContext.success(info);
            } catch (Exception e) {
                Log.e(TAG, "Error getting info", e);
                callbackContext.error(e.getMessage());
            }
        }
    });
}
 
開發者ID:jsayol,項目名稱:cordova-plugin-firebase-sdk,代碼行數:24,代碼來源:RemoteConfigComponent.java


注:本文中的org.apache.cordova.CallbackContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。