io.flutter.plugin.common.MethodCall Java Examples

The following examples show how to use io.flutter.plugin.common.MethodCall. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TencentImPlugin.java    From FlutterTencentImPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * 腾讯云 获得用户信息
 *
 * @param methodCall 方法调用对象
 * @param result     返回结果对象
 */
private void getUserInfo(MethodCall methodCall, final Result result) {
    // 用户ID
    String id = this.getParam(methodCall, result, "id");
    boolean forceUpdate = this.getParam(methodCall, result, "forceUpdate");
    TIMFriendshipManager.getInstance().getUsersProfile(Collections.singletonList(id), forceUpdate, new ValueCallBack<List<TIMUserProfile>>(result) {
        @Override
        public void onSuccess(List<TIMUserProfile> timUserProfiles) {
            if (timUserProfiles != null && timUserProfiles.size() >= 1) {
                result.success(JsonUtil.toJSONString(timUserProfiles.get(0)));
            } else {
                result.success(null);
            }
        }
    });
}
 
Example #2
Source File: FlutterUploaderPlugin.java    From flutter_uploader with MIT License 6 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, @NonNull Result result) {
  switch (call.method) {
    case "enqueue":
      enqueue(call, result);
      break;
    case "enqueueBinary":
      enqueueBinary(call, result);
      break;
    case "cancel":
      cancel(call, result);
      break;
    case "cancelAll":
      cancelAll(call, result);
      break;
    default:
      result.notImplemented();
      break;
  }
}
 
Example #3
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void exitGroup(MethodCall call, final Result result) {
  HashMap<String, Object> map = call.arguments();
  long groupId;
  try {
    JSONObject params = new JSONObject(map);
    groupId = Long.parseLong(params.getString("id"));
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }

  JMessageClient.exitGroup(groupId, new BasicCallback() {
    @Override
    public void gotResult(int status, String desc) {
      handleResult(status, desc, result);
    }
  });
}
 
Example #4
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void createConversation(MethodCall call, Result result) {
  HashMap<String, Object> map = call.arguments();
  try {
    JSONObject params = new JSONObject(map);
    Conversation conversation = JMessageUtils.createConversation(params);

    if (conversation != null) {
      result.success(toJson(conversation));
    } else {
      handleResult(ERR_CODE_CONVERSATION, "Can't create the conversation, please check your parameters",
              result);
    }
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
  }
}
 
Example #5
Source File: LeancloudFunction.java    From leancloud_flutter_plugin with MIT License 6 votes vote down vote up
/**
 * initialize function
 *
 * The call must be include args:
 *  appId
 *  appKey
 *
 * @param call MethodCall from LeancloudFlutterPlugin.onMethodCall function
 * @param result MethodChannel.Result from LeancloudFlutterPlugin.onMethodCall function
 */
static void setServer(MethodCall call, MethodChannel.Result result) {
    int apiOSServiceType = LeancloudArgsConverter.getIntValue(call, result, "OSService");
    String url = LeancloudArgsConverter.getStringValue(call, result, "value");
    AVOSService avosService;
    switch (apiOSServiceType) {
        case 1:
            avosService = AVOSService.ENGINE;
            break;
        case 2:
            avosService = AVOSService.PUSH;
            break;
        case 3:
            avosService = AVOSService.RTM;
            break;
        default:
            avosService = AVOSService.API;
            break;
    }
    AVOSCloud.setServer(avosService, url);
}
 
Example #6
Source File: TencentImPlugin.java    From FlutterTencentImPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * 腾讯云 获取自己的资料
 *
 * @param methodCall 方法调用对象
 * @param result     返回结果对象
 */
