io.flutter.plugin.common.MethodChannel.Result Java Examples

The following examples show how to use io.flutter.plugin.common.MethodChannel.Result. 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 groupPendencyRefuse(MethodCall methodCall, final Result result) {
    // 理由
    final String msg = methodCall.argument("msg");
    // 群ID
    final String groupId = this.getParam(methodCall, result, "groupId");
    // 申请人ID
    final String identifier = this.getParam(methodCall, result, "identifier");
    // 申请时间
    final long addTime = Long.parseLong(this.getParam(methodCall, result, "addTime").toString());

    TIMGroupManager.getInstance().getGroupPendencyList(new TIMGroupPendencyGetParam(), new ValueCallBack<TIMGroupPendencyListGetSucc>(result) {
        @Override
        public void onSuccess(TIMGroupPendencyListGetSucc timGroupPendencyListGetSucc) {
            List<TIMGroupPendencyItem> data = timGroupPendencyListGetSucc.getPendencies();
            if (data != null) {
                for (TIMGroupPendencyItem datum : data) {
                    if (datum.getGroupId().equals(groupId) && datum.getIdentifer().equals(identifier) && datum.getAddTime() == addTime) {
                        datum.refuse(msg, new VoidCallBack(result));
                        break;
                    }
                }
            }
        }
    });
}
 
Example #2
Source File: TencentImPlugin.java    From FlutterTencentImPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * 腾讯云 未决审核
 *
 * @param methodCall 方法调用对象
 * @param result     返回结果对象
 */
private void examinePendency(MethodCall methodCall, final Result result) {
    // 类型
    int type = this.getParam(methodCall, result, "type");
    // 用户Id
    String id = this.getParam(methodCall, result, "id");
    // 好友备注
    String remark = methodCall.argument("remark");

    // 未决审核
    TIMFriendResponse response = new TIMFriendResponse();
    response.setIdentifier(id);
    response.setResponseType(type);
    response.setRemark(remark);
    TIMFriendshipManager.getInstance().doResponse(response, new ValueCallBack<TIMFriendResult>(result));
}
 
Example #3
Source File: TflitePlugin.java    From flutter_tflite with MIT License 6 votes vote down vote up
void runPoseNetOnFrame(HashMap args, Result result) throws IOException {
  List<byte[]> bytesList = (ArrayList) args.get("bytesList");
  double mean = (double) (args.get("imageMean"));
  float IMAGE_MEAN = (float) mean;
  double std = (double) (args.get("imageStd"));
  float IMAGE_STD = (float) std;
  int imageHeight = (int) (args.get("imageHeight"));
  int imageWidth = (int) (args.get("imageWidth"));
  int rotation = (int) (args.get("rotation"));
  int numResults = (int) args.get("numResults");
  double threshold = (double) args.get("threshold");
  int nmsRadius = (int) args.get("nmsRadius");

  ByteBuffer imgData = feedInputTensorFrame(bytesList, imageHeight, imageWidth, IMAGE_MEAN, IMAGE_STD, rotation);

  new RunPoseNet(args, imgData, numResults, threshold, nmsRadius, result).executeTfliteTask();
}
 
Example #4
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void sendCustomMessage(MethodCall call, Result result) {
  HashMap<String, Object> map = call.arguments();
  try {
    JSONObject params = new JSONObject(map);
    Conversation conversation = JMessageUtils.createConversation(params);
    if (conversation == null) {
      handleResult(ERR_CODE_CONVERSATION, ERR_MSG_CONVERSATION, result);
      return;
    }

    JSONObject customObject = params.getJSONObject("customObject");

    MessageSendingOptions options = null;
    if (params.has("messageSendingOptions")) {
      options = toMessageSendingOptions(params.getJSONObject("messageSendingOptions"));
    }

    CustomContent content = new CustomContent();
    content.setAllValues(fromJson(customObject));
    sendMessage(conversation, content, options, result);
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }
}
 
Example #5
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void applyJoinGroup(MethodCall call, final Result result) {
  HashMap<String, Object> map = call.arguments();
  String reason;
  long groupId;
  try {
    JSONObject params = new JSONObject(map);
    groupId = Long.parseLong(params.getString("groupId"));
    reason = params.getString("reason");
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }
  JMessageClient.applyJoinGroup(groupId, reason, new BasicCallback() {
    @Override
    public void gotResult(int status, String desc) {
      handleResult(status, desc, result);
    }
  });
}
 
