Commit be545209c06a353f3e06594ff5b8621a79acf6e6

Authored by 陈硕
1 parent 781b4848

修改方法

app/src/main/java/com/cnlive/im/ui/ChatRoomActivity.java
... ... @@ -44,6 +44,8 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
44 44 private Button user_imfor_send;
45 45 private EditText user_id, user_name;
46 46 private CNUserInfo cnUser;
  47 + private Button exit_chat2;
  48 + private Button exit_chat1;
47 49  
48 50  
49 51 @Override
... ... @@ -62,6 +64,8 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
62 64  
63 65  
64 66 private void initUI() {
  67 + exit_chat2 = (Button) findViewById(R.id.exit_chat2);
  68 + exit_chat1 = (Button) findViewById(R.id.exit_chat1);
65 69 user_id = (EditText) findViewById(R.id.user_ID);
66 70 user_name = (EditText) findViewById(R.id.user_name);
67 71 user_imfor_send = (Button) findViewById(R.id.user_imfor_send);
... ... @@ -78,6 +82,8 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
78 82 editText = (EditText) findViewById(R.id.message_content);
79 83 send_messageOneBtn = (Button) findViewById(R.id.send_messageOne);
80 84 send_messageOneTwo = (Button) findViewById(R.id.send_messageTwo);
  85 + exit_chat1.setOnClickListener(this);
  86 + exit_chat2.setOnClickListener(this);
81 87 user_imfor_send.setOnClickListener(this);
82 88 disconnectBtn.setOnClickListener(this);
83 89 foundChatBtn.setOnClickListener(this);
... ... @@ -262,12 +268,12 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
262 268 // 加入聊天室监听
263 269 private IChat.OnOperationListener onOperationListener = new IChat.OnOperationListener() {
264 270 @Override
265   - public void onSuccess(int what, String extra) {
266   - Log.v(TAG, "加入聊天室" + what + extra);
  271 + public void onSuccess(int what, final String extra) {
  272 + Log.v(TAG, + what + extra);
267 273 mHandler.post(new Runnable() {
268 274 @Override
269 275 public void run() {
270   - Toast.makeText(ChatRoomActivity.this, "加入聊天室成功", Toast.LENGTH_SHORT).show();
  276 + Toast.makeText(ChatRoomActivity.this, extra, Toast.LENGTH_SHORT).show();
271 277  
272 278 }
273 279 });
... ... @@ -332,11 +338,19 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
332 338 ChatUtil.joinChatRoom(roomIdTwo, -1, onOperationListener);
333 339 break;
334 340  
  341 + case R.id.exit_chat2:
  342 + ChatUtil.quitChatRoom(roomIdTwo, onOperationListener);
  343 + break;
  344 +
  345 + case R.id.exit_chat1:
  346 + ChatUtil.quitChatRoom(roomIdOne, onOperationListener);
  347 + break;
  348 +
335 349  
336 350 case R.id.user_imfor_send:
337 351 if (user_id.getText().toString().isEmpty())
338 352 Toast.makeText(ChatRoomActivity.this, "用户id不能为空", Toast.LENGTH_SHORT).show();
339   - else if (user_name.getText().toString().isEmpty())
  353 + else if (user_name.getText().toString().isEmpty())
340 354 Toast.makeText(ChatRoomActivity.this, "用户名不能为空", Toast.LENGTH_SHORT).show();
341 355 else {
342 356 cnUser = new CNUserInfo(user_id.getText().toString(), user_name.getText().toString(), "");
... ... @@ -349,11 +363,11 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
349 363 }
350 364 }
351 365  
352   -
353 366 @Override
354 367 protected void onPause() {
355 368 super.onPause();
356   - ChatUtil.disconnect(false);
  369 + ChatUtil.quitChatRoom(roomIdTwo, onOperationListener);
  370 + ChatUtil.quitChatRoom(roomIdOne, onOperationListener);
357 371 }
358 372  
359 373  
... ...
app/src/main/java/com/cnlive/im/ui/PrivateChatActivity.java
... ... @@ -207,12 +207,7 @@ public class PrivateChatActivity extends AppCompatActivity implements View.OnCli
207 207 };
208 208  
209 209  
210   - @Override
211   - protected void onPause() {
212   - super.onPause();
213   - ChatUtil.disconnect(false);
214 210  
215   - }
216 211  
217 212  
218 213 }
... ...