Commit 74affc6a210998e584aeb946b958edb249946be7
1 parent
22283030
添加上传进度功能
Showing
10 changed files
with
190 additions
and
31 deletions
app/src/main/java/com/cnlive/im/adapter/ChatRoomAdpter.java
| @@ -202,12 +202,14 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -202,12 +202,14 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 202 | private TextView ima_user_name; | 202 | private TextView ima_user_name; |
| 203 | private ImageView img_content; | 203 | private ImageView img_content; |
| 204 | private TextView status; | 204 | private TextView status; |
| 205 | + private TextView uploadProgress; | ||
| 205 | 206 | ||
| 206 | public ImaMessageHolder(View itemView) { | 207 | public ImaMessageHolder(View itemView) { |
| 207 | super(itemView); | 208 | super(itemView); |
| 208 | ima_user_name = (TextView) itemView.findViewById(R.id.img_user_name); | 209 | ima_user_name = (TextView) itemView.findViewById(R.id.img_user_name); |
| 209 | img_content = (ImageView) itemView.findViewById(R.id.img_content); | 210 | img_content = (ImageView) itemView.findViewById(R.id.img_content); |
| 210 | status = (TextView) itemView.findViewById(R.id.status); | 211 | status = (TextView) itemView.findViewById(R.id.status); |
| 212 | + uploadProgress = (TextView) itemView.findViewById(R.id.uploadProgress); | ||
| 211 | } | 213 | } |
| 212 | 214 | ||
| 213 | public void showMessage(final ImagMessage imagMessage) { | 215 | public void showMessage(final ImagMessage imagMessage) { |
| @@ -219,16 +221,24 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -219,16 +221,24 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 219 | case IChat.CN_MSG_STATUS_SENDING: | 221 | case IChat.CN_MSG_STATUS_SENDING: |
| 220 | if (status != null) | 222 | if (status != null) |
| 221 | status.setText("发送中"); | 223 | status.setText("发送中"); |
| 224 | + if (uploadProgress != null) { | ||
| 225 | + uploadProgress.setVisibility(View.VISIBLE); | ||
| 226 | + uploadProgress.setText("上传进度:" + imagMessage.getProgress() + "%"); | ||
| 227 | + } | ||
| 222 | Glide.with(mContext).load(imagMessage.getCnImgMessage().getImagePath()).into(img_content); | 228 | Glide.with(mContext).load(imagMessage.getCnImgMessage().getImagePath()).into(img_content); |
| 223 | break; | 229 | break; |
| 224 | case IChat.CN_MSG_STATUS_SEND_FAIL: | 230 | case IChat.CN_MSG_STATUS_SEND_FAIL: |
| 225 | if (status != null) | 231 | if (status != null) |
| 226 | status.setText("发送失败"); | 232 | status.setText("发送失败"); |
| 233 | + if (uploadProgress != null) | ||
| 234 | + uploadProgress.setVisibility(View.GONE); | ||
| 227 | Glide.with(mContext).load(imagMessage.getCnImgMessage().getImagePath()).into(img_content); | 235 | Glide.with(mContext).load(imagMessage.getCnImgMessage().getImagePath()).into(img_content); |
| 228 | break; | 236 | break; |
| 229 | case IChat.CN_MSG_STATUS_SEND_SUCCESS: | 237 | case IChat.CN_MSG_STATUS_SEND_SUCCESS: |
| 230 | if (status != null) | 238 | if (status != null) |
| 231 | status.setText("发送成功"); | 239 | status.setText("发送成功"); |
| 240 | + if (uploadProgress != null) | ||
| 241 | + uploadProgress.setVisibility(View.GONE); | ||
| 232 | sendSuccess(imagMessage); | 242 | sendSuccess(imagMessage); |
| 233 | break; | 243 | break; |
| 234 | } | 244 | } |
| @@ -280,6 +290,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -280,6 +290,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 280 | private TextView voice_duration; | 290 | private TextView voice_duration; |
| 281 | private View voice_none_read; | 291 | private View voice_none_read; |
| 282 | private TextView status; | 292 | private TextView status; |
| 293 | + private TextView uploadProgress; | ||
| 283 | 294 | ||
| 284 | public VoiceMessageHolder(View itemView) { | 295 | public VoiceMessageHolder(View itemView) { |
| 285 | super(itemView); | 296 | super(itemView); |
| @@ -288,6 +299,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -288,6 +299,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 288 | voice_duration = (TextView) itemView.findViewById(R.id.voice_duration); | 299 | voice_duration = (TextView) itemView.findViewById(R.id.voice_duration); |
| 289 | voice_none_read = itemView.findViewById(R.id.noneRead); | 300 | voice_none_read = itemView.findViewById(R.id.noneRead); |
| 290 | status = (TextView) itemView.findViewById(R.id.status); | 301 | status = (TextView) itemView.findViewById(R.id.status); |
| 302 | + uploadProgress = (TextView) itemView.findViewById(R.id.uploadProgress); | ||
| 291 | } | 303 | } |
| 292 | 304 | ||
| 293 | public void showMessage(final VoiceMessage voiceMessage) { | 305 | public void showMessage(final VoiceMessage voiceMessage) { |
| @@ -298,14 +310,22 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -298,14 +310,22 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 298 | case IChat.CN_MSG_STATUS_SENDING: | 310 | case IChat.CN_MSG_STATUS_SENDING: |
| 299 | if (status != null) | 311 | if (status != null) |
| 300 | status.setText("发送中"); | 312 | status.setText("发送中"); |
| 313 | + if (uploadProgress != null) { | ||
| 314 | + uploadProgress.setVisibility(View.VISIBLE); | ||
| 315 | + uploadProgress.setText("上传进度:" + voiceMessage.getProgress() + "%"); | ||
| 316 | + } | ||
| 301 | break; | 317 | break; |
| 302 | case IChat.CN_MSG_STATUS_SEND_FAIL: | 318 | case IChat.CN_MSG_STATUS_SEND_FAIL: |
| 303 | if (status != null) | 319 | if (status != null) |
| 304 | status.setText("发送失败"); | 320 | status.setText("发送失败"); |
| 321 | + if (uploadProgress != null) | ||
| 322 | + uploadProgress.setVisibility(View.GONE); | ||
| 305 | break; | 323 | break; |
| 306 | case IChat.CN_MSG_STATUS_SEND_SUCCESS: | 324 | case IChat.CN_MSG_STATUS_SEND_SUCCESS: |
| 307 | if (status != null) | 325 | if (status != null) |
| 308 | status.setText("发送成功"); | 326 | status.setText("发送成功"); |
| 327 | + if (uploadProgress != null) | ||
| 328 | + uploadProgress.setVisibility(View.GONE); | ||
| 309 | sendSuccess(voiceMessage); | 329 | sendSuccess(voiceMessage); |
| 310 | break; | 330 | break; |
| 311 | } | 331 | } |
| @@ -332,6 +352,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -332,6 +352,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 332 | private ImageView video_snapshot; | 352 | private ImageView video_snapshot; |
| 333 | private View videoLayout; | 353 | private View videoLayout; |
| 334 | private TextView status; | 354 | private TextView status; |
| 355 | + private TextView uploadProgress; | ||
| 335 | 356 | ||
| 336 | public VideoMessageHolder(View itemView) { | 357 | public VideoMessageHolder(View itemView) { |
| 337 | super(itemView); | 358 | super(itemView); |
| @@ -339,6 +360,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -339,6 +360,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 339 | video_snapshot = (ImageView) itemView.findViewById(R.id.img_content); | 360 | video_snapshot = (ImageView) itemView.findViewById(R.id.img_content); |
| 340 | videoLayout = itemView.findViewById(R.id.videoLayout); | 361 | videoLayout = itemView.findViewById(R.id.videoLayout); |
| 341 | status = (TextView) itemView.findViewById(R.id.status); | 362 | status = (TextView) itemView.findViewById(R.id.status); |
| 363 | + uploadProgress = (TextView) itemView.findViewById(R.id.uploadProgress); | ||
| 342 | } | 364 | } |
| 343 | 365 | ||
| 344 | public void showMessage(final VideoMessage videoMessage) { | 366 | public void showMessage(final VideoMessage videoMessage) { |
| @@ -347,16 +369,24 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -347,16 +369,24 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 347 | case IChat.CN_MSG_STATUS_SENDING: | 369 | case IChat.CN_MSG_STATUS_SENDING: |
| 348 | if (status != null) | 370 | if (status != null) |
| 349 | status.setText("发送中"); | 371 | status.setText("发送中"); |
| 372 | + if (uploadProgress != null) { | ||
| 373 | + uploadProgress.setVisibility(View.VISIBLE); | ||
| 374 | + uploadProgress.setText("上传进度:" + videoMessage.getProgress() + "%"); | ||
| 375 | + } | ||
| 350 | Glide.with(mContext).load(videoMessage.getCnVideoMessage().getSnapshotPath()).into(video_snapshot); | 376 | Glide.with(mContext).load(videoMessage.getCnVideoMessage().getSnapshotPath()).into(video_snapshot); |
| 351 | break; | 377 | break; |
| 352 | case IChat.CN_MSG_STATUS_SEND_FAIL: | 378 | case IChat.CN_MSG_STATUS_SEND_FAIL: |
| 353 | if (status != null) | 379 | if (status != null) |
| 354 | status.setText("发送失败"); | 380 | status.setText("发送失败"); |
| 381 | + if (uploadProgress != null) | ||
| 382 | + uploadProgress.setVisibility(View.GONE); | ||
| 355 | Glide.with(mContext).load(videoMessage.getCnVideoMessage().getSnapshotPath()).into(video_snapshot); | 383 | Glide.with(mContext).load(videoMessage.getCnVideoMessage().getSnapshotPath()).into(video_snapshot); |
| 356 | break; | 384 | break; |
| 357 | case IChat.CN_MSG_STATUS_SEND_SUCCESS: | 385 | case IChat.CN_MSG_STATUS_SEND_SUCCESS: |
| 358 | if (status != null) | 386 | if (status != null) |
| 359 | status.setText("发送成功"); | 387 | status.setText("发送成功"); |
| 388 | + if (uploadProgress != null) | ||
| 389 | + uploadProgress.setVisibility(View.GONE); | ||
| 360 | sendSuccess(videoMessage); | 390 | sendSuccess(videoMessage); |
| 361 | break; | 391 | break; |
| 362 | } | 392 | } |
| @@ -406,6 +436,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -406,6 +436,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 406 | private ImageView video_cover; | 436 | private ImageView video_cover; |
| 407 | private View videoLayout; | 437 | private View videoLayout; |
| 408 | private TextView status; | 438 | private TextView status; |
| 439 | + private TextView uploadProgress; | ||
| 409 | 440 | ||
| 410 | public UgcVideoMessageHolder(View itemView) { | 441 | public UgcVideoMessageHolder(View itemView) { |
| 411 | super(itemView); | 442 | super(itemView); |
| @@ -413,6 +444,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -413,6 +444,7 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 413 | video_cover = (ImageView) itemView.findViewById(R.id.img_content); | 444 | video_cover = (ImageView) itemView.findViewById(R.id.img_content); |
| 414 | videoLayout = itemView.findViewById(R.id.videoLayout); | 445 | videoLayout = itemView.findViewById(R.id.videoLayout); |
| 415 | status = (TextView) itemView.findViewById(R.id.status); | 446 | status = (TextView) itemView.findViewById(R.id.status); |
| 447 | + uploadProgress = (TextView) itemView.findViewById(R.id.uploadProgress); | ||
| 416 | } | 448 | } |
| 417 | 449 | ||
| 418 | public void showMessage(final UgcVideoMessage videoMessage) { | 450 | public void showMessage(final UgcVideoMessage videoMessage) { |
| @@ -421,16 +453,24 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | @@ -421,16 +453,24 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter { | ||
| 421 | case IChat.CN_MSG_STATUS_SENDING: | 453 | case IChat.CN_MSG_STATUS_SENDING: |
| 422 | if (status != null) | 454 | if (status != null) |
| 423 | status.setText("发送中"); | 455 | status.setText("发送中"); |
| 456 | + if (uploadProgress != null) { | ||
| 457 | + uploadProgress.setVisibility(View.VISIBLE); | ||
| 458 | + uploadProgress.setText("上传进度:" + videoMessage.getProgress() + "%"); | ||
| 459 | + } | ||
| 424 | Glide.with(mContext).load(videoMessage.getCnUgcMessage().getCoverPath()).into(video_cover); | 460 | Glide.with(mContext).load(videoMessage.getCnUgcMessage().getCoverPath()).into(video_cover); |
| 425 | break; | 461 | break; |
| 426 | case IChat.CN_MSG_STATUS_SEND_FAIL: | 462 | case IChat.CN_MSG_STATUS_SEND_FAIL: |
| 427 | if (status != null) | 463 | if (status != null) |
| 428 | status.setText("发送失败"); | 464 | status.setText("发送失败"); |
| 465 | + if (uploadProgress != null) | ||
| 466 | + uploadProgress.setVisibility(View.GONE); | ||
| 429 | Glide.with(mContext).load(videoMessage.getCnUgcMessage().getCoverPath()).into(video_cover); | 467 | Glide.with(mContext).load(videoMessage.getCnUgcMessage().getCoverPath()).into(video_cover); |
| 430 | break; | 468 | break; |
| 431 | case IChat.CN_MSG_STATUS_SEND_SUCCESS: | 469 | case IChat.CN_MSG_STATUS_SEND_SUCCESS: |
| 432 | if (status != null) | 470 | if (status != null) |
| 433 | status.setText("发送成功"); | 471 | status.setText("发送成功"); |
| 472 | + if (uploadProgress != null) | ||
| 473 | + uploadProgress.setVisibility(View.GONE); | ||
| 434 | sendSuccess(videoMessage); | 474 | sendSuccess(videoMessage); |
| 435 | break; | 475 | break; |
| 436 | } | 476 | } |
app/src/main/java/com/cnlive/im/mode/ImagMessage.java
| @@ -13,6 +13,7 @@ public class ImagMessage { | @@ -13,6 +13,7 @@ public class ImagMessage { | ||
| 13 | boolean isUserSend; | 13 | boolean isUserSend; |
| 14 | 14 | ||
| 15 | private boolean isDownloading = false; | 15 | private boolean isDownloading = false; |
| 16 | + private int progress = 0; | ||
| 16 | 17 | ||
| 17 | 18 | ||
| 18 | public String getType() { | 19 | public String getType() { |
| @@ -52,4 +53,19 @@ public class ImagMessage { | @@ -52,4 +53,19 @@ public class ImagMessage { | ||
| 52 | this.cnImgMessage = cnImgMessage; | 53 | this.cnImgMessage = cnImgMessage; |
| 53 | this.isUserSend = isUserSend; | 54 | this.isUserSend = isUserSend; |
| 54 | } | 55 | } |
| 56 | + | ||
| 57 | + public ImagMessage(String type, CNImgMessage cnImgMessage, boolean isUserSend, int progress) { | ||
| 58 | + this.type = type; | ||
| 59 | + this.cnImgMessage = cnImgMessage; | ||
| 60 | + this.isUserSend = isUserSend; | ||
| 61 | + this.progress = progress; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public int getProgress() { | ||
| 65 | + return progress; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public void setProgress(int progress) { | ||
| 69 | + this.progress = progress; | ||
| 70 | + } | ||
| 55 | } | 71 | } |
app/src/main/java/com/cnlive/im/mode/UgcVideoMessage.java
| @@ -12,6 +12,7 @@ public class UgcVideoMessage { | @@ -12,6 +12,7 @@ public class UgcVideoMessage { | ||
| 12 | boolean isUserSend; | 12 | boolean isUserSend; |
| 13 | 13 | ||
| 14 | private boolean isDownloading = false; | 14 | private boolean isDownloading = false; |
| 15 | + private int progress = 0; | ||
| 15 | 16 | ||
| 16 | public UgcVideoMessage(String type, CNUgcMessage cnUgcMessage, boolean isUserSend) { | 17 | public UgcVideoMessage(String type, CNUgcMessage cnUgcMessage, boolean isUserSend) { |
| 17 | this.type = type; | 18 | this.type = type; |
| @@ -19,6 +20,14 @@ public class UgcVideoMessage { | @@ -19,6 +20,14 @@ public class UgcVideoMessage { | ||
| 19 | this.isUserSend = isUserSend; | 20 | this.isUserSend = isUserSend; |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 23 | + public UgcVideoMessage(String type, CNUgcMessage cnUgcMessage, boolean isUserSend, int progress) { | ||
| 24 | + this.type = type; | ||
| 25 | + this.cnUgcMessage = cnUgcMessage; | ||
| 26 | + this.isUserSend = isUserSend; | ||
| 27 | + this.progress = progress; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + | ||
| 22 | public String getType() { | 31 | public String getType() { |
| 23 | return type; | 32 | return type; |
| 24 | } | 33 | } |
| @@ -50,5 +59,13 @@ public class UgcVideoMessage { | @@ -50,5 +59,13 @@ public class UgcVideoMessage { | ||
| 50 | public void setDownloading(boolean downloading) { | 59 | public void setDownloading(boolean downloading) { |
| 51 | isDownloading = downloading; | 60 | isDownloading = downloading; |
| 52 | } | 61 | } |
| 62 | + | ||
| 63 | + public int getProgress() { | ||
| 64 | + return progress; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public void setProgress(int progress) { | ||
| 68 | + this.progress = progress; | ||
| 69 | + } | ||
| 53 | } | 70 | } |
| 54 | 71 |
app/src/main/java/com/cnlive/im/mode/VideoMessage.java
| @@ -13,6 +13,7 @@ public class VideoMessage { | @@ -13,6 +13,7 @@ public class VideoMessage { | ||
| 13 | boolean isUserSend; | 13 | boolean isUserSend; |
| 14 | 14 | ||
| 15 | private boolean isDownloading = false; | 15 | private boolean isDownloading = false; |
| 16 | + private int progress; | ||
| 16 | 17 | ||
| 17 | public VideoMessage(String type, CNVideoMessage cnVideoMessage, boolean isUserSend) { | 18 | public VideoMessage(String type, CNVideoMessage cnVideoMessage, boolean isUserSend) { |
| 18 | this.type = type; | 19 | this.type = type; |
| @@ -20,6 +21,14 @@ public class VideoMessage { | @@ -20,6 +21,14 @@ public class VideoMessage { | ||
| 20 | this.isUserSend = isUserSend; | 21 | this.isUserSend = isUserSend; |
| 21 | } | 22 | } |
| 22 | 23 | ||
| 24 | + | ||
| 25 | + public VideoMessage(String type, CNVideoMessage cnVideoMessage, boolean isUserSend, int progress) { | ||
| 26 | + this.type = type; | ||
| 27 | + this.cnVideoMessage = cnVideoMessage; | ||
| 28 | + this.isUserSend = isUserSend; | ||
| 29 | + this.progress = progress; | ||
| 30 | + } | ||
| 31 | + | ||
| 23 | public String getType() { | 32 | public String getType() { |
| 24 | return type; | 33 | return type; |
| 25 | } | 34 | } |
| @@ -51,4 +60,12 @@ public class VideoMessage { | @@ -51,4 +60,12 @@ public class VideoMessage { | ||
| 51 | public void setDownloading(boolean downloading) { | 60 | public void setDownloading(boolean downloading) { |
| 52 | isDownloading = downloading; | 61 | isDownloading = downloading; |
| 53 | } | 62 | } |
| 63 | + | ||
| 64 | + public int getProgress() { | ||
| 65 | + return progress; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public void setProgress(int progress) { | ||
| 69 | + this.progress = progress; | ||
| 70 | + } | ||
| 54 | } | 71 | } |
app/src/main/java/com/cnlive/im/mode/VoiceMessage.java
| @@ -12,12 +12,21 @@ public class VoiceMessage { | @@ -12,12 +12,21 @@ public class VoiceMessage { | ||
| 12 | private CNVoiceMessage cnVoiceMessage; | 12 | private CNVoiceMessage cnVoiceMessage; |
| 13 | boolean isUserSend; | 13 | boolean isUserSend; |
| 14 | 14 | ||
| 15 | + private int progress; | ||
| 16 | + | ||
| 15 | public VoiceMessage(String type, CNVoiceMessage cnVoiceMessage, boolean isUserSend) { | 17 | public VoiceMessage(String type, CNVoiceMessage cnVoiceMessage, boolean isUserSend) { |
| 16 | this.type = type; | 18 | this.type = type; |
| 17 | this.cnVoiceMessage = cnVoiceMessage; | 19 | this.cnVoiceMessage = cnVoiceMessage; |
| 18 | this.isUserSend = isUserSend; | 20 | this.isUserSend = isUserSend; |
| 19 | } | 21 | } |
| 20 | 22 | ||
| 23 | + public VoiceMessage(String type, CNVoiceMessage cnVoiceMessage, boolean isUserSend, int progress) { | ||
| 24 | + this.type = type; | ||
| 25 | + this.cnVoiceMessage = cnVoiceMessage; | ||
| 26 | + this.isUserSend = isUserSend; | ||
| 27 | + this.progress = progress; | ||
| 28 | + } | ||
| 29 | + | ||
| 21 | public String getType() { | 30 | public String getType() { |
| 22 | return type; | 31 | return type; |
| 23 | } | 32 | } |
| @@ -41,4 +50,12 @@ public class VoiceMessage { | @@ -41,4 +50,12 @@ public class VoiceMessage { | ||
| 41 | public void setUserSend(boolean userSend) { | 50 | public void setUserSend(boolean userSend) { |
| 42 | isUserSend = userSend; | 51 | isUserSend = userSend; |
| 43 | } | 52 | } |
| 53 | + | ||
| 54 | + public int getProgress() { | ||
| 55 | + return progress; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public void setProgress(int progress) { | ||
| 59 | + this.progress = progress; | ||
| 60 | + } | ||
| 44 | } | 61 | } |
app/src/main/java/com/cnlive/im/ui/ChatRoomActivity.java
| @@ -74,7 +74,7 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | @@ -74,7 +74,7 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | ||
| 74 | 74 | ||
| 75 | private final int CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE = 0x2001; | 75 | private final int CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE = 0x2001; |
| 76 | 76 | ||
| 77 | - private ArrayList<String> groupChatOneListMy; | 77 | + private ArrayList<String> msgIds = new ArrayList<>(); |
| 78 | private String roomIdOne = "ChatRoom10"; | 78 | private String roomIdOne = "ChatRoom10"; |
| 79 | private EditText editText; | 79 | private EditText editText; |
| 80 | private Button send_messageOneBtn; | 80 | private Button send_messageOneBtn; |
| @@ -132,7 +132,8 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | @@ -132,7 +132,8 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | ||
| 132 | mHandler = new Handler(); | 132 | mHandler = new Handler(); |
| 133 | ChatUtil.setOnConnectStatusListener(connectStatusListener); | 133 | ChatUtil.setOnConnectStatusListener(connectStatusListener); |
| 134 | ChatUtil.setOnChatRoomActionListener(chatRoomActionListener); | 134 | ChatUtil.setOnChatRoomActionListener(chatRoomActionListener); |
| 135 | - ChatUtil.setOnReceiveMessageListener(receiveMessageListener); | 135 | + ChatUtil.setOnReceiveChatroomMessageListener(receiveMessageListener); |
| 136 | + ChatUtil.setUploadProgressListener(uploadProgressListener); | ||
| 136 | ChatUtil.setKickedOfflineListener(onKickedOfflineListener); | 137 | ChatUtil.setKickedOfflineListener(onKickedOfflineListener); |
| 137 | Intent intent = getIntent(); | 138 | Intent intent = getIntent(); |
| 138 | user_name_string = intent.getStringExtra("user_name_string"); | 139 | user_name_string = intent.getStringExtra("user_name_string"); |
| @@ -168,7 +169,6 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | @@ -168,7 +169,6 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | ||
| 168 | exit_chat1.setOnClickListener(this); | 169 | exit_chat1.setOnClickListener(this); |
| 169 | foundChatBtn.setOnClickListener(this); | 170 | foundChatBtn.setOnClickListener(this); |
| 170 | send_messageOneBtn.setOnClickListener(this); | 171 | send_messageOneBtn.setOnClickListener(this); |
| 171 | - groupChatOneListMy = new ArrayList<>(); | ||
| 172 | chatListAdapterOne = new ChatRoomAdpter(ChatRoomActivity.this, false); | 172 | chatListAdapterOne = new ChatRoomAdpter(ChatRoomActivity.this, false); |
| 173 | chatListAdapterOne.setonVoiceItemClickListener(this); | 173 | chatListAdapterOne.setonVoiceItemClickListener(this); |
| 174 | listViewOne.setLayoutManager(new LinearLayoutManager(ChatRoomActivity.this)); | 174 | listViewOne.setLayoutManager(new LinearLayoutManager(ChatRoomActivity.this)); |
| @@ -200,12 +200,12 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | @@ -200,12 +200,12 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | ||
| 200 | 200 | ||
| 201 | @Override | 201 | @Override |
| 202 | public void onSuccess(final CNBaseMessage o) { | 202 | public void onSuccess(final CNBaseMessage o) { |
| 203 | - updateItem(o); | 203 | + updateItem(o, -1); |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | @Override | 206 | @Override |
| 207 | public void onError(CNBaseMessage o, int i, String s) { | 207 | public void onError(CNBaseMessage o, int i, String s) { |
| 208 | - updateItem(o); | 208 | + updateItem(o, -1); |
| 209 | } | 209 | } |
| 210 | }; | 210 | }; |
| 211 | 211 | ||
| @@ -221,15 +221,25 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | @@ -221,15 +221,25 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | ||
| 221 | private IChat.OnReceiveMessageListener receiveMessageListener = new IChat.OnReceiveMessageListener() { | 221 | private IChat.OnReceiveMessageListener receiveMessageListener = new IChat.OnReceiveMessageListener() { |
| 222 | @Override | 222 | @Override |
| 223 | public void processMessage(final CNBaseMessage o) { | 223 | public void processMessage(final CNBaseMessage o) { |
| 224 | + if (!o.getTargetId().equals(roomIdOne)) return; | ||
| 224 | showMessage(o); | 225 | showMessage(o); |
| 225 | } | 226 | } |
| 226 | }; | 227 | }; |
| 227 | 228 | ||
| 229 | + private IChat.OnUploadProgressListener uploadProgressListener = new IChat.OnUploadProgressListener() { | ||
| 230 | + @Override | ||
| 231 | + public void onMessagesUpdate(CNBaseMessage message, int elemIdx, int taskId, int progress) { | ||
| 232 | + if (!message.getTargetId().equals(roomIdOne)) return; | ||
| 233 | + updateItem(message, progress); | ||
| 234 | + } | ||
| 235 | + }; | ||
| 236 | + | ||
| 237 | + | ||
| 228 | /** | 238 | /** |
| 229 | * 更新消息 | 239 | * 更新消息 |
| 230 | */ | 240 | */ |
| 231 | - public void updateItem(CNBaseMessage o) { | ||
| 232 | - int updateIndex = groupChatOneListMy.indexOf(o.getMessageId()); | 241 | + public void updateItem(CNBaseMessage o, int progress) { |
| 242 | + int updateIndex = msgIds.indexOf(o.getMessageId()); | ||
| 233 | if (updateIndex < 0 || chatListAdapterOne.getItemCount() <= 0 || updateIndex > chatListAdapterOne.getItemCount() - 1) | 243 | if (updateIndex < 0 || chatListAdapterOne.getItemCount() <= 0 || updateIndex > chatListAdapterOne.getItemCount() - 1) |
| 234 | return; | 244 | return; |
| 235 | if (o.getMsgType() == IChat.CN_MSG_TYPE_TEXT) { | 245 | if (o.getMsgType() == IChat.CN_MSG_TYPE_TEXT) { |
| @@ -237,18 +247,18 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | @@ -237,18 +247,18 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | ||
| 237 | chatListAdapterOne.updateItem(new StringMessage(MessageType.stringMessage, o1, o1.isSelf()), updateIndex); | 247 | chatListAdapterOne.updateItem(new StringMessage(MessageType.stringMessage, o1, o1.isSelf()), updateIndex); |
| 238 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_IMAGE) { | 248 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_IMAGE) { |
| 239 | CNImgMessage o1 = (CNImgMessage) o; | 249 | CNImgMessage o1 = (CNImgMessage) o; |
| 240 | - chatListAdapterOne.updateItem(new ImagMessage(MessageType.imaMessage, o1, o1.isSelf()), updateIndex); | 250 | + chatListAdapterOne.updateItem(new ImagMessage(MessageType.imaMessage, o1, o1.isSelf(), progress < 0 ? 0 : progress), updateIndex); |
| 241 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VOICE) { | 251 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VOICE) { |
| 242 | CNVoiceMessage o1 = (CNVoiceMessage) o; | 252 | CNVoiceMessage o1 = (CNVoiceMessage) o; |
| 243 | - VoiceMessage voiceMessage = new VoiceMessage(MessageType.voiceMessage, o1, o1.isSelf()); | 253 | + VoiceMessage voiceMessage = new VoiceMessage(MessageType.voiceMessage, o1, o1.isSelf(), progress < 0 ? 0 : progress); |
| 244 | chatListAdapterOne.updateItem(voiceMessage, updateIndex); | 254 | chatListAdapterOne.updateItem(voiceMessage, updateIndex); |
| 245 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VIDEO) { | 255 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VIDEO) { |
| 246 | CNVideoMessage ol = (CNVideoMessage) o; | 256 | CNVideoMessage ol = (CNVideoMessage) o; |
| 247 | - VideoMessage videoMessage = new VideoMessage(MessageType.videoMessage, ol, ol.isSelf()); | 257 | + VideoMessage videoMessage = new VideoMessage(MessageType.videoMessage, ol, ol.isSelf(), progress < 0 ? 0 : progress); |
| 248 | chatListAdapterOne.updateItem(videoMessage, updateIndex); | 258 | chatListAdapterOne.updateItem(videoMessage, updateIndex); |
| 249 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_UGC) { | 259 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_UGC) { |
| 250 | CNUgcMessage ol = (CNUgcMessage) o; | 260 | CNUgcMessage ol = (CNUgcMessage) o; |
| 251 | - UgcVideoMessage ugcVideoMessage = new UgcVideoMessage(MessageType.ugcVideoMessage, ol, ol.isSelf()); | 261 | + UgcVideoMessage ugcVideoMessage = new UgcVideoMessage(MessageType.ugcVideoMessage, ol, ol.isSelf(), progress < 0 ? 0 : progress); |
| 252 | chatListAdapterOne.updateItem(ugcVideoMessage, updateIndex); | 262 | chatListAdapterOne.updateItem(ugcVideoMessage, updateIndex); |
| 253 | } | 263 | } |
| 254 | } | 264 | } |
| @@ -259,7 +269,7 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | @@ -259,7 +269,7 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | ||
| 259 | * @param o | 269 | * @param o |
| 260 | */ | 270 | */ |
| 261 | private void showMessage(CNBaseMessage o) { | 271 | private void showMessage(CNBaseMessage o) { |
| 262 | - groupChatOneListMy.add(o.getMessageId()); | 272 | + msgIds.add(o.getMessageId()); |
| 263 | if (o.getMsgType() == IChat.CN_MSG_TYPE_TEXT) { | 273 | if (o.getMsgType() == IChat.CN_MSG_TYPE_TEXT) { |
| 264 | CNMessage o1 = (CNMessage) o; | 274 | CNMessage o1 = (CNMessage) o; |
| 265 | chatListAdapterOne.addItem(new StringMessage(MessageType.stringMessage, o1, o1.isSelf())); | 275 | chatListAdapterOne.addItem(new StringMessage(MessageType.stringMessage, o1, o1.isSelf())); |
| @@ -271,12 +281,12 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | @@ -271,12 +281,12 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | ||
| 271 | VoiceMessage voiceMessage = new VoiceMessage(MessageType.voiceMessage, o1, o1.isSelf()); | 281 | VoiceMessage voiceMessage = new VoiceMessage(MessageType.voiceMessage, o1, o1.isSelf()); |
| 272 | chatListAdapterOne.addItem(voiceMessage); | 282 | chatListAdapterOne.addItem(voiceMessage); |
| 273 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VIDEO) { | 283 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VIDEO) { |
| 274 | - CNVideoMessage ol = (CNVideoMessage) o; | ||
| 275 | - VideoMessage videoMessage = new VideoMessage(MessageType.videoMessage, ol, ol.isSelf()); | 284 | + CNVideoMessage o1 = (CNVideoMessage) o; |
| 285 | + VideoMessage videoMessage = new VideoMessage(MessageType.videoMessage, o1, o1.isSelf()); | ||
| 276 | chatListAdapterOne.addItem(videoMessage); | 286 | chatListAdapterOne.addItem(videoMessage); |
| 277 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_UGC) { | 287 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_UGC) { |
| 278 | - CNUgcMessage ol = (CNUgcMessage) o; | ||
| 279 | - UgcVideoMessage ugcVideoMessage = new UgcVideoMessage(MessageType.ugcVideoMessage, ol, ol.isSelf()); | 288 | + CNUgcMessage o1 = (CNUgcMessage) o; |
| 289 | + UgcVideoMessage ugcVideoMessage = new UgcVideoMessage(MessageType.ugcVideoMessage, o1, o1.isSelf()); | ||
| 280 | chatListAdapterOne.addItem(ugcVideoMessage); | 290 | chatListAdapterOne.addItem(ugcVideoMessage); |
| 281 | } | 291 | } |
| 282 | if (chatListAdapterOne.getItemCount() > 0) | 292 | if (chatListAdapterOne.getItemCount() > 0) |
| @@ -817,7 +827,10 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | @@ -817,7 +827,10 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL | ||
| 817 | @Override | 827 | @Override |
| 818 | protected void onDestroy() { | 828 | protected void onDestroy() { |
| 819 | super.onDestroy(); | 829 | super.onDestroy(); |
| 830 | + ChatUtil.removeUploadProgressListener(uploadProgressListener); | ||
| 820 | ChatUtil.removeReceiveMessageListener(receiveMessageListener); | 831 | ChatUtil.removeReceiveMessageListener(receiveMessageListener); |
| 821 | ChatUtil.removeConnectListener(connectListener); | 832 | ChatUtil.removeConnectListener(connectListener); |
| 833 | + ChatUtil.removeConnectStatusListener(connectStatusListener); | ||
| 822 | } | 834 | } |
| 835 | + | ||
| 823 | } | 836 | } |
app/src/main/java/com/cnlive/im/ui/PrivateActivity.java
| @@ -99,7 +99,7 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | @@ -99,7 +99,7 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | ||
| 99 | private EditText messageContent; | 99 | private EditText messageContent; |
| 100 | private Button sendMessageBtn; | 100 | private Button sendMessageBtn; |
| 101 | private ChatRoomAdpter chatListAdapter; | 101 | private ChatRoomAdpter chatListAdapter; |
| 102 | - private ArrayList<String> messageList = new ArrayList<>(); | 102 | + private ArrayList<String> msgIds = new ArrayList<>(); |
| 103 | // private CNMessage cnMessage; | 103 | // private CNMessage cnMessage; |
| 104 | private LinearLayout linearLayoutUseID; | 104 | private LinearLayout linearLayoutUseID; |
| 105 | private EditText user_id_edit; | 105 | private EditText user_id_edit; |
| @@ -144,6 +144,7 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | @@ -144,6 +144,7 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | ||
| 144 | mHandler = new Handler(); | 144 | mHandler = new Handler(); |
| 145 | ChatUtil.setOnConnectStatusListener(connectStatusListener); | 145 | ChatUtil.setOnConnectStatusListener(connectStatusListener); |
| 146 | ChatUtil.setOnReceivePrivateMessageListener(receiveMessageListener); | 146 | ChatUtil.setOnReceivePrivateMessageListener(receiveMessageListener); |
| 147 | + ChatUtil.setUploadProgressListener(uploadProgressListener); | ||
| 147 | requestPermission(); | 148 | requestPermission(); |
| 148 | } | 149 | } |
| 149 | 150 | ||
| @@ -414,12 +415,12 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | @@ -414,12 +415,12 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | ||
| 414 | 415 | ||
| 415 | @Override | 416 | @Override |
| 416 | public void onSuccess(final CNBaseMessage o) { | 417 | public void onSuccess(final CNBaseMessage o) { |
| 417 | - updateItem(o); | 418 | + updateItem(o, -1); |
| 418 | } | 419 | } |
| 419 | 420 | ||
| 420 | @Override | 421 | @Override |
| 421 | public void onError(CNBaseMessage o, int i, String s) { | 422 | public void onError(CNBaseMessage o, int i, String s) { |
| 422 | - updateItem(o); | 423 | + updateItem(o, -1); |
| 423 | } | 424 | } |
| 424 | }; | 425 | }; |
| 425 | 426 | ||
| @@ -436,15 +437,24 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | @@ -436,15 +437,24 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | ||
| 436 | private IChat.OnReceiveMessageListener receiveMessageListener = new IChat.OnReceiveMessageListener() { | 437 | private IChat.OnReceiveMessageListener receiveMessageListener = new IChat.OnReceiveMessageListener() { |
| 437 | @Override | 438 | @Override |
| 438 | public void processMessage(final CNBaseMessage o) { | 439 | public void processMessage(final CNBaseMessage o) { |
| 440 | + if (!o.getTargetId().equals(oppositeID)) return; | ||
| 439 | showMessage(o, true); | 441 | showMessage(o, true); |
| 440 | } | 442 | } |
| 441 | }; | 443 | }; |
| 442 | 444 | ||
| 445 | + private IChat.OnUploadProgressListener uploadProgressListener = new IChat.OnUploadProgressListener() { | ||
| 446 | + @Override | ||
| 447 | + public void onMessagesUpdate(CNBaseMessage message, int elemIdx, int taskId, int progress) { | ||
| 448 | + if (!message.getTargetId().equals(oppositeID)) return; | ||
| 449 | + updateItem(message, progress); | ||
| 450 | + } | ||
| 451 | + }; | ||
| 452 | + | ||
| 443 | /** | 453 | /** |
| 444 | * 更新消息 | 454 | * 更新消息 |
| 445 | */ | 455 | */ |
| 446 | - public void updateItem(CNBaseMessage o) { | ||
| 447 | - int updateIndex = messageList.indexOf(o.getMessageId()); | 456 | + public void updateItem(CNBaseMessage o, int progress) { |
| 457 | + int updateIndex = msgIds.indexOf(o.getMessageId()); | ||
| 448 | if (updateIndex < 0 || chatListAdapter.getItemCount() <= 0 || updateIndex > chatListAdapter.getItemCount() - 1) | 458 | if (updateIndex < 0 || chatListAdapter.getItemCount() <= 0 || updateIndex > chatListAdapter.getItemCount() - 1) |
| 449 | return; | 459 | return; |
| 450 | if (o.getMsgType() == IChat.CN_MSG_TYPE_TEXT) { | 460 | if (o.getMsgType() == IChat.CN_MSG_TYPE_TEXT) { |
| @@ -452,18 +462,18 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | @@ -452,18 +462,18 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | ||
| 452 | chatListAdapter.updateItem(new StringMessage(MessageType.stringMessage, o1, o1.isSelf()), updateIndex); | 462 | chatListAdapter.updateItem(new StringMessage(MessageType.stringMessage, o1, o1.isSelf()), updateIndex); |
| 453 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_IMAGE) { | 463 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_IMAGE) { |
| 454 | CNImgMessage o1 = (CNImgMessage) o; | 464 | CNImgMessage o1 = (CNImgMessage) o; |
| 455 | - chatListAdapter.updateItem(new ImagMessage(MessageType.imaMessage, o1, o1.isSelf()), updateIndex); | 465 | + chatListAdapter.updateItem(new ImagMessage(MessageType.imaMessage, o1, o1.isSelf(), progress < 0 ? 0 : progress), updateIndex); |
| 456 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VOICE) { | 466 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VOICE) { |
| 457 | CNVoiceMessage o1 = (CNVoiceMessage) o; | 467 | CNVoiceMessage o1 = (CNVoiceMessage) o; |
| 458 | - VoiceMessage voiceMessage = new VoiceMessage(MessageType.voiceMessage, o1, o1.isSelf()); | 468 | + VoiceMessage voiceMessage = new VoiceMessage(MessageType.voiceMessage, o1, o1.isSelf(), progress < 0 ? 0 : progress); |
| 459 | chatListAdapter.updateItem(voiceMessage, updateIndex); | 469 | chatListAdapter.updateItem(voiceMessage, updateIndex); |
| 460 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VIDEO) { | 470 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VIDEO) { |
| 461 | CNVideoMessage ol = (CNVideoMessage) o; | 471 | CNVideoMessage ol = (CNVideoMessage) o; |
| 462 | - VideoMessage videoMessage = new VideoMessage(MessageType.videoMessage, ol, ol.isSelf()); | 472 | + VideoMessage videoMessage = new VideoMessage(MessageType.videoMessage, ol, ol.isSelf(), progress < 0 ? 0 : progress); |
| 463 | chatListAdapter.updateItem(videoMessage, updateIndex); | 473 | chatListAdapter.updateItem(videoMessage, updateIndex); |
| 464 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_UGC) { | 474 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_UGC) { |
| 465 | CNUgcMessage ol = (CNUgcMessage) o; | 475 | CNUgcMessage ol = (CNUgcMessage) o; |
| 466 | - UgcVideoMessage ugcVideoMessage = new UgcVideoMessage(MessageType.ugcVideoMessage, ol, ol.isSelf()); | 476 | + UgcVideoMessage ugcVideoMessage = new UgcVideoMessage(MessageType.ugcVideoMessage, ol, ol.isSelf(), progress < 0 ? 0 : progress); |
| 467 | chatListAdapter.updateItem(ugcVideoMessage, updateIndex); | 477 | chatListAdapter.updateItem(ugcVideoMessage, updateIndex); |
| 468 | } | 478 | } |
| 469 | } | 479 | } |
| @@ -490,7 +500,7 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | @@ -490,7 +500,7 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | ||
| 490 | sendInfo = 4; | 500 | sendInfo = 4; |
| 491 | } else if ("4".equals(type)) { | 501 | } else if ("4".equals(type)) { |
| 492 | Log.v(TAG, o1.getContent().toString()); | 502 | Log.v(TAG, o1.getContent().toString()); |
| 493 | - messageList.add(o.getMessageId()); | 503 | + msgIds.add(o.getMessageId()); |
| 494 | chatListAdapter.addItem(new StringMessage(MessageType.stringMessage, o1, false)); | 504 | chatListAdapter.addItem(new StringMessage(MessageType.stringMessage, o1, false)); |
| 495 | } | 505 | } |
| 496 | } catch (JSONException e) { | 506 | } catch (JSONException e) { |
| @@ -512,28 +522,28 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | @@ -512,28 +522,28 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | ||
| 512 | } else if ("3".equals(type) && message.equals("同意")) { | 522 | } else if ("3".equals(type) && message.equals("同意")) { |
| 513 | sendInfo = 1; | 523 | sendInfo = 1; |
| 514 | } else if ("4".equals(type)) { | 524 | } else if ("4".equals(type)) { |
| 515 | - messageList.add(o.getMessageId()); | 525 | + msgIds.add(o.getMessageId()); |
| 516 | chatListAdapter.addItem(new StringMessage(MessageType.stringMessage, o1, true)); | 526 | chatListAdapter.addItem(new StringMessage(MessageType.stringMessage, o1, true)); |
| 517 | } | 527 | } |
| 518 | } catch (JSONException e) { | 528 | } catch (JSONException e) { |
| 519 | } | 529 | } |
| 520 | } | 530 | } |
| 521 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_IMAGE) { | 531 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_IMAGE) { |
| 522 | - messageList.add(o.getMessageId()); | 532 | + msgIds.add(o.getMessageId()); |
| 523 | CNImgMessage o1 = (CNImgMessage) o; | 533 | CNImgMessage o1 = (CNImgMessage) o; |
| 524 | chatListAdapter.addItem(new ImagMessage(MessageType.imaMessage, o1, o1.isSelf())); | 534 | chatListAdapter.addItem(new ImagMessage(MessageType.imaMessage, o1, o1.isSelf())); |
| 525 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VOICE) { | 535 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VOICE) { |
| 526 | - messageList.add(o.getMessageId()); | 536 | + msgIds.add(o.getMessageId()); |
| 527 | CNVoiceMessage o1 = (CNVoiceMessage) o; | 537 | CNVoiceMessage o1 = (CNVoiceMessage) o; |
| 528 | VoiceMessage voiceMessage = new VoiceMessage(MessageType.voiceMessage, o1, o1.isSelf()); | 538 | VoiceMessage voiceMessage = new VoiceMessage(MessageType.voiceMessage, o1, o1.isSelf()); |
| 529 | chatListAdapter.addItem(voiceMessage); | 539 | chatListAdapter.addItem(voiceMessage); |
| 530 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VIDEO) { | 540 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_VIDEO) { |
| 531 | - messageList.add(o.getMessageId()); | 541 | + msgIds.add(o.getMessageId()); |
| 532 | CNVideoMessage ol = (CNVideoMessage) o; | 542 | CNVideoMessage ol = (CNVideoMessage) o; |
| 533 | VideoMessage videoMessage = new VideoMessage(MessageType.videoMessage, ol, ol.isSelf()); | 543 | VideoMessage videoMessage = new VideoMessage(MessageType.videoMessage, ol, ol.isSelf()); |
| 534 | chatListAdapter.addItem(videoMessage); | 544 | chatListAdapter.addItem(videoMessage); |
| 535 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_UGC) { | 545 | } else if (o.getMsgType() == IChat.CN_MSG_TYPE_UGC) { |
| 536 | - messageList.add(o.getMessageId()); | 546 | + msgIds.add(o.getMessageId()); |
| 537 | CNUgcMessage ol = (CNUgcMessage) o; | 547 | CNUgcMessage ol = (CNUgcMessage) o; |
| 538 | UgcVideoMessage ugcVideoMessage = new UgcVideoMessage(MessageType.ugcVideoMessage, ol, ol.isSelf()); | 548 | UgcVideoMessage ugcVideoMessage = new UgcVideoMessage(MessageType.ugcVideoMessage, ol, ol.isSelf()); |
| 539 | chatListAdapter.addItem(ugcVideoMessage); | 549 | chatListAdapter.addItem(ugcVideoMessage); |
| @@ -874,7 +884,9 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | @@ -874,7 +884,9 @@ public class PrivateActivity extends AppCompatActivity implements View.OnClickLi | ||
| 874 | @Override | 884 | @Override |
| 875 | protected void onDestroy() { | 885 | protected void onDestroy() { |
| 876 | super.onDestroy(); | 886 | super.onDestroy(); |
| 887 | + ChatUtil.removeUploadProgressListener(uploadProgressListener); | ||
| 877 | ChatUtil.removeReceiveMessageListener(receiveMessageListener); | 888 | ChatUtil.removeReceiveMessageListener(receiveMessageListener); |
| 878 | ChatUtil.removeConnectListener(connectListener); | 889 | ChatUtil.removeConnectListener(connectListener); |
| 890 | + ChatUtil.removeConnectStatusListener(connectStatusListener); | ||
| 879 | } | 891 | } |
| 880 | } | 892 | } |
app/src/main/res/layout/imag_layout_item_user.xml
| @@ -13,6 +13,15 @@ | @@ -13,6 +13,15 @@ | ||
| 13 | android:orientation="horizontal"> | 13 | android:orientation="horizontal"> |
| 14 | 14 | ||
| 15 | <TextView | 15 | <TextView |
| 16 | + android:id="@+id/uploadProgress" | ||
| 17 | + android:layout_width="wrap_content" | ||
| 18 | + android:layout_height="wrap_content" | ||
| 19 | + android:layout_gravity="center_vertical" | ||
| 20 | + android:layout_marginRight="5dp" | ||
| 21 | + android:gravity="center" | ||
| 22 | + android:textColor="@android:color/black" /> | ||
| 23 | + | ||
| 24 | + <TextView | ||
| 16 | android:id="@+id/status" | 25 | android:id="@+id/status" |
| 17 | android:layout_width="wrap_content" | 26 | android:layout_width="wrap_content" |
| 18 | android:layout_height="wrap_content" | 27 | android:layout_height="wrap_content" |
app/src/main/res/layout/video_layout_item_user.xml
| @@ -13,6 +13,15 @@ | @@ -13,6 +13,15 @@ | ||
| 13 | android:layout_alignParentRight="true"> | 13 | android:layout_alignParentRight="true"> |
| 14 | 14 | ||
| 15 | <TextView | 15 | <TextView |
| 16 | + android:id="@+id/uploadProgress" | ||
| 17 | + android:layout_width="wrap_content" | ||
| 18 | + android:layout_height="wrap_content" | ||
| 19 | + android:layout_gravity="center_vertical" | ||
| 20 | + android:layout_marginRight="5dp" | ||
| 21 | + android:gravity="center" | ||
| 22 | + android:textColor="@android:color/black" /> | ||
| 23 | + | ||
| 24 | + <TextView | ||
| 16 | android:id="@+id/status" | 25 | android:id="@+id/status" |
| 17 | android:layout_width="wrap_content" | 26 | android:layout_width="wrap_content" |
| 18 | android:layout_height="wrap_content" | 27 | android:layout_height="wrap_content" |
app/src/main/res/layout/voice_layout_item_user.xml
| @@ -11,6 +11,15 @@ | @@ -11,6 +11,15 @@ | ||
| 11 | android:layout_alignParentRight="true"> | 11 | android:layout_alignParentRight="true"> |
| 12 | 12 | ||
| 13 | <TextView | 13 | <TextView |
| 14 | + android:id="@+id/uploadProgress" | ||
| 15 | + android:layout_width="wrap_content" | ||
| 16 | + android:layout_height="wrap_content" | ||
| 17 | + android:layout_gravity="center_vertical" | ||
| 18 | + android:layout_marginRight="5dp" | ||
| 19 | + android:gravity="center" | ||
| 20 | + android:textColor="@android:color/black" /> | ||
| 21 | + | ||
| 22 | + <TextView | ||
| 14 | android:id="@+id/status" | 23 | android:id="@+id/status" |
| 15 | android:layout_width="wrap_content" | 24 | android:layout_width="wrap_content" |
| 16 | android:layout_height="wrap_content" | 25 | android:layout_height="wrap_content" |