Example #6
Source File: FlutterUmplusPlugin.java    From flutter_umplus with MIT License 6 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, Result result) {
  if (call.method.equals("getPlatformVersion")) {
    result.success("Android " + android.os.Build.VERSION.RELEASE);
  } else if (call.method.equals("init")) {
    initSetup(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("logPageView")) {
    logPageView(call, result);
  } else if (call.method.equals("event")) {
    event(call, result);
  } else {
    result.notImplemented();
  }
}
 
Example #7
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 #8
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 #9
Source File: ChatroomHandler.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
static void exitChatRoom(JSONObject data, final Result callback) {
    final long roomId;

    try {
        roomId = Long.parseLong(data.getString("roomId"));
    } catch (JSONException e) {
        e.printStackTrace();
        handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, callback);
        return;
    }

    ChatRoomManager.leaveChatRoom(roomId, new BasicCallback() {
        @Override
        public void gotResult(int status, String desc) {
            if (status == 0) { // success
                callback.success(null);
            } else {
                handleResult(status, desc, callback);
            }
        }
    });
}
 
Example #10
Source File: MethodCallHandlerImpl.java    From flutter-zendesk with MIT License 6 votes vote down vote up
@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
  switch (call.method) {
    case "init":
      handleInit(call, result);
      break;
    case "setVisitorInfo":
      handleSetVisitorInfo(call, result);
      break;
    case "startChat":
      handleStartChat(call, result);
      break;
    case "version":
      handleVersion(result);
      break;
    default:
      result.notImplemented();
      break;
  }
}
 
Example #11
Source File: JMessageUtils.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
static void sendMessage(Conversation conversation, MessageContent content, MessageSendingOptions options,
        final Result callback) {
    final Message msg = conversation.createSendMessage(content);
    msg.setOnSendCompleteCallback(new BasicCallback() {
        @Override
        public void gotResult(int status, String desc) {
            if (status == 0) {
                HashMap json = JsonUtils.toJson(msg);
                handleResult(json, status, desc, callback);
            } else {
                handleResult(status, desc, callback);
            }
        }
    });

    if (options == null) {
        JMessageClient.sendMessage(msg);
    } else {
        JMessageClient.sendMessage(msg, options);
    }
}
 
Example #12
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void acceptInvitation(MethodCall call, final Result result) {

    HashMap<String, Object> map = call.arguments();
    String username, appKey;
    try {
      JSONObject params = new JSONObject(map);
      username = params.getString("username");
      appKey = params.has("appKey") ? params.getString("appKey") : JmessageFlutterPlugin.appKey;

    } catch (JSONException e) {
      e.printStackTrace();
      handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
      return;
    }

    ContactManager.acceptInvitation(username, appKey, new BasicCallback() {

      @Override
      public void gotResult(int status, String desc) {
        handleResult(status, desc, result);
      }
    });
  }
 
Example #13
Source File: TflitePlugin.java    From flutter_tflite with MIT License 6 votes vote down vote up
RunSegmentationOnImage(HashMap args, Result result) throws IOException {
  super(args, result);

  String path = args.get("path").toString();
  double mean = (double) (args.get("imageMean"));
  float IMAGE_MEAN = (float) mean;
  double std = (double) (args.get("imageStd"));
  float IMAGE_STD = (float) std;

  labelColors = (ArrayList) args.get("labelColors");
  outputType = args.get("outputType").toString();

  startTime = SystemClock.uptimeMillis();
  input = feedInputTensorImage(path, IMAGE_MEAN, IMAGE_STD);
  output = ByteBuffer.allocateDirect(tfLite.getOutputTensor(0).numBytes());
  output.order(ByteOrder.nativeOrder());
}
 
Example #14
Source File: ImageJpegPlugin.java    From image_jpeg with MIT License 6 votes vote down vote up
public void getImgInfo(Result successResult, Resources res, int resId) {
  HashMap map = new HashMap();
  map.put("resId", resId);
  try {
    if (resId != 0) {
      final BitmapFactory.Options options = new BitmapFactory.Options();
      options.inJustDecodeBounds = true;
      AssetFileDescriptor af = res.openRawResourceFd(resId);
      map.put("size", af.getLength());
      af.close();
      InputStream is = res.openRawResource(resId);
      BitmapFactory.decodeStream(is, null, options);
      is.close();
      map.put("width", options.outWidth);
      map.put("height", options.outHeight);
    } else {
      map.put("error", "resources doesn't exist");
    }
    successResult.success(map);
  } catch (Exception e) {
    map.put("error", e.getMessage());
    successResult.success(map);
  }
}
 
