Java Code Examples for com.android.nfc.beam.SendUi

Following code examples demonstrate how to use com.android.nfc.beam.SendUifrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.android.nfc.beam.SendUiand various code implementation of this class.

        if (mSending) {
            mNfcService.playSound(NfcService.SOUND_ERROR);
            mSending = false;
        } 


    public void onP2pReceiveComplete(boolean playSound) {
        mVibrator.vibrate(VIBRATION_PATTERN, -1);
        if (playSound) mNfcService.playSound(NfcService.SOUND_END);
        if (mSendUi != null) {
            mSendUi.finish(SendUi.FINISH_SCALE_UP);
        }
        mNdefReceived = true;
    } 

    public void onP2pSendConfirmationRequested() {
        mNfcService.playSound(NfcService.SOUND_START);
        mVibrator.vibrate(VIBRATION_PATTERN, -1);
        if (mSendUi != null) {
            mSendUi.showPreSend(false);
        } else {
            mCallback.onP2pSendConfirmed();
        }
    } 

    public void onP2pSendComplete() {
        mNfcService.playSound(NfcService.SOUND_END);
        mVibrator.vibrate(VIBRATION_PATTERN, -1);
        if (mSendUi != null) {
            mSendUi.finish(SendUi.FINISH_SEND_SUCCESS);
        }
        mSending = false;
        mNdefSent = true;
    } 

    public void onP2pHandoverNotSupported() {
        mNfcService.playSound(NfcService.SOUND_ERROR);
        mVibrator.vibrate(VIBRATION_PATTERN, -1);
        mSendUi.finishAndToast(SendUi.FINISH_SCALE_UP,
                mContext.getString(R.string.beam_handover_not_supported));
        mSending = false;
        mNdefSent = false;
    } 

        if (mInDebounce) {
            if (mSendUi != null) {
                mSendUi.showStartSend();
            }
        } 

    public void onCanceled() {
        mSendUi.finish(SendUi.FINISH_SCALE_UP);
        mCallback.onP2pCanceled();
    } 

    public void onP2pTimeoutWaitingForLink() {
        if (mSendUi != null) {
            mSendUi.finish(SendUi.FINISH_SCALE_UP);
        }
    } 

    public void onSendConfirmed() {
        if (!mSending) {
            if (mSendUi != null) {
                mSendUi.showStartSend();
            }
            mCallback.onP2pSendConfirmed();
        }
        mSending = true;

    } 

    public void onP2pInRange() {
        mNdefSent = false;
        mNdefReceived = false;
        mInDebounce = false;

        if (mSendUi != null) {
            mSendUi.takeScreenshot();
        }
    } 

    public void onP2pSendDebounce() {
        mInDebounce = true;
        mNfcService.playSound(NfcService.SOUND_ERROR);
        if (mSendUi != null) {
            mSendUi.showSendHint();
        }
    } 

    public void onP2pHandoverBusy() {
        mNfcService.playSound(NfcService.SOUND_ERROR);
        mVibrator.vibrate(VIBRATION_PATTERN, -1);
        mSendUi.finishAndToast(SendUi.FINISH_SCALE_UP, mContext.getString(R.string.beam_busy));
        mSending = false;
        mNdefSent = false;
    } 

    public void onP2pNfcTapRequested() {
        mNfcService.playSound(NfcService.SOUND_START);
        mNdefSent = false;
        mNdefReceived = false;
        mInDebounce = false;

        mVibrator.vibrate(VIBRATION_PATTERN, -1);
        if (mSendUi != null) {
            mSendUi.takeScreenshot();
            mSendUi.showPreSend(true);
        }
    } 

Advertisement
Javadoc
This class is responsible for handling the UI animation around Android Beam. The animation consists

of the following animators: mPreAnimator: scales the screenshot down to INTERMEDIATE_SCALE mSlowSendAnimator: scales the screenshot down to 0.2f (used as a "send in progress" animation) mFastSendAnimator: quickly scales the screenshot down to 0.0f (used for send success) mFadeInAnimator: fades the current activity back in (used after mFastSendAnimator completes) mScaleUpAnimator: scales the screenshot back up to full screen (used for failure or receiving) mHintAnimator: Slowly turns up the alpha of the "Touch to Beam" hint Possible sequences are: mPreAnimator => mSlowSendAnimator => mFastSendAnimator => mFadeInAnimator (send success) mPreAnimator => mSlowSendAnimator => mScaleUpAnimator (send failure) mPreAnimator => mScaleUpAnimator (p2p link broken, or data received) Note that mFastSendAnimator and mFadeInAnimator are combined in a set, as they are an atomic animation that cannot be interrupted. All methods of this class must be called on the UI thread

Read More
Related Classes
Advertisement