private void getSelfProfile(MethodCall methodCall, final Result result) {
    // 强制走后台拉取
    Boolean forceUpdate = methodCall.argument("forceUpdate");
    if (forceUpdate != null && forceUpdate) {
        TIMFriendshipManager.getInstance().getSelfProfile(new ValueCallBack<TIMUserProfile>(result));
    } else {
        // 先获取本地,再获取服务器
        TIMUserProfile data = TIMFriendshipManager.getInstance().querySelfProfile();
        if (data == null) {
            TIMFriendshipManager.getInstance().getSelfProfile(new ValueCallBack<TIMUserProfile>(result));
        } else {
            result.success(JsonUtil.toJSONString(data));
        }
    }
}
 
Example #7
Source File: FlutterBraintreeDropIn.java    From FlutterBraintree with MIT License 6 votes vote down vote up
private static void readGooglePaymentParameters(DropInRequest dropInRequest, MethodCall call) {
  HashMap<String, Object> arg = call.argument("googlePaymentRequest");
  if (arg == null) {
    dropInRequest.disableGooglePayment();
    return;
  }
  GooglePaymentRequest googlePaymentRequest = new GooglePaymentRequest()
          .transactionInfo(TransactionInfo.newBuilder()
                  .setTotalPrice((String) arg.get("totalPrice"))
                  .setCurrencyCode((String) arg.get("currencyCode"))
                  .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
                  .build())
          .billingAddressRequired((Boolean) arg.get("billingAddressRequired"))
          .googleMerchantId((String) arg.get("merchantID"));
  dropInRequest.googlePaymentRequest(googlePaymentRequest);
}
 
Example #8
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void getPublicGroupInfos(MethodCall call, final Result result) {
  HashMap<String, Object> map = call.arguments();
  String appKey;
  int start, count;
  try {
    JSONObject params = new JSONObject(map);
    start = Integer.parseInt(params.getString("start"));
    count = Integer.parseInt(params.getString("count"));
    appKey = params.has("appKey") ? params.getString("appKey") : JmessageFlutterPlugin.appKey;
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }

  JMessageClient.getPublicGroupListByApp(appKey, start, count, new RequestCallback<List<GroupBasicInfo>>() {
    @Override
    public void gotResult(int status, String desc, List<GroupBasicInfo> groupBasicInfos) {
      handleResult(toJson(groupBasicInfos), status, desc, result);
    }
  });
}
 
Example #9
Source File: QrReaderView.java    From flutter_qr_reader with MIT License 6 votes vote down vote up
@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
    switch (methodCall.method) {
        case "flashlight":
            _view.setTorchEnabled(!flashlight);
            flashlight = !flashlight;
            result.success(flashlight);
            break;
        case "startCamera":
            _view.startCamera();
            break;
        case "stopCamera":
            _view.stopCamera();
            break;
    }

}
 
Example #10
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void setup(MethodCall call, Result result) {
  HashMap<String, Object> map = call.arguments();
  try {
    JSONObject params = new JSONObject(map);

    boolean isOpenMessageRoaming = false;
    if (params.has("isOpenMessageRoaming")) {
      isOpenMessageRoaming = params.getBoolean("isOpenMessageRoaming");
    }

    if (params.has("appkey")) {
      JmessageFlutterPlugin.appKey = params.getString("appkey");
    }
    JMessageClient.init(registrar.context(), isOpenMessageRoaming);
    JMessageClient.registerEventReceiver(this);
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }
}
 
Example #11
Source File: TencentImPlugin.java    From FlutterTencentImPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * 发送消息
 *
 * @param methodCall 方法调用对象
 * @param result     返回结果对象
 */
private void saveMessage(MethodCall methodCall, final Result result) {
    String nodeStr = this.getParam(methodCall, result, "node");
    Map node = JSON.parseObject(nodeStr, Map.class);
    String sessionType = this.getParam(methodCall, result, "sessionType");
    String sessionId = this.getParam(methodCall, result, "sessionId");
    String sender = this.getParam(methodCall, result, "sender");
    Boolean isReaded = this.getParam(methodCall, result, "isReaded");

    // 发送消息
    AbstractMessageNode messageNode = MessageNodeType.valueOf(node.get("nodeType").toString()).getMessageNodeInterface();
    AbstractMessageEntity messageEntity = (AbstractMessageEntity) JSON.parseObject(nodeStr, messageNode.getEntityClass());
    TIMMessage message = messageNode.save(TencentImUtils.getSession(sessionId, sessionType), messageEntity, sender, isReaded);
    TencentImUtils.getMessageInfo(Collections.singletonList(message), new ValueCallBack<List<MessageEntity>>(result) {
        @Override
        public void onSuccess(List<MessageEntity> messageEntities) {
            result.success(JsonUtil.toJSONString(messageEntities.get(0)));
        }
    });
}
 