Example #15
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void getGroupMembers(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.getGroupMembers(groupId, new RequestCallback<List<GroupMemberInfo>>() {
    @Override
    public void gotResult(int status, String desc, List<GroupMemberInfo> groupMemberInfos) {
      if (status == 0) {
        handleResult(toJson(groupMemberInfos), status, desc, result);

      } else {
        handleResult(status, desc, result);
      }
    }
  });
}
 
Example #16
Source File: TflitePlugin.java    From flutter_tflite with MIT License 6 votes vote down vote up
RunPix2PixOnImage(HashMap args, Result result) throws IOException {
  super(args, result);
  path = args.get("path").toString();
  double mean = (double) (args.get("imageMean"));
  IMAGE_MEAN = (float) mean;
  double std = (double) (args.get("imageStd"));
  IMAGE_STD = (float) std;

  outputType = args.get("outputType").toString();
  startTime = SystemClock.uptimeMillis();
  input = feedInputTensorImage(path, IMAGE_MEAN, IMAGE_STD);
  output = ByteBuffer.allocateDirect(input.limit());
  output.order(ByteOrder.nativeOrder());
  if (input.limit() == 0) {
    result.error("Unexpected input position, bad file?", null, null);
    return;
  }
  if (output.position() != 0) {
    result.error("Unexpected output position", null, null);
    return;
  }
}
 
Example #17
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);
}
 
Example #18
Source File: AdvCameraPlugin.java    From adv_camera with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, final Result result) {
    if (call.method.equals("checkForPermission")) {
        checkForPermission(result);
    } else {
        result.notImplemented();
    }
}
 
Example #19
Source File: FlutterYoutubePlugin.java    From FlutterYoutube with Apache License 2.0 5 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, Result result) {

  if (call.method.equals("playYoutubeVideo")) {
    String apiKey = call.argument("api");
    String videoId = call.argument("id");
    boolean autoPlay = call.argument("autoPlay");
    boolean fullScreen = call.argument("fullScreen");
    boolean appBarVisible = call.argument("appBarVisible");
    Long appBarColor = call.argument("appBarColor");
    Long backgroundColor = call.argument("backgroundColor");


    Intent playerIntent = new Intent(activity, PlayerActivity.class);
    playerIntent.putExtra("api", apiKey);
    playerIntent.putExtra("videoId", videoId);
    playerIntent.putExtra("autoPlay", autoPlay);
    playerIntent.putExtra("fullScreen", fullScreen);
    playerIntent.putExtra("appBarVisible", appBarVisible);
    playerIntent.putExtra("appBarColor", appBarColor.intValue());
    playerIntent.putExtra("backgroundColor", backgroundColor.intValue());

    activity.startActivityForResult(playerIntent, YOUTUBE_PLAYER_RESULT);

  } else {
    result.notImplemented();
  }
}
 
Example #20
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 5 votes vote down vote up
private void downloadVoiceFile(MethodCall call, final Result result) {
  HashMap<String, Object> map = call.arguments();
  final Message msg;
  try {
    JSONObject params = new JSONObject(map);
    msg = JMessageUtils.getMessage(params);
    if (msg == null) {
      handleResult(ERR_CODE_MESSAGE, ERR_MSG_MESSAGE, result);
      return;
    }
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }

  if (msg.getContentType() != ContentType.voice) {
    handleResult(ERR_CODE_MESSAGE, "Message type isn't voice", result);
    return;
  }

  VoiceContent content = (VoiceContent) msg.getContent();
  content.downloadVoiceFile(msg, new DownloadCompletionCallback() {

    @Override
    public void onComplete(int status, String desc, File file) {
      if (status == 0) {
        HashMap res= new HashMap();
        res.put("messageId", msg.getId());
        res.put("filePath", file.getAbsolutePath());
        handleResult(res, status, desc, result);

      } else {
        handleResult(status, desc, result);
      }
    }
  });
}
 
