cn.jpush.im.android.api.JMessageClient Java Examples

The following examples show how to use cn.jpush.im.android.api.JMessageClient. 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: MsgListAdapter.java    From jmessage-android-uikit with MIT License 6 votes vote down vote up
private void resendTextOrVoice(final ViewHolder holder, Message msg) {
    holder.resend.setVisibility(View.GONE);
    holder.sendingIv.setVisibility(View.VISIBLE);
    holder.sendingIv.startAnimation(mSendingAnim);

    if (!msg.isSendCompleteCallbackExists()) {
        msg.setOnSendCompleteCallback(new BasicCallback() {
            @Override
            public void gotResult(final int status, String desc) {
                holder.sendingIv.clearAnimation();
                holder.sendingIv.setVisibility(View.GONE);
                if (status != 0) {
                    HandleResponseCode.onHandle(mContext, status, false);
                    holder.resend.setVisibility(View.VISIBLE);
                    Log.i(TAG, "Resend message failed!");
                }
            }
        });
    }

    JMessageClient.sendMessage(msg);
}
 
Example #2
Source File: NotFriendSettingActivity.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_not_friend_setting);

    mBtn_addBlackList = (SlipButton) findViewById(R.id.btn_addBlackList);
    mUserName = getIntent().getStringExtra("notFriendUserName");
    mBtn_addBlackList.setOnChangedListener(R.id.btn_addBlackList, this);
    JMessageClient.getUserInfo(mUserName, new GetUserInfoCallback() {
        @Override
        public void gotResult(int i, String s, UserInfo userInfo) {
            if (i == 0) {
                mUserInfo = userInfo;
                mBtn_addBlackList.setChecked(userInfo.getBlacklist() == 1);
            }
        }
    });
}
 
Example #3
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void updateMyAvatar(MethodCall call, final Result result) {
  HashMap<String, Object> map = call.arguments();
  try {
    JSONObject params = new JSONObject(map);
    if (!params.has("imgPath")) {
      handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
      return;
    }

    String imgPath = params.getString("imgPath");
    File img = new File(imgPath);
    String format = imgPath.substring(imgPath.lastIndexOf(".") + 1);
    JMessageClient.updateUserAvatar(img, format, 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 #4
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void updateMyPassword(MethodCall call, final Result result) {
  HashMap<String, Object> map = call.arguments();
  String oldPwd, newPwd;
  try {
    JSONObject params = new JSONObject(map);
    oldPwd = params.getString("oldPwd");
    newPwd = params.getString("newPwd");
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }

  JMessageClient.updateUserPassword(oldPwd, newPwd, new BasicCallback() {
    @Override
    public void gotResult(int status, String desc) {
      handleResult(status, desc, result);
    }
  });
}
 
Example #5
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 #6
Source File: ChatActivity.java    From jmessage-android-uikit with MIT License 6 votes vote down vote up
@Override
protected void onResume() {
    if (!RecordVoiceButton.mIsPressed) {
        mChatView.dismissRecordDialog();
    }
    String targetId = getIntent().getStringExtra(TARGET_ID);
    if (!mIsSingle) {
        long groupId = getIntent().getLongExtra(GROUP_ID, 0);
        if (groupId != 0) {
            JMessageClient.enterGroupConversation(groupId);
        }
    } else if (null != targetId) {
        String appKey = getIntent().getStringExtra(TARGET_APP_KEY);
        JMessageClient.enterSingleConversation(targetId, appKey);
    }
    mChatAdapter.initMediaPlayer();
    Log.i(TAG, "[Life cycle] - onResume");
    super.onResume();
}
 
Example #7
Source File: GroupDetailActivity.java    From jmessage-android-uikit with MIT License 6 votes vote down vote up
private void getUserInfo(final String targetId, final Dialog dialog){
    JMessageClient.getUserInfo(targetId, new GetUserInfoCallback() {
        @Override
        public void gotResult(final int status, String desc, final UserInfo userInfo) {
            if (mLoadingDialog != null) {
                mLoadingDialog.dismiss();
            }
            if (status == 0) {
                addAMember(userInfo);
                dialog.cancel();
            } else {
                HandleResponseCode.onHandle(mContext, status, true);
            }
        }
    });
}
 
Example #8
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void userRegister(MethodCall call, final Result result) {
  HashMap<String, Object> map = call.arguments();
  String username, password;
  RegisterOptionalUserInfo optionalUserInfo = new RegisterOptionalUserInfo();
  try {
    JSONObject params = new JSONObject(map);
    username = params.getString("username");
    password = params.getString("password");

    if (params.has("nickname"))
      optionalUserInfo.setNickname(params.getString("nickname"));
  } catch (JSONException e) {
    e.printStackTrace();
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
    return;
  }
  Log.d("Android","Action - userRegister: username=" + username + ",pw=" + password);

  JMessageClient.register(username, password, optionalUserInfo, new BasicCallback() {
    @Override
    public void gotResult(int status, String desc) {
      handleResult(status, desc, result);
    }
  });
}
 
Example #9
Source File: MessageFragment.java    From Android-IM with Apache License 2.0 6 votes vote down vote up
public void onEvent(final MessageEvent event) {
        final Message msg = event.getMessage();
        this.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
//                Log.e("Log:新消息", "消息啊" + msg.getContentType().name() + "\n" + msg);

                if (JMessageClient.getMyInfo().getUserName() == "1006" || JMessageClient.getMyInfo().getUserName().equals("1006")) {

                    final Message message1 =
                            JMessageClient.createSingleTextMessage(((UserInfo)msg.getTargetInfo()).getUserName(), SharedPrefHelper.getInstance().getAppKey(), "[自动回复]你好,我是机器人");
//                    for (int i=0;i<list.size();i++){
//                        conversation = list.get(i);
//                        Message message=conversation.createSendMessage(new TextContent("[自动回复]你好,我是机器人"));
                        JMessageClient.sendMessage(message1);
//                    }
                }
                updataData();

            }
        });

    }
 
