@Override
public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction();
int x = (int) event.getX();
int y = (int) event.getY();
switch (action) {
case MotionEvent.ACTION_DOWN:
//TODO
isRecording=true;
changeState(STATE_RECORDING);
return false;
case MotionEvent.ACTION_MOVE:
if (isRecording) {
// 根据x,y的坐标,判断是否想要取消录音
if (wantToCancel(x, y)) {
changeState(STATE_WANT_TO_CANCEL);
} else {
changeState(STATE_RECORDING);
}
}
break;
case MotionEvent.ACTION_UP:
if (mCurState == STATE_RECORDING) {
// 重置状态
// 通知主界面更新ListView
} else if (mCurState == STATE_WANT_TO_CANCEL) {
// 取消录音
}
reset();
break;
}
return super.onTouchEvent(event);
}