Example #21
Source File: Request.java    From play_games with MIT License 5 votes vote down vote up
public Request(PlayGamesPlugin pluginRef, GoogleSignInAccount currentAccount, Registrar registrar, MethodCall call, Result result) {
    this.pluginRef = pluginRef;
    this.currentAccount = currentAccount;
    this.registrar = registrar;
    this.call = call;
    this.result = result;
}
 
Example #22
Source File: FlutterUmengAnalyticsPlugin.java    From flutter_umeng_analytics with MIT License 5 votes vote down vote up
public void init(MethodCall call, Result result) {
    // 设置组件化的Log开关,参数默认为false,如需查看LOG设置为true
    UMConfigure.setLogEnabled(true);
    /**
     * 初始化common库 参数1:上下文,不能为空 参数2:【友盟+】Appkey名称 参数3:【友盟+】Channel名称
     * 参数4:设备类型,UMConfigure.DEVICE_TYPE_PHONE为手机、UMConfigure.DEVICE_TYPE_BOX为盒子,默认为手机
     * 参数5:Push推送业务的secret
     */
    UMConfigure.init(activity, (String) call.argument("key"), "Umeng", UMConfigure.DEVICE_TYPE_PHONE, null);
    // 设置日志加密 参数:boolean 默认为false(不加密)
    UMConfigure.setEncryptEnabled((Boolean) call.argument("encrypt"));

    double interval = call.argument("interval");
    if (call.argument("interval") != null) {
        // Session间隔时长,单位是毫秒,默认Session间隔时间是30秒,一般情况下不用修改此值
        MobclickAgent.setSessionContinueMillis(Double.valueOf(interval).longValue());
    } else {
        // Session间隔时长,单位是毫秒,默认Session间隔时间是30秒,一般情况下不用修改此值
        MobclickAgent.setSessionContinueMillis(30000L);
    }


    // true表示打开错误统计功能,false表示关闭 默认为打开
    MobclickAgent.setCatchUncaughtExceptions((Boolean) call.argument("reportCrash"));

    // 页面采集的两种模式:AUTO和MANUAL,Android 4.0及以上版本使用AUTO,4.0以下使用MANUAL
    int results = call.argument("mode");
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (results == 0) {
            // 大于等于4.4选用AUTO页面采集模式
            MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
        }
    } else if (results == 1) {
        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.MANUAL);
    }
    result.success(true);
}
 
Example #23
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 5 votes vote down vote up
private void retractMessage(MethodCall call, final Result result) {
  Log.d("Android","retractMessage:" + 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("messageId");
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }

  Message msg = conversation.getMessage(Long.parseLong(messageId));
  conversation.retractMessage(msg, new BasicCallback() {
    @Override
    public void gotResult(int status, String desc) {
      handleResult(status, desc, result);
    }
  });
}
 
Example #24
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 5 votes vote down vote up
private void getChatRoomConversation(MethodCall call, Result result) {
  HashMap<String, Object> map = call.arguments();
  long chatRoomId;
  try {
    JSONObject params = new JSONObject(map);
    chatRoomId = Long.parseLong(params.getString("roomId"));
    Conversation conversation = JMessageClient.getChatRoomConversation(chatRoomId);
    result.success(toJson(conversation));
  } catch (Exception e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
  }

}
 
Example #25
Source File: TencentImPlugin.java    From FlutterTencentImPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 腾讯云 删除消息
 *
 * @param methodCall 方法调用对象
 * @param result     返回结果对象
 */
private void removeMessage(MethodCall methodCall, final Result result) {
    // 获得消息后删除
    TencentImUtils.getTimMessage(methodCall, result, new ValueCallBack<TIMMessage>(result) {
        @Override
        public void onSuccess(TIMMessage message) {
            result.success(message.remove());
        }
    });
}
 