Example #10
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void updateGroupInfo(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);
      }
    }
  });
}
 
Example #11
Source File: MainActivity.java    From Android-IM with Apache License 2.0 6 votes vote down vote up
private void initNVHeader() {
//        mMainNv.setItemTextColor(getResources().getColorStateList(R.drawable.nav_select_tv,null));
        mMainNv.setItemIconTintList(null);
        View headerView = mMainNv.getHeaderView(0);
        nav_header_ll = (LinearLayout) headerView.findViewById(R.id.nav_header_ll);
        nav_header_name = (TextView) headerView.findViewById(R.id.nav_header_name);
        nav_header_name.setText(JMessageClient.getMyInfo().getNickname());
        nav_header_id = (TextView) headerView.findViewById(R.id.nav_header_id);
        nav_header_id.setText("ID:  " + helper.getUserId());
        nav_header_img = (ImageView) headerView.findViewById(R.id.nav_header_img);
        Picasso.with(MainActivity.this)
                .load(JMessageClient.getMyInfo().getAvatarFile())
                .placeholder(R.mipmap.icon_user)
                .into(nav_header_img);
        nav_header_ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, UserActivty.class);
                startActivity(intent);
            }
        });

    }
 
Example #12
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 #13
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 #14
Source File: BaseActivity.java    From Android-IM with Apache License 2.0 6 votes vote down vote up
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        BarUtils.setNavBarImmersive(this);
//        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
//            try {
//                Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView");
//                Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor");
//                field.setAccessible(true);
//                field.setInt(getWindow().getDecorView(), Color.TRANSPARENT);  //改为透明
//            } catch (Exception e) {}
//        }
        setContentView(rootContentView());
        ButterKnife.bind(this);
        new SystemStatusManager(this).setTranslucentStatus(R.drawable.shape_titlebar);
        JMessageClient.registerEventReceiver(this);
        mContext = BaseActivity.this;
        helper=SharedPrefHelper.getInstance();
        initView();
        initData();
    }
 
Example #15
Source File: ChattingListAdapter.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 从发送队列中出列,并发送图片
 *
 * @param msg 图片消息
 */
