Java Code Examples for io.flutter.plugin.common.MethodCall#hasArgument()

The following examples show how to use io.flutter.plugin.common.MethodCall#hasArgument() . 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: MethodCallHandlerImpl.java    From flutter-zendesk with MIT License 6 votes vote down vote up
private void handleSetVisitorInfo(MethodCall call, Result result) {
  VisitorInfo.Builder builder = new VisitorInfo.Builder();
  if (call.hasArgument("name")) {
    builder = builder.name((String) call.argument("name"));
  }
  if (call.hasArgument("email")) {
    builder = builder.email((String) call.argument("email"));
  }
  if (call.hasArgument("phoneNumber")) {
    builder = builder.phoneNumber((String) call.argument("phoneNumber"));
  }
  if (call.hasArgument("note")) {
    builder = builder.note((String) call.argument("note"));
  }
  ZopimChat.setVisitorInfo(builder.build());
  result.success(true);
}
 
Example 2
Source File: ContactPhotoQuery.java    From flutter_sms with MIT License 6 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, MethodChannel.Result result) {
    if (!call.method.equals("getContactPhoto")) {
        result.notImplemented();
        return;
    }
    if (!call.hasArgument("photoUri")) {
        result.error("#02", "missing argument 'photoUri'", null);
        return;
    }
  String photoUri = call.argument("photoUri");
    boolean fullSize = call.hasArgument("fullSize") && (boolean) call.argument("fullSize");
  ContactPhotoQueryHandler handler = new ContactPhotoQueryHandler(registrar, result, photoUri, fullSize);
  this.registrar.addRequestPermissionsResultListener(handler);
  handler.handle(permissions);
}
 
Example 3
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 4
Source File: MethodCallHandlerImpl.java    From flutter-zendesk with MIT License 5 votes vote down vote up
private void handleInit(MethodCall call, Result result) {
  ZopimChat.DefaultConfig zopimConfig = ZopimChat.init((String) call.argument("accountKey"));
  if (call.hasArgument("department")) {
    zopimConfig.department((String) call.argument("department"));
  }
  if (call.hasArgument("appName")) {
    zopimConfig.visitorPathOne((String) call.argument("appName"));
  }

  result.success(true);
}
 
Example 5
Source File: ContactQuery.java    From flutter_sms with MIT License 5 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, MethodChannel.Result result) {
    if (!call.method.equals("getContact")) {
        result.notImplemented();
    } else if (!call.hasArgument("address")) {
        result.error("#02", "missing argument 'address'", null);
    } else {
        String contactAddress = call.argument("address");
        ContactQueryHandler handler = new ContactQueryHandler(registrar, result, contactAddress);
        this.registrar.addRequestPermissionsResultListener(handler);
        handler.handle(permissions);
    }
}
 
Example 6
Source File: SmsQuery.java    From flutter_sms with MIT License 5 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, Result result) {
  int start = 0;
  int count = -1;
  int threadId = -1;
  String address = null;
  SmsQueryRequest request;
  switch (call.method) {
    case "getInbox":
      request = SmsQueryRequest.Inbox;
      break;
    case "getSent":
      request = SmsQueryRequest.Sent;
      break;
    case "getDraft":
      request = SmsQueryRequest.Draft;
      break;
    default:
      result.notImplemented();
      return;
  }
  if (call.hasArgument("start")) {
    start = call.argument("start");
  }
  if (call.hasArgument("count")) {
    count = call.argument("count");
  }
  if (call.hasArgument("thread_id")) {
    threadId = call.argument("thread_id");
  }
  if (call.hasArgument("address")) {
    address = call.argument("address");
  }
  SmsQueryHandler handler = new SmsQueryHandler(registrar, result, request, start, count, threadId, address);
  this.registrar.addRequestPermissionsResultListener(handler);
  handler.handle(permissions);
}
 
Example 7
Source File: FlutterImagePickCropPlugin.java    From FlutterImagePickCrop with Apache License 2.0 5 votes vote down vote up
private void checkRequestResult(MethodCall call) {
    if (call.hasArgument(PICK_OPTIONS)) {
        String options = call.argument(PICK_OPTIONS).toString();

        //Toast.makeText(activity, "Option Received", Toast.LENGTH_SHORT).show();

        if (options.equals(REQUEST_FOR_CAMERA)) {
            openPickupFromCamera();
        } else if (options.equals(REQUEST_FOR_GALLERY)) {
            openPickupFromGallery();
        }
    }
}
 
Example 8
Source File: OpenFilePlugin.java    From open_file with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
@SuppressLint("NewApi")
public void onMethodCall(MethodCall call, @NonNull Result result) {
    isResultSubmitted = false;
    if (call.method.equals("open_file")) {
        filePath = call.argument("file_path");
        this.result = result;

        if (call.hasArgument("type") && call.argument("type") != null) {
            typeString = call.argument("type");
        } else {
            typeString = getFileType(filePath);
        }
        if (pathRequiresPermission()) {
            if (hasPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) {
                if (TYPE_STRING_APK.equals(typeString)) {
                    openApkFile();
                    return;
                }
                startActivity();
            } else {
                ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_CODE);
            }
        } else {
            startActivity();
        }
    } else {
        result.notImplemented();
        isResultSubmitted = true;
    }
}
 
Example 9
Source File: FlutterMultipleImagePickerPlugin.java    From FlutterMulti-ImagePicker with Apache License 2.0 5 votes vote down vote up
private void openMulti_ImagePicker(MethodCall call){

        if (call.hasArgument(MAX_IMAGES) && call.hasArgument(IS_SINGLE)) {
            int maxImages = call.argument(MAX_IMAGES);
            boolean isSingle = call.argument(IS_SINGLE);

            if(maxImages == 0){
                finishWithError("Max_Images","Please images cannot be 0");
                return;
            }

            GalleryConfig config = new GalleryConfig.Build()
                    .limitPickPhoto(maxImages)
                    .singlePhoto(isSingle)
                    .hintOfPick("Selected Maximum no of images")
                    .filterMimeTypes(new String[]{"image/jpeg"})
                    .build();
            GalleryActivity.openActivity(activity, PICK_MULTI_IMAGES, config);
        }else {
            finishWithError("Max_Images & Single_Photo","Please images cannot be set to 0.. ");

        }




    }