Example #26
Source File: ContactsServicePlugin.java    From flutter_contacts with MIT License 5 votes vote down vote up
@Override
public void onMethodCall(MethodCall call, Result result) {
  switch(call.method){
    case "getContacts":
      this.getContacts((String)call.argument("query"), (boolean)call.argument("withThumbnails"), (boolean)call.argument("photoHighResolution"), result);
      break;
    case "getContactsForPhone":
      this.getContactsForPhone((String)call.argument("phone"), (boolean)call.argument("withThumbnails"), (boolean)call.argument("photoHighResolution"), result);
      break;
    case "addContact":
      Contact c = Contact.fromMap((HashMap)call.arguments);
      if(this.addContact(c)) {
        result.success(null);
      } else{
        result.error(null, "Failed to add the contact", null);
      }
      break;
    case "deleteContact":
      Contact ct = Contact.fromMap((HashMap)call.arguments);
      if(this.deleteContact(ct)){
        result.success(null);
      } else{
        result.error(null, "Failed to delete the contact, make sure it has a valid identifier", null);
      }
      break;
    case "updateContact":
      Contact ct1 = Contact.fromMap((HashMap)call.arguments);
      if(this.updateContact(ct1)) {
        result.success(null);
      } else {
        result.error(null, "Failed to update the contact, make sure it has a valid identifier", null);
      }
      break;
    default:
      result.notImplemented();
      break;
  }
}
 
Example #27
Source File: FlutterUmplusPlugin.java    From flutter_umplus with MIT License 5 votes vote down vote up
private void initSetup(MethodCall call, Result result) {
    String appKey = (String)call.argument("key");
    String channel = (String)call.argument("channel");
    Boolean logEnable = (Boolean)call.argument("logEnable");
    Boolean encrypt = (Boolean)call.argument("encrypt");
    Boolean reportCrash = (Boolean)call.argument("reportCrash");

    Log.d("UM", "initSetup: " + appKey);
//    Log.d("UM", "channel: " +  getMetadata(activity, "INSTALL_CHANNEL"));

    UMConfigure.setLogEnabled(logEnable);
    UMConfigure.init(activity, appKey, channel, UMConfigure.DEVICE_TYPE_PHONE,
                     null);
    UMConfigure.setEncryptEnabled(encrypt);

    MobclickAgent.setSessionContinueMillis(30000L);
    MobclickAgent.setCatchUncaughtExceptions(reportCrash);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      // 大于等于4.4选用AUTO页面采集模式
      MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
    } else {
      MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.MANUAL);
    }


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


  MessageSendingOptions messageSendingOptions = null;
  Conversation conversation;

  try {
    JSONObject params = new JSONObject(map);
    conversation = JMessageUtils.createConversation(params);
    final Message message = conversation.getMessage(Integer.parseInt(params.getString("id")));

    if (params.has("messageSendingOptions")) {
      messageSendingOptions = toMessageSendingOptions(params.getJSONObject("messageSendingOptions"));
    }

    message.setOnSendCompleteCallback(new BasicCallback() {
      @Override
      public void gotResult(int status, String desc) {
        if (status == 0) {
          HashMap json = JsonUtils.toJson(message);
          handleResult(json, status, desc, result);
        } else {
          handleResult(status, desc, result);
        }
      }
    });

    if (messageSendingOptions == null) {
      JMessageClient.sendMessage(message);
    } else {
      JMessageClient.sendMessage(message, messageSendingOptions);
    }

  } catch (Exception e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }
}
 
Example #29
Source File: ChatroomHandler.java    From jmessage-flutter-plugin with MIT License 5 votes vote down vote up
static void getChatRoomInfoListOfApp(JSONObject data, final Result callback) {
    int start, count;
    try {

        start = data.getInt("start");
        count = data.getInt("count");
    } catch (JSONException e) {
        e.printStackTrace();
        handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, callback);
        return;
    }

    ChatRoomManager.getChatRoomListByApp(start, count, new RequestCallback<List<ChatRoomInfo>>() {
        @Override
        public void gotResult(int status, String desc, List<ChatRoomInfo> chatRoomInfos) {
            if (status != 0) {
                handleResult(status, desc, callback);
                return;
            }

            ArrayList jsonArr = new ArrayList();
            for (ChatRoomInfo chatroomInfo : chatRoomInfos) {
                jsonArr.add(toJson(chatroomInfo));
            }
            callback.success(jsonArr);
        }
    });
}
 
Example #30
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 5 votes vote down vote up
private void getGroupInfo(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.getGroupInfo(groupId, new GetGroupInfoCallback() {
      @Override
      public void gotResult(int status, String desc, GroupInfo groupInfo) {
        if (status == 0) {
          handleResult(toJson(groupInfo), status, desc, result);
        } else {
          handleResult(status, desc, result);
        }
      }
    });
  }