示例#1
0
  /**
   * 重发图片消息 @Title: resendImageMsg
   *
   * @param @param parentV
   * @param @param values
   * @return void
   * @throws
   */
  private void resendFileMsg(final View parentV, final Object values) {
    BmobChatManager.getInstance(ChatActivity.this)
        .resendFileMessage(
            targetUser,
            (BmobMsg) values,
            new UploadListener() {

              @Override
              public void onStart(BmobMsg msg) {}

              @Override
              public void onSuccess() {
                ((BmobMsg) values).setStatus(BmobConfig.STATUS_SEND_SUCCESS);
                parentV.findViewById(R.id.progress_load).setVisibility(View.INVISIBLE);
                parentV.findViewById(R.id.iv_fail_resend).setVisibility(View.INVISIBLE);
                if (((BmobMsg) values).getMsgType() == BmobConfig.TYPE_VOICE) {
                  parentV.findViewById(R.id.tv_send_status).setVisibility(View.GONE);
                  parentV.findViewById(R.id.tv_voice_length).setVisibility(View.VISIBLE);
                } else {
                  parentV.findViewById(R.id.tv_send_status).setVisibility(View.VISIBLE);
                  ((TextView) parentV.findViewById(R.id.tv_send_status)).setText("已发送");
                }
              }

              @Override
              public void onFailure(int arg0, String arg1) {
                ((BmobMsg) values).setStatus(BmobConfig.STATUS_SEND_FAIL);
                parentV.findViewById(R.id.progress_load).setVisibility(View.INVISIBLE);
                parentV.findViewById(R.id.iv_fail_resend).setVisibility(View.VISIBLE);
                parentV.findViewById(R.id.tv_send_status).setVisibility(View.INVISIBLE);
              }
            });
    mAdapter.notifyDataSetChanged();
  }
示例#2
0
  /** 重发文本消息 */
  private void resendTextMsg(final View parentV, final Object values) {
    BmobChatManager.getInstance(ChatActivity.this)
        .resendTextMessage(
            targetUser,
            (BmobMsg) values,
            new PushListener() {

              @Override
              public void onSuccess() {
                Log.i("yuyang", "发送成功");
                ((BmobMsg) values).setStatus(BmobConfig.STATUS_SEND_SUCCESS);
                parentV.findViewById(R.id.progress_load).setVisibility(View.INVISIBLE);
                parentV.findViewById(R.id.iv_fail_resend).setVisibility(View.INVISIBLE);
                parentV.findViewById(R.id.tv_send_status).setVisibility(View.VISIBLE);
                ((TextView) parentV.findViewById(R.id.tv_send_status)).setText("已发送");
              }

              @Override
              public void onFailure(int arg0, String arg1) {
                Log.i("yuyang", "发送失败:" + arg1);
                ((BmobMsg) values).setStatus(BmobConfig.STATUS_SEND_FAIL);
                parentV.findViewById(R.id.progress_load).setVisibility(View.INVISIBLE);
                parentV.findViewById(R.id.iv_fail_resend).setVisibility(View.VISIBLE);
                parentV.findViewById(R.id.tv_send_status).setVisibility(View.INVISIBLE);
              }
            });
    mAdapter.notifyDataSetChanged();
  }
示例#3
0
 @Override
 public void onReaded(String conversionId, String msgTime) {
   // 此处应该过滤掉不是和当前用户的聊天的回执消息界面的刷新
   if (conversionId.split("&")[1].equals(targetId)) {
     // 修改界面上指定消息的阅读状态
     for (BmobMsg msg : mAdapter.getList()) {
       if (msg.getConversationId().equals(conversionId) && msg.getMsgTime().equals(msgTime)) {
         msg.setStatus(BmobConfig.STATUS_SEND_RECEIVERED);
       }
       mAdapter.notifyDataSetChanged();
     }
   }
 }
示例#4
0
 /**
  * 界面刷新 @Title: initOrRefresh
  *
  * @param
  * @return void
  * @throws
  */
 private void initOrRefresh() {
   if (mAdapter != null) {
     if (MyMessageReceiver.mNewNum != 0) { // 用于更新当在聊天界面锁屏期间来了消息,这时再回到聊天页面的时候需要显示新来的消息
       int news = MyMessageReceiver.mNewNum; // 有可能锁屏期间,来了N条消息,因此需要倒叙显示在界面上
       int size = initMsgData().size();
       for (int i = (news - 1); i >= 0; i--) {
         mAdapter.add(initMsgData().get(size - (i + 1))); // 添加最后一条消息到界面显示
       }
       mListView.setSelection(mAdapter.getCount() - 1);
     } else {
       mAdapter.notifyDataSetChanged();
     }
   } else {
     mAdapter = new MessageChatAdapter(this, initMsgData());
     mListView.setAdapter(mAdapter);
   }
 }