@Override public void handleMessage(android.os.Message msg) { super.handleMessage(msg); RecordVoiceBtn controller = mController.get(); if (controller != null) { switch (msg.what) { case SEND_CALLBACK: int status = msg.getData().getInt("status", -1); if (status == 803008) { return; } else if (status != 0) { } controller.mMsgListAdapter.notifyDataSetChanged(); break; case START_RECORD: if (mIsPressed) controller.initDialogAndStartRecord(); break; } } }
@Override public void handleMessage(android.os.Message msg) { RecordVoiceBtn controller = mController.get(); if (controller != null) { int restTime = msg.getData().getInt("restTime", -1); // 若restTime>0, 进入倒计时 if (restTime > 0) { controller.mTimeUp = true; android.os.Message msg1 = controller.mVolumeHandler.obtainMessage(); msg1.what = 60 - restTime + 1; Bundle bundle = new Bundle(); bundle.putInt("restTime", restTime - 1); msg1.setData(bundle); // 创建一个延迟一秒执行的HandlerMessage,用于倒计时 controller.mVolumeHandler.sendMessageDelayed(msg1, 1000); controller.mRecordHintTv.setText( String.format( controller.mContext.getString(R.string.rest_record_time_hint), restTime)); // 倒计时结束,发送语音, 重置状态 } else if (restTime == 0) { controller.finishRecord(); controller.setPressed(false); controller.mTimeUp = false; // restTime = -1, 一般情况 } else { // 没有进入倒计时状态 if (!controller.mTimeUp) { if (msg.what < CANCEL_RECORD) { controller.mRecordHintTv.setBackgroundColor(Color.TRANSPARENT); controller.mRecordHintTv.setText( controller.mContext.getString(R.string.move_to_cancel_hint)); } else { controller.mRecordHintTv.setBackgroundColor(Color.RED); controller.mRecordHintTv.setText( controller.mContext.getString(R.string.cancel_record_voice_hint)); } // 进入倒计时 } else { if (msg.what == CANCEL_RECORD) { controller.mRecordHintTv.setText( controller.mContext.getString(R.string.cancel_record_voice_hint)); if (!mIsPressed) controller.cancelRecord(); } } // if (msg.what >=0 && msg.what < 5){ // controller.mChatView.setWaveHeight(msg.what); // } if (controller.mVolumeIv != null) { controller.mVolumeIv.setImageResource(res[msg.what]); } // if (msg.what <=3) { // // controller.mChatView.getRecordAnimImage().setImageResource(recordRes[msg.what]); // } else { // // controller.mChatView.getRecordAnimImage().setImageResource(recordRes[3]); // } } } }