Example #12
Source File: FlutterDownloaderPlugin.java    From flutter_downloader with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void retry(MethodCall call, MethodChannel.Result result) {
    String taskId = call.argument("task_id");
    DownloadTask task = taskDao.loadTask(taskId);
    boolean requiresStorageNotLow = call.argument("requires_storage_not_low");
    if (task != null) {
        if (task.status == DownloadStatus.FAILED || task.status == DownloadStatus.CANCELED) {
            WorkRequest request = buildRequest(task.url, task.savedDir, task.filename, task.headers, task.showNotification, task.openFileFromNotification, false, requiresStorageNotLow);
            String newTaskId = request.getId().toString();
            result.success(newTaskId);
            sendUpdateProgress(newTaskId, DownloadStatus.ENQUEUED, task.progress);
            taskDao.updateTask(taskId, newTaskId, DownloadStatus.ENQUEUED, task.progress, false);
            WorkManager.getInstance(context).enqueue(request);
        } else {
            result.error("invalid_status", "only failed and canceled task can be retried", null);
        }
    } else {
        result.error("invalid_task_id", "not found task corresponding to given task id", null);
    }
}
 
Example #13
Source File: FlutterMediaNotificationPlugin.java    From flutter_media_notification with MIT License 6 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, Result result) {
  switch (call.method) {
    case "showNotification":
      final String title = call.argument("title");
      final String author = call.argument("author");
      final boolean isPlaying = call.argument("isPlaying");
      showNotification(title, author, isPlaying);
      result.success(null);
      break;
    case "hideNotification":
      hideNotification();
      result.success(null);
      break;
    default:
      result.notImplemented();
  }
}
 
Example #14
Source File: FlutterUmengAnalyticsPlugin.java    From flutter_umeng_analytics with MIT License 6 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, Result result) {
    if (call.method.equals("init")) {
        init(call, result);
    } else if (call.method.equals("beginPageView")) {
        beginPageView(call, result);
    } else if (call.method.equals("endPageView")) {
        endPageView(call, result);
    } else if (call.method.equals("loginPageView")) {
        loginPageView(call, result);
    } else if (call.method.equals("eventCounts")) {
        eventCounts(call, result);
    } else {
        result.notImplemented();
    }
}
 
Example #15
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void setNoDisturbGlobal(MethodCall call, final Result result) {
  HashMap<String, Object> map = call.arguments();
  try {
    JSONObject params = new JSONObject(map);
    int isNoDisturbGlobal = params.getBoolean("isNoDisturb") ? ERR_CODE_PARAMETER : 0;
    JMessageClient.setNoDisturbGlobal(isNoDisturbGlobal, new BasicCallback() {

      @Override
      public void gotResult(int status, String desc) {
        handleResult(status, desc, result);
      }
    });
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }
}
 
Example #16
Source File: QiniucloudPushPlatformView.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 更新美颜设置
 */
private void updateFaceBeautySetting(MethodCall call, final MethodChannel.Result result) {
    double beautyLevel = CommonUtil.getParam(call, result, "beautyLevel");
    double redden = CommonUtil.getParam(call, result, "redden");
    double whiten = CommonUtil.getParam(call, result, "whiten");
    manager.setVideoFilterType(CameraStreamingSetting.VIDEO_FILTER_TYPE.VIDEO_FILTER_BEAUTY);

    CameraStreamingSetting.FaceBeautySetting faceBeautySetting = new CameraStreamingSetting.FaceBeautySetting((float) beautyLevel, (float) whiten, (float) redden);
    cameraStreamingSetting.setFaceBeautySetting(faceBeautySetting);
    manager.updateFaceBeautySetting(faceBeautySetting);
    result.success(null);
}
 
