Commit 4bc26f31749c6d6f62001a9bed30193f7bae4e50

Authored by 陈硕
1 parent 8077a676

添加toast

app/src/main/java/com/cnlive/im/ui/ChatRoomActivity.java
... ... @@ -87,17 +87,21 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
87 87 @Override
88 88 public void onTokenIncorrect() {
89 89 Log.e(TAG, "ConnectListener TokenIncorrect");
  90 + Toast.makeText(ChatRoomActivity.this, "TokenIncorrect", Toast.LENGTH_SHORT).show();
  91 +
90 92 }
91 93  
92 94 @Override
93 95 public void onSuccess(String s) {
94 96 Log.e(TAG, "ConnectListener 连接监听" + s);
95   -
  97 + Toast.makeText(ChatRoomActivity.this, "连接成功", Toast.LENGTH_SHORT).show();
96 98 }
97 99  
98 100 @Override
99 101 public void onError(int i, String s) {
100 102 Log.e(TAG, "ConnectListener errorCode : " + i + " : errorMessage : " + s);
  103 + Toast.makeText(ChatRoomActivity.this, s, Toast.LENGTH_SHORT).show();
  104 +
101 105 }
102 106 };
103 107  
... ... @@ -116,9 +120,12 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
116 120  
117 121 @Override
118 122 public void onSuccess(final CNMessage cnMessage) {
  123 +
119 124 mHandler.post(new Runnable() {
120 125 @Override
121 126 public void run() {
  127 + Toast.makeText(ChatRoomActivity.this, "发送成功", Toast.LENGTH_SHORT).show();
  128 +
122 129 if (("60_" + roomIdOne).equals(cnMessage.getTargetId())) {
123 130 groupChatOneListMy.add(cnMessage);
124 131 chatListAdapterOne.updateItems(groupChatOneListMy);
... ... @@ -143,6 +150,14 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
143 150 @Override
144 151 public void onError(CNMessage cnMessage, int i, String s) {
145 152 Log.v(TAG, "SendMessageListener 失败 " + i + " s" + s);
  153 + mHandler.post(new Runnable() {
  154 + @Override
  155 + public void run() {
  156 + Toast.makeText(ChatRoomActivity.this, "发送失败", Toast.LENGTH_SHORT).show();
  157 +
  158 + }
  159 + });
  160 +
146 161  
147 162 }
148 163 };
... ... @@ -200,6 +215,7 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
200 215 public void onJoined(String s) {
201 216 Log.i(TAG, "chatRoomActionListener " + "onJoined" + s);
202 217  
  218 +
203 219 }
204 220  
205 221 @Override
... ... @@ -234,6 +250,13 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
234 250 @Override
235 251 public void onSuccess(int what, String extra) {
236 252 Log.v(TAG, "加入聊天室" + what + extra);
  253 + mHandler.post(new Runnable() {
  254 + @Override
  255 + public void run() {
  256 + Toast.makeText(ChatRoomActivity.this, "加入聊天室成功", Toast.LENGTH_SHORT).show();
  257 +
  258 + }
  259 + });
237 260  
238 261 }
239 262  
... ...
app/src/main/java/com/cnlive/im/ui/PrivateChatActivity.java
... ... @@ -118,22 +118,25 @@ public class PrivateChatActivity extends AppCompatActivity implements View.OnCli
118 118 private IChat.OnConnectListener connectListener = new IChat.OnConnectListener() {
119 119 @Override
120 120 public void onTokenIncorrect() {
121   - Log.e(TAG, "私聊ConnectListener TokenIncorrect");
  121 + Log.e(TAG, "ConnectListener TokenIncorrect");
  122 + Toast.makeText(PrivateChatActivity.this, "TokenIncorrect", Toast.LENGTH_SHORT).show();
  123 +
122 124 }
123 125  
124 126 @Override
125 127 public void onSuccess(String s) {
126   - Log.e(TAG, "私聊ConnectListener 连接监听" + s);
127   -
  128 + Log.e(TAG, "ConnectListener 连接监听" + s);
  129 + Toast.makeText(PrivateChatActivity.this, "连接成功", Toast.LENGTH_SHORT).show();
128 130 }
129 131  
130 132 @Override
131 133 public void onError(int i, String s) {
132   - Log.e(TAG, "私聊ConnectListener errorCode : " + i + " : errorMessage : " + s);
  134 + Log.e(TAG, "ConnectListener errorCode : " + i + " : errorMessage : " + s);
  135 + Toast.makeText(PrivateChatActivity.this, s, Toast.LENGTH_SHORT).show();
  136 +
133 137 }
134 138 };
135 139  
136   -
137 140 /**
138 141 * 发送消息监听
139 142 */
... ... @@ -150,6 +153,8 @@ public class PrivateChatActivity extends AppCompatActivity implements View.OnCli
150 153 mHandler.post(new Runnable() {
151 154 @Override
152 155 public void run() {
  156 + Toast.makeText(PrivateChatActivity.this, "发送消息成功", Toast.LENGTH_SHORT).show();
  157 +
153 158 messageList.add(cnMessage);
154 159 chatListAdapter.updateItems(messageList);
155 160 chatListAdapter.notifyDataSetChanged();
... ... @@ -164,8 +169,15 @@ public class PrivateChatActivity extends AppCompatActivity implements View.OnCli
164 169 @Override
165 170 public void onError(CNMessage cnMessage, int i, String s) {
166 171 Log.v(TAG, "私聊SendMessageListener 失败 " + i + " s" + s);
  172 + mHandler.post(new Runnable() {
  173 + @Override
  174 + public void run() {
  175 + Toast.makeText(PrivateChatActivity.this, "发送消息失败", Toast.LENGTH_SHORT).show();
167 176  
168 177  
  178 + }
  179 + });
  180 +
169 181 }
170 182 };
171 183  
... ... @@ -196,10 +208,6 @@ public class PrivateChatActivity extends AppCompatActivity implements View.OnCli
196 208 };
197 209  
198 210  
199   -
200   -
201   -
202   -
203 211 @Override
204 212 protected void onPause() {
205 213 super.onPause();
... ...