private void sendNextImgMsg(Message msg) {
    MessageSendingOptions options = new MessageSendingOptions();
    options.setNeedReadReceipt(mNeedReadReceipt);
    JMessageClient.sendMessage(msg, options);
    msg.setOnSendCompleteCallback(new BasicCallback() {
        @Override
        public void gotResult(int i, String s) {
            //出列
            mMsgQueue.poll();
            //如果队列不为空,则继续发送下一张
            if (!mMsgQueue.isEmpty()) {
                sendNextImgMsg(mMsgQueue.element());
            }
            notifyDataSetChanged();
        }
    });
}
 
Example #16
Source File: MsgListAdapter.java    From jmessage-android-uikit with MIT License 6 votes vote down vote up
/**
 * 从发送队列中出列,并发送图片
 *
 * @param msg 图片消息
 */
private void sendNextImgMsg(Message msg) {
    JMessageClient.sendMessage(msg);
    msg.setOnSendCompleteCallback(new BasicCallback() {
        @Override
        public void gotResult(int i, String s) {
            //出列
            mMsgQueue.poll();
            //如果队列不为空,则继续发送下一张
            if (!mMsgQueue.isEmpty()) {
                sendNextImgMsg(mMsgQueue.element());
            }
            notifyDataSetChanged();
        }
    });
}
 
Example #17
Source File: BaseActivity.java    From jmessage-android-uikit with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    JMessageClient.init(this);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    //订阅接收消息,子类只要重写onEvent就能收到
    JMessageClient.registerEventReceiver(this);
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    mDensity = dm.density;
    mDensityDpi = dm.densityDpi;
    mWidth = dm.widthPixels;
    mHeight = dm.heightPixels;
    mAvatarSize = (int) (50 * mDensity);
}
 
Example #18
Source File: PassWordActivity.java    From Android-IM with Apache License 2.0 6 votes vote down vote up
@OnClick({R.id.title_bar_back, R.id.password_ok})
public void onViewClicked(View view) {
    switch (view.getId()) {
        case R.id.title_bar_back:
            finish();
            break;
        case R.id.password_ok:
            if (mPasswordNew.getText().toString().equals(mPasswordNew2.getText().toString())) {
                JMessageClient.updateUserPassword(mPasswordOld.getText().toString(), mPasswordNew2.getText().toString(), new BasicCallback() {
                    @Override
                    public void gotResult(int i, String s) {
                        if (i == 0) {
                            showToast(PassWordActivity.this, "修改成功");
                            startActivity(new Intent(PassWordActivity.this, LoginActivity.class));
                        } else {
                            showLongToast(PassWordActivity.this, "修改失败:" + s);
                        }
                    }
                });
            } else {
                showToast(PassWordActivity.this, "两次输入的密码不一致");
            }
            break;
    }
}
 
Example #19
Source File: ChatDetailController.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @param userInfo 要增加的成员的用户名,目前一次只能增加一个
 */
private void addAMember(final UserInfo userInfo) {
    mLoadingDialog = DialogCreator.createLoadingDialog(mContext,
            mContext.getString(R.string.adding_hint));
    mLoadingDialog.show();
    ArrayList<String> list = new ArrayList<String>();
    list.add(userInfo.getUserName());
    JMessageClient.addGroupMembers(mGroupId, list, new BasicCallback() {

        @Override
        public void gotResult(final int status, final String desc) {
            mLoadingDialog.dismiss();
            if (status == 0) {
                refreshMemberList();
            } else {
                ToastUtil.shortToast(mContext, "添加失败");
            }
        }
    });
}
 
Example #20
Source File: MeFragment.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onResume() {
    UserInfo myInfo = JMessageClient.getMyInfo();
    myInfo.getAvatarBitmap(new GetAvatarBitmapCallback() {
        @Override
        public void gotResult(int i, String s, Bitmap bitmap) {
            if (i == 0) {
                mMeView.showPhoto(bitmap);
                mMeController.setBitmap(bitmap);
            }else {
                mMeView.showPhoto(null);
                mMeController.setBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.rc_default_portrait));
            }
        }
    });
    mMeView.showNickName(myInfo);
    super.onResume();
}
 