Example #17
Source File: TencentImPlugin.java    From FlutterTencentImPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 腾讯云 邀请加入群组
 *
 * @param methodCall 方法调用对象
 * @param result     返回结果对象
 */
private void inviteGroupMember(MethodCall methodCall, final Result result) {
    // 群ID
    String groupId = this.getParam(methodCall, result, "groupId");
    // 用户ID集合
    List<String> ids = Arrays.asList(this.getParam(methodCall, result, "ids").toString().split(","));

    TIMGroupManager.getInstance().inviteGroupMember(groupId, ids, new ValueCallBack<List<TIMGroupMemberResult>>(result));
}
 
Example #18
Source File: TencentImPlugin.java    From FlutterTencentImPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 腾讯云 申请加入群组
 *
 * @param methodCall 方法调用对象
 * @param result     返回结果对象
 */
private void applyJoinGroup(MethodCall methodCall, final Result result) {
    // 群ID
    String groupId = this.getParam(methodCall, result, "groupId");
    // 申请理由
    String reason = this.getParam(methodCall, result, "reason");

    TIMGroupManager.getInstance().applyJoinGroup(groupId, reason, new VoidCallBack(result));
}
 
Example #19
Source File: TencentImPlugin.java    From FlutterTencentImPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 腾讯云 退出群组
 *
 * @param methodCall 方法调用对象
 * @param result     返回结果对象
 */
private void quitGroup(MethodCall methodCall, final Result result) {
    // 群ID
    String groupId = this.getParam(methodCall, result, "groupId");

    TIMGroupManager.getInstance().quitGroup(groupId, new VoidCallBack(result));
}
 
Example #20
Source File: WifiIotPlugin.java    From WiFiFlutter with MIT License 5 votes vote down vote up
private void findAndConnect(final MethodCall poCall, final Result poResult) {
    int PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION = 65655434;
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && moContext.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED){
        moActivity.requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION);
    }
    new Thread() {
        public void run() {
            String ssid = poCall.argument("ssid");
            String password = poCall.argument("password");
            Boolean joinOnce = poCall.argument("join_once");

            String security = null;
            List<ScanResult> results = moWiFi.getScanResults();
            for (ScanResult result : results) {
                String resultString = "" + result.SSID;
                if (ssid.equals(resultString)) {
                    security = getSecurityType(result);
                }
            }

            final boolean connected = connectTo(ssid, password, security, joinOnce);

final Handler handler = new Handler(Looper.getMainLooper());
            handler.post(new Runnable() {
                @Override
                public void run () {
                    poResult.success(connected);
                }
            });
        }
    }.start();
}
 
Example #21
Source File: CommonUtil.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 通用方法,获得参数值,如未找到参数,则直接中断
 *
 * @param methodCall 方法调用对象
 * @param result     返回对象
 * @param param      参数名
 */
public static <T> T getParam(MethodCall methodCall, MethodChannel.Result result, String param) {
    T par = methodCall.argument(param);
    if (par == null) {
        result.error("Missing parameter", "Cannot find parameter `" + param + "` or `" + param + "` is null!", 5);
        throw new RuntimeException("Cannot find parameter `" + param + "` or `" + param + "` is null!");
    }
    return par;
}
 
Example #22
Source File: QiniucloudPushPlatformView.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 获取编码器输出的画面的高宽
 */
private void getVideoEncodingSize(MethodCall call, final MethodChannel.Result result) {
    Map<String, Object> res = new HashMap<>(2, 1);
    res.put("width", connectOptions.getVideoEncodingWidth());
    res.put("height", connectOptions.getVideoEncodingHeight());
    result.success(JSON.toJSONString(res));
}
 
