当前位置: 首页>>代码示例>>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;未经允许,请勿转载。