Example #21
Source File: SettingActivity.java    From Android-IM with Apache License 2.0 6 votes vote down vote up
private void pushMusic() {
    mSettingPushMusic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                if (helper.getVib()) {
                    JMessageClient.setNotificationFlag(FLAG_NOTIFY_SILENCE | FLAG_NOTIFY_WITH_SOUND | FLAG_NOTIFY_WITH_VIBRATE);
                } else {
                    JMessageClient.setNotificationFlag(FLAG_NOTIFY_SILENCE | FLAG_NOTIFY_WITH_SOUND);
                }
                helper.setMusic(true);
            } else {
                if (helper.getVib()) {
                    JMessageClient.setNotificationFlag(FLAG_NOTIFY_SILENCE | FLAG_NOTIFY_WITH_VIBRATE);
                } else {
                    JMessageClient.setNotificationFlag(FLAG_NOTIFY_SILENCE);
                }
                helper.setMusic(false);
            }
        }
    });
}
 
Example #22
Source File: UserActivty.java    From Android-IM with Apache License 2.0 6 votes vote down vote up
@Override
    protected void initData() {
        mUserinfoNikename.setText(JMessageClient.getMyInfo().getNickname() + "");
        mUserinfoBirthday.setText(TimeUtils.ms2date("yyyy-MM-dd", JMessageClient.getMyInfo().getBirthday()));
        mUserinfoGender.setText(StringUtils.constant2String(JMessageClient.getMyInfo().getGender().name()));
        if (StringUtils.isNull(JMessageClient.getMyInfo().getSignature())) {
            mUserinfoSignature.setText("签名:暂未设置签名");
        } else {
            mUserinfoSignature.setText(JMessageClient.getMyInfo().getSignature() + "");
        }
//        Log.e("info====", JMessageClient.getMyInfo().getAddress() + "\nregion:" + info.getRegion());
        mUserinfoRegion.setText(JMessageClient.getMyInfo().getAddress() + "");
        mUserinfoUsername.setText(JMessageClient.getMyInfo().getUserName() + "");
        mUserinfoMtime.setText("上次更新:" + TimeUtils.unix2Date("yyyy-MM-dd hh-mm", JMessageClient.getMyInfo().getmTime()));
        Picasso.with(this)
                .load(JMessageClient.getMyInfo().getAvatarFile())
                .placeholder(R.mipmap.icon_user)
                .into(mUserinfoAvatar);

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

  } 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) {
        List<GroupMemberInfo> groupSilenceMemberInfos = groupInfo.getGroupSilenceMemberInfos();
        handleResult(toJson(groupSilenceMemberInfos), status, desc, result);
      } else {
        handleResult(status, desc, result);
      }
    }
  });
}
 
Example #24
Source File: BaseActivity.java    From jmessage-android-uikit with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    //初始化JMessage-sdk
    JMessageClient.init(this);
    //订阅接收消息 这里主要是添加或删除群成员的event
    JMessageClient.registerEventReceiver(this);
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    mDensity = dm.density;
    mDensityDpi = dm.densityDpi;
    mWidth = dm.widthPixels;
    mHeight = dm.heightPixels;
    mAvatarSize = (int) (50 * mDensity);
}
 