Example #23
Source File: FlutterImagePickCropPlugin.java    From FlutterImagePickCrop with Apache License 2.0 5 votes vote down vote up
private boolean setPendingMethodCallAndResult(
        MethodCall methodCall, MethodChannel.Result result) {
    if (pendingResult != null) {
        return false;
    }

    this.methodCall = methodCall;
    pendingResult = result;
    return true;
}
 
Example #24
Source File: SquareReaderSdkFlutterPlugin.java    From reader-sdk-flutter-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, Result result) {
  String methodName = call.method;
  if (methodName.equals("isAuthorized")) {
    authorizeModule.isAuthorized(result);
  } else if (methodName.equals("isAuthorizationInProgress")) {
    authorizeModule.isAuthorizationInProgress(result);
  } else if (methodName.equals("authorizedLocation")) {
    authorizeModule.authorizedLocation(result);
  } else if (methodName.equals("authorize")) {
    String authCode = call.argument("authCode");
    authorizeModule.authorize(authCode, result);
  } else if (methodName.equals("canDeauthorize")) {
    authorizeModule.canDeauthorize(result);
  } else if (methodName.equals("deauthorize")) {
    authorizeModule.deauthorize(result);
  } else if (methodName.equals("startCheckout")) {
    HashMap<String, Object> checkoutParams = call.argument("checkoutParams");
    checkoutModule.startCheckout(checkoutParams, result);
  } else if (methodName.equals("startReaderSettings")) {
    readerSettingsModule.startReaderSettings(result);
  } else if (methodName.equals("startStoreCard")) {
    String customerId = call.argument("customerId");
    storeCustomerCardModule.startStoreCard(customerId, result);
  } else {
    result.notImplemented();
  }
}
 
Example #25
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 5 votes vote down vote up
private void setMessageHaveRead(MethodCall call,final Result result) {
  Log.d(TAG,"setMessageHaveRead: "  + call.arguments);

  HashMap<String, Object> map = call.arguments();
  Conversation conversation;
  String messageId;
  try {
    JSONObject params = new JSONObject(map);

    conversation = JMessageUtils.getConversation(params);
    if (conversation == null) {
      handleResult(ERR_CODE_CONVERSATION, ERR_MSG_CONVERSATION, result);
      return;
    }
    messageId = params.getString("id");
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }

  Message msg = conversation.getMessage(Integer.parseInt(messageId));
  if (msg != null) {
    msg.setHaveRead(new BasicCallback() {
      @Override
      public void gotResult(int code, String s) {
        if (code == 0) {
          result.success(true);
        } else {
          result.success(false);
        }
      }
    });
  }else {
    Log.d(TAG,"can not found this msg(msgid = "+ messageId + ")");
    result.success(false);
  }
}
 
Example #26
Source File: FlutterAudioQueryPlugin.java    From flutter_audio_query with MIT License 5 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, Result result) {

    String source = call.argument("source");
    if (source != null ){

        switch (source){
            case "artist":
                m_delegate.artistSourceHandler(call, result);
                break;

            case "album":
                m_delegate.albumSourceHandler(call, result);
                break;

            case "song":
                m_delegate.songSourceHandler(call, result);
                break;

            case "genre":
                m_delegate.genreSourceHandler(call, result);
                break;

            case "playlist":
                m_delegate.playlistSourceHandler(call, result);
                break;

            default:
                result.error("unknown_source",
                            "method call was made by an unknown source", null);
                break;

        }
    }

    else {
        result.error("no_source", "There is no source in your method call", null);
    }
}
 
