Java Code Examples for cn.jpush.im.android.api.JMessageClient#deleteSingleConversation()

The following examples show how to use cn.jpush.im.android.api.JMessageClient#deleteSingleConversation() . 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: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 6 votes vote down vote up
private void deleteConversation(MethodCall call, Result result) {
  HashMap<String, Object> map = call.arguments();
  try {
    JSONObject params = new JSONObject(map);
    String type = params.getString("type");

    if (type.equals("single")) {
      String username = params.getString("username");

      if (params.has("appKey") && !TextUtils.isEmpty(params.getString("appKey"))) {
        JMessageClient.deleteSingleConversation(username, params.getString("appKey"));
      } else {
        JMessageClient.deleteSingleConversation(username);
      }

    } else if (type.equals("group")) {
      long groupId = Long.parseLong(params.getString("groupId"));
      JMessageClient.deleteGroupConversation(groupId);

    } else if (type.equals("chatRoom")) {
      long roomId = Long.parseLong(params.getString("roomId"));
      JMessageClient.deleteChatRoomConversation(roomId);

    } else {
      handleResult(ERR_CODE_PARAMETER, "Conversation type is error", result);
      return;
    }

    result.success(null);
  } catch (JSONException e) {
    handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
  }
}
 
Example 2
Source File: ChatDetailController.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public void delConvAndReturnMainActivity() {
    Conversation conversation = JMessageClient.getSingleConversation(mUserInfo.getUserName(), mUserInfo.getAppKey());
    EventBus.getDefault().post(new Event.Builder().setType(EventType.deleteConversation)
            .setConversation(conversation)
            .build());
    JMessageClient.deleteSingleConversation(mUserInfo.getUserName(), mUserInfo.getAppKey());
    mContext.startMainActivity();
}
 
Example 3
Source File: FriendSettingActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public void delConvAndReturnMainActivity() {
    Conversation conversation = JMessageClient.getSingleConversation(mFriendInfo.getUserName(), mFriendInfo.getAppKey());
    EventBus.getDefault().post(new Event.Builder().setType(EventType.deleteConversation)
            .setConversation(conversation)
            .build());
    JMessageClient.deleteSingleConversation(mFriendInfo.getUserName(), mFriendInfo.getAppKey());
    Intent intent = new Intent(this, MainActivity.class);
    startActivity(intent);
    finish();
}
 
Example 4
Source File: ConversationListController.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
    final Conversation conv = mDatas.get(position - 3);
    if (conv != null) {
        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (v.getId()) {
                    //会话置顶
                    case R.id.jmui_top_conv_ll:
                        //已经置顶,去取消
                        if (!TextUtils.isEmpty(conv.getExtra())) {
                            mListAdapter.setCancelConvTop(conv);
                            //没有置顶,去置顶
                        } else {
                            mListAdapter.setConvTop(conv);
                        }
                        mDialog.dismiss();
                        break;
                    //删除会话
                    case R.id.jmui_delete_conv_ll:
                        if (conv.getType() == ConversationType.group) {
                            JMessageClient.deleteGroupConversation(((GroupInfo) conv.getTargetInfo()).getGroupID());
                        } else {
                            JMessageClient.deleteSingleConversation(((UserInfo) conv.getTargetInfo()).getUserName());
                        }
                        mDatas.remove(position - 3);
                        if (mDatas.size() > 0) {
                            mConvListView.setNullConversation(true);
                        } else {
                            mConvListView.setNullConversation(false);
                        }
                        mListAdapter.notifyDataSetChanged();
                        mDialog.dismiss();
                        break;
                    default:
                        break;
                }

            }
        };
        mDialog = DialogCreator.createDelConversationDialog(mContext.getActivity(), listener, TextUtils.isEmpty(conv.getExtra()));
        mDialog.show();
        mDialog.getWindow().setLayout((int) (0.8 * mWidth), WindowManager.LayoutParams.WRAP_CONTENT);
    }
    return true;
}
 
Example 5
Source File: ChatMsgActivity.java    From Android-IM with Apache License 2.0 4 votes vote down vote up
@OnClick({R.id.title_bar_back, R.id.title_bar_title, R.id.title_options_tv})
public void onViewClicked(View view) {
    switch (view.getId()) {
        case R.id.title_bar_title:
            Intent intent = new Intent(mContext, UserInfoActivity.class);
            intent.putExtra("USERNAME", userName);
            break;
        case R.id.title_bar_back:
            finish();
            //重置会话未读
            conversation.resetUnreadCount();
            break;
        case R.id.title_options_tv:
            //
            MyAlertDialog dialog = new MyAlertDialog(this, new String[]{"清空聊天记录", "清空并删除会话"}, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    switch (i) {
                        case 0:
                            showProgressDialog("正在删除聊天记录");
                            if (conversation.deleteAllMessage()) {
                                mAdapter.clear();
                                mData.clear();
                                mAdapter.notifyDataSetChanged();
                                dismissProgressDialog();
                            }

                            break;
                        case 1:
                            showProgressDialog("正在删除");
                            if (JMessageClient.deleteSingleConversation(userName)) {
                                startActivity(new Intent(ChatMsgActivity.this, MainActivity.class));
                            }
                            break;
                        default:
                            break;
                    }
                }
            });
            dialog.initDialog(Gravity.RIGHT | Gravity.TOP);
            dialog.dialogSize(200, 0, 0, 55);

            break;
        default:
            break;
    }
}