コード例 #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
ファイル: BaseActivity.java プロジェクト: fwjynll/Git_learn
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   // TODO Auto-generated method stub
   super.onCreate(savedInstanceState);
   userManager = BmobUserManager.getInstance(this);
   manager = BmobChatManager.getInstance(this);
   mApplication = CustomApplcation.getInstance();
   DisplayMetrics metric = new DisplayMetrics();
   getWindowManager().getDefaultDisplay().getMetrics(metric);
   mScreenWidth = metric.widthPixels;
   mScreenHeight = metric.heightPixels;
 }
コード例 #4
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   manager = BmobChatManager.getInstance(this);
   MsgPagerNum = 0;
   // 组装聊天对象
   targetUser = (BmobChatUser) getIntent().getSerializableExtra("user");
   targetId = targetUser.getObjectId();
   //		BmobLog.i("聊天对象:" + targetUser.getUsername() + ",targetId = "
   //				+ targetId);
   // 注册广播接收器
   initNewMessageBroadCast();
   initView();
 }
コード例 #5
0
 public void handleMessage(Message msg) {
   if (msg.what == NEW_MESSAGE) {
     BmobMsg message = (BmobMsg) msg.obj;
     String uid = message.getBelongId();
     BmobMsg m =
         BmobChatManager.getInstance(ChatActivity.this)
             .getMessage(message.getConversationId(), message.getMsgTime());
     if (!uid.equals(targetId)) // 如果不是当前正在聊天对象的消息,不处理
     return;
     mAdapter.add(m);
     // 定位
     mListView.setSelection(mAdapter.getCount() - 1);
     // 取消当前聊天对象的未读标示
     BmobDB.create(ChatActivity.this).resetUnread(targetId);
   }
 }
コード例 #6
0
 @Override
 public void onReceive(Context context, Intent intent) {
   String from = intent.getStringExtra("fromId");
   String msgId = intent.getStringExtra("msgId");
   String msgTime = intent.getStringExtra("msgTime");
   // 收到这个广播的时候,message已经在消息表中,可直接获取
   if (TextUtils.isEmpty(from) && TextUtils.isEmpty(msgId) && TextUtils.isEmpty(msgTime)) {
     BmobMsg msg = BmobChatManager.getInstance(ChatActivity.this).getMessage(msgId, msgTime);
     if (!from.equals(targetId)) // 如果不是当前正在聊天对象的消息,不处理
     return;
     // 添加到当前页面
     mAdapter.add(msg);
     // 定位
     mListView.setSelection(mAdapter.getCount() - 1);
     // 取消当前聊天对象的未读标示
     BmobDB.create(ChatActivity.this).resetUnread(targetId);
   }
   // 记得把广播给终结掉
   abortBroadcast();
 }
コード例 #7
0
ファイル: BaseActivity.java プロジェクト: skywish/CallMeUp
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   userManager = BmobUserManager.getInstance(this);
   manager = BmobChatManager.getInstance(this);
 }