Code example for Handler

Methods: removeMessagessendEmptyMessageDelayed

0
        mListener.setFocusParameters();
        if (mFocusAreaSupported) {
            autoFocus(); 
        } else {  // Just show the indicator in all other cases. 
            updateFocusUI(); 
            mHandler.removeMessages(RESET_TOUCH_FOCUS);
            if (mFocusTime != 0) {
                mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, mFocusTime);
            } 
        } 
    } 
 
    public void onPreviewStarted() { 
        mState = STATE_IDLE;
    } 
 
    public void onPreviewStopped() { 
        // If auto focus was in progress, it would have been stopped. 
        mState = STATE_IDLE;
        resetTouchFocus(); 
        updateFocusUI(); 
    } 
 
    public void onCameraReleased() { 
        onPreviewStopped(); 
    } 
 
    private void autoFocus() { 
        Log.v(TAG, "Start autofocus.");
        mListener.autoFocus();
        mState = STATE_FOCUSING;
        // Pause the face view because the driver will keep sending face 
        // callbacks after the focus completes. 
        if (mFaceView != null) mFaceView.pause();
        updateFocusUI(); 
        mHandler.removeMessages(RESET_TOUCH_FOCUS);
    } 
 
    private void cancelAutoFocus() { 
        Log.v(TAG, "Cancel autofocus.");
 
        // Reset the tap area before calling mListener.cancelAutofocus. 
        // Otherwise, focus mode stays at auto and the tap area passed to the 
        // driver is not reset. 
        resetTouchFocus(); 
        mListener.cancelAutoFocus();
        if (mFaceView != null) mFaceView.resume();
        mState = STATE_IDLE;
        updateFocusUI(); 
        mHandler.removeMessages(RESET_TOUCH_FOCUS);
    } 
 
    private void capture() { 
        if (mListener.capture()) {
            mState = STATE_IDLE;