@Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { BmobRecent recent = adapter.getItem(position); // 重置未读消息 BmobDB.create(this).resetUnread(recent.getTargetid()); // 组装聊天对象 BmobChatUser user = new BmobChatUser(); user.setAvatar(recent.getAvatar()); user.setNick(recent.getNick()); user.setUsername(recent.getUserName()); user.setObjectId(recent.getTargetid()); Intent intent = new Intent(this, ChatActivity.class); intent.putExtra("user", user); startAnimActivity(intent); }
@Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int position, long arg3) { BmobRecent recent = adapter.getItem(position); showDeleteDialog(recent); return true; }
/** * 删除会话 deleteRecent * * @param recent * @return void */ private void deleteRecent(BmobRecent recent) { adapter.remove(recent); BmobDB.create(this).deleteRecent(recent.getTargetid()); BmobDB.create(this).deleteMessages(recent.getTargetid()); }