Example #25
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 5 votes vote down vote up
private void sendCrossDeviceTransCommand(MethodCall call, final Result result) {
  HashMap<String, Object> map = call.arguments();
  try {
    JSONObject params = new JSONObject(map);
    String message = params.getString("message");
    String type = params.getString("platform");

    PlatformType platformType = PlatformType.all;
    if (type.equals("android")) {
      platformType = PlatformType.android;
    }else if (type.equals("ios")) {
      platformType = PlatformType.ios;
    }else if (type.equals("windows")) {
      platformType = PlatformType.windows;
    }else if (type.equals("web")) {
      platformType = PlatformType.web;
    }else {//all
      platformType = PlatformType.all;
    }

    JMessageClient.sendCrossDeviceTransCommand(platformType, message, 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 #26
Source File: SearchMoreFriendsActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Object selectObject = parent.getItemAtPosition(position);
    if (selectObject instanceof UserInfo) {
        UserInfo friend = (UserInfo) selectObject;
        final Intent intent = new Intent(SearchMoreFriendsActivity.this, ChatActivity.class);
        String notename = friend.getDisplayName();
        Conversation conv = JMessageClient.getSingleConversation(friend.getUserName(), friend.getAppKey());
        //如果会话为空,使用EventBus通知会话列表添加新会话
        if (conv == null) {
            conv = Conversation.createSingleConversation(friend.getUserName(), friend.getAppKey());
            EventBus.getDefault().post(new Event.Builder()
                    .setType(EventType.createConversation)
                    .setConversation(conv)
                    .build());
        }
        //转发消息
        if (isForwardMsg) {
            DialogCreator.createForwardMsg(SearchMoreFriendsActivity.this, mWidth, true, null, null, notename, friend);
            //进入聊天界面
        } else if (isBusinessCard) {
            setSearchContactsBusiness(getIntent(), null, friend);
        } else {
            intent.putExtra(JGApplication.TARGET_ID, friend.getUserName());
            intent.putExtra(JGApplication.TARGET_APP_KEY, friend.getAppKey());
            intent.putExtra(JGApplication.CONV_TITLE, notename);
            startActivity(intent);
        }
    }
}
 
Example #27
Source File: MeView.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public void initModule(float density, int width) {
    mTakePhotoBtn = (SelectableRoundedImageView) findViewById(R.id.take_photo_iv);
    mNickNameTv = (TextView) findViewById(R.id.nickName);
    mSignatureTv = (TextView) findViewById(R.id.signature);
    mSet_pwd = (RelativeLayout) findViewById(R.id.setPassword);
    mSet_noDisturb = (SlipButton) findViewById(R.id.btn_noDisturb);
    mOpinion = (RelativeLayout) findViewById(R.id.opinion);
    mAbout = (RelativeLayout) findViewById(R.id.about);
    mExit = (RelativeLayout) findViewById(R.id.exit);
    mRl_personal = (RelativeLayout) findViewById(R.id.rl_personal);
    mSet_noDisturb.setOnChangedListener(R.id.btn_noDisturb, this);

    mWidth = width;
    mHeight = (int) (190 * density);


    final Dialog dialog = DialogCreator.createLoadingDialog(mContext, mContext.getString(R.string.jmui_loading));
    dialog.show();
    //初始化是否全局免打扰
    JMessageClient.getNoDisturbGlobal(new IntegerCallback() {
        @Override
        public void gotResult(int responseCode, String responseMessage, Integer value) {
            dialog.dismiss();
            if (responseCode == 0) {
                mSet_noDisturb.setChecked(value == 1);
            } else {
                ToastUtil.shortToast(mContext, responseMessage);
            }
        }
    });


}
 
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: AllMembersAdapter.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
    if (mIsCreator && !mIsDeleteMode && position != 0) {
        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (v.getId()) {
                    case R.id.jmui_cancel_btn:
                        mDialog.dismiss();
                        break;
                    case R.id.jmui_commit_btn:
                        mDialog.dismiss();
                        mLoadingDialog = DialogCreator.createLoadingDialog(mContext,
                                mContext.getString(R.string.deleting_hint));
                        mLoadingDialog.show();
                        List<String> list = new ArrayList<String>();
                        list.add(mMemberList.get(position).data.getUserName());
                        JMessageClient.removeGroupMembers(mGroupId, list, new BasicCallback() {
                            @Override
                            public void gotResult(int status, String desc) {
                                mLoadingDialog.dismiss();
                                if (status == 0) {
                                    mContext.refreshMemberList();
                                } else {
                                    ToastUtil.shortToast(mContext, "删除失败" + desc);
                                }
                            }
                        });
                        break;

                }
            }
        };
        mDialog = DialogCreator.createDeleteMemberDialog(mContext, listener, true);
        mDialog.getWindow().setLayout((int) (0.8 * mWidth), WindowManager.LayoutParams.WRAP_CONTENT);
        mDialog.show();
    }
    return true;
}
 
Example #30
Source File: MsgListAdapter.java    From jmessage-android-uikit with MIT License 5 votes vote down vote up
public MsgListAdapter(Context context, long groupId, ContentLongClickListener longClickListener) {
    initData(context);
    this.mGroupId = groupId;
    this.mIsGroup = true;
    this.mLongClickListener = longClickListener;
    this.mConv = JMessageClient.getGroupConversation(groupId);
    this.mMsgList = mConv.getMessagesFromNewest(0, mOffset);
    reverse(mMsgList);
    mStart = mOffset;
    checkSendingImgMsg();
}