Example #27
Source File: BackgroundLocationUpdatesPlugin.java    From background_location_updates with Apache License 2.0 5 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, final Result result) {
  if (call.method.equals("getPlatformVersion")) {
    result.success("Android " + android.os.Build.VERSION.RELEASE);
  } else if (call.method.equals("trackStart/android-strategy:periodic")) {
    startTrackingWithPeriodicStrategy(call, result);
  } else if (call.method.equals("trackStop/android-strategy:periodic")) {
    stopTrackingWithPeriodicStrategy();
    result.success(null);
  } else if (call.method.equals("trackStart/android-strategy:broadcast")) {
    startTrackingWithBroadcastStrategy(call);
  } else if (call.method.equals("trackStop/android-strategy:broadcast")) {
    stopTrackingWithBroadcastStrategy();
  } else if (call.method.equals("getLocationTracesCount")) {
    new CountRetriever(result, mContext).execute(CountRetriever.CountRetrievalMode.RETRIEVE_ALL);
  } else if (call.method.equals("getUnreadLocationTracesCount")) {
    new CountRetriever(result, mContext).execute(CountRetriever.CountRetrievalMode.RETRIEVE_UNREAD);
  } else if (call.method.equals("getUnreadLocationTraces")) {
    new TraceRetriever(result, mContext).execute(TraceRetriever.TraceRetrievalMode.RETRIEVE_UNREAD);
  } else if (call.method.equals("getLocationTraces")) {
    new TraceRetriever(result, mContext).execute(TraceRetriever.TraceRetrievalMode.RETRIEVE_ALL);
  } else if (call.method.equals("markAsRead")) {
    markLocationTracesAsRead(call, result);
  } else if (call.method.equals("requestPermission")) {
    requestPermission(result);
  } else if (call.method.equals("getSqliteDatabasePath")) {
    getSqliteDatabasePath(result);
  } else if ( call.method.equals("revertActiveStrategy")) {
    revertActiveUnknownStrategy();
    result.success(true);
  } else {
    result.notImplemented();
  }
}
 
Example #28
Source File: QiniucloudPushPlatformView.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 切换摄像头
 */
private void switchCamera(MethodCall call, final MethodChannel.Result result) {
    CameraStreamingSetting.CAMERA_FACING_ID id;
    if(cameraStreamingSetting.getCameraFacingId() == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT){
        id = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    }else{
        id = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    }
    cameraStreamingSetting.setCameraFacingId(id);
    result.success(manager.switchCamera(id));
}
 
Example #29
Source File: FlutterFlipperkitPlugin.java    From flutter_flipperkit with MIT License 5 votes vote down vote up
private void clientAddPlugin(MethodCall call, Result result) {
    if (call.hasArgument("id")) {
        final String pluginId = call.argument("id");
        if (pluginId == null) {
            result.error("", "", "");
            return;
        }
        // 当插件已经添加时,避免再次添加
        if (flipperClient.getPlugin(pluginId) != null) {
            result.success(true);
            return;
        }
        switch (pluginId) {
            case NetworkFlipperPlugin.ID:
                flipperClient.addPlugin(networkFlipperPlugin);
                break;
            case "Preferences":
                flipperClient.addPlugin(sharedPreferencesFlipperPlugin);
                break;
            case FlipperDatabaseBrowserPlugin.ID:
                flipperClient.addPlugin(flipperDatabaseBrowserPlugin);
                break;
            case FlipperReduxInspectorPlugin.ID:
                flipperClient.addPlugin(flipperReduxInspectorPlugin);
                break;
        }
    }

    result.success(true);
}
 
Example #30
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 5 votes vote down vote up
private void setConversationExtras(MethodCall call, Result result) {
  HashMap<String, Object> map = call.arguments();
  Conversation conversation;
  JSONObject extra = null;

  try {
    JSONObject params = new JSONObject(map);
    conversation = JMessageUtils.getConversation(params);

    if (conversation == null) {
      handleResult(ERR_CODE_CONVERSATION, ERR_MSG_CONVERSATION, result);
      return;
    }

    if (params.has("extras")) {
      extra = params.getJSONObject("extras");
    }
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }

  String extraStr = extra == null ? "" : extra.toString();
  conversation.updateConversationExtra(extraStr);
  handleResult(toJson(conversation), 0, null, result);
}