Search in sources :

Example 6 with CountDownTimer

use of android.os.CountDownTimer in project StyleableToast by Muddz.

the class DurationTracker method trackToastDuration.

/**
     * Starts a {@link CountDownTimer} which counts down from the duration set in StyleableToast when {@link StyleableToast#show()} is called.
     */
public void trackToastDuration() {
    countDownTimer = new CountDownTimer(duration + EXTRA_DELAY, IN_SECONDS) {

        @Override
        public void onTick(long millisUntilFinished) {
        }

        @Override
        public void onFinish() {
            if (onToastFinished != null) {
                onToastFinished.onToastFinished();
            }
        }
    };
    countDownTimer.start();
}
Also used : CountDownTimer(android.os.CountDownTimer)

Example 7 with CountDownTimer

use of android.os.CountDownTimer in project android_frameworks_base by ResurrectionRemix.

the class UserInactivityCountdownDialog method show.

@Override
public void show() {
    super.show();
    final TextView messageView = (TextView) findViewById(R.id.message);
    messageView.post(new Runnable() {

        @Override
        public void run() {
            mCountDownTimer = new CountDownTimer(mCountDownDuration, mRefreshInterval) {

                @Override
                public void onTick(long millisUntilFinished) {
                    String msg = getContext().getString(R.string.demo_user_inactivity_timeout_countdown, millisUntilFinished / 1000);
                    messageView.setText(msg);
                }

                @Override
                public void onFinish() {
                    dismiss();
                    if (mOnCountDownExpiredListener != null)
                        mOnCountDownExpiredListener.onCountDownExpired();
                }
            }.start();
        }
    });
}
Also used : CountDownTimer(android.os.CountDownTimer) TextView(android.widget.TextView)

Example 8 with CountDownTimer

use of android.os.CountDownTimer in project android_frameworks_base by ResurrectionRemix.

the class KeyguardAbsKeyInputView method handleAttemptLockout.

// Prevent user from using the PIN/Password entry until scheduled deadline.
protected void handleAttemptLockout(long elapsedRealtimeDeadline) {
    setPasswordEntryEnabled(false);
    long elapsedRealtime = SystemClock.elapsedRealtime();
    new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime, 1000) {

        @Override
        public void onTick(long millisUntilFinished) {
            int secondsRemaining = (int) (millisUntilFinished / 1000);
            mSecurityMessageDisplay.setMessage(R.string.kg_too_many_failed_attempts_countdown, true, secondsRemaining);
        }

        @Override
        public void onFinish() {
            mSecurityMessageDisplay.setMessage("", false);
            resetState();
        }
    }.start();
}
Also used : CountDownTimer(android.os.CountDownTimer)

Example 9 with CountDownTimer

use of android.os.CountDownTimer in project Atom_Android by Rogrand-Dev.

the class CountDownButton method init.

private void init(Context context, AttributeSet attrs) {
    // 获取自定义属性值
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CountDownButton);
    mCountDownFormat = typedArray.getString(R.styleable.CountDownButton_countDownFormat);
    if (typedArray.hasValue(R.styleable.CountDownButton_countDown)) {
        mCount = (int) typedArray.getFloat(R.styleable.CountDownButton_countDown, DEFAULT_COUNT);
    }
    mInterval = (int) typedArray.getFloat(R.styleable.CountDownButton_countDownInterval, DEFAULT_INTERVAL);
    mEnableCountDown = (mCount > mInterval) && typedArray.getBoolean(R.styleable.CountDownButton_enableCountDown, false);
    typedArray.recycle();
    // 初始化倒计时Timer
    if (mCountDownTimer == null) {
        mCountDownTimer = new CountDownTimer(mCount, mInterval) {

            @Override
            public void onTick(long millisUntilFinished) {
                setText(String.format(Locale.CHINA, mCountDownFormat, millisUntilFinished / 1000));
            }

            @Override
            public void onFinish() {
                isCountDownNow = false;
                mEnableCountDown = false;
                setEnabled(true);
                setClickable(true);
                setText(mDefaultText);
            }
        };
    }
}
Also used : TypedArray(android.content.res.TypedArray) CountDownTimer(android.os.CountDownTimer)

Example 10 with CountDownTimer

use of android.os.CountDownTimer in project ride-read-android by Ride-Read.

the class LoginFragment method initView.

@Override
public void initView() {
    String latestPhone = UserUtils.getPhone();
    if (!TextUtils.isEmpty(latestPhone)) {
        mEdtLoginAccount.setText(latestPhone);
        mEdtLoginAccount.setSelection(latestPhone.length());
    }
    mEdtLoginAccount.setOnEditorActionListener(this);
    mEdtLoginPwd.setOnEditorActionListener(this);
    mEdtCode.setOnEditorActionListener(this);
    mEdtPassword.setOnEditorActionListener(this);
    mEdtPasswordConfirm.setOnEditorActionListener(this);
    mDownTimer = new CountDownTimer(60 * 1000, 1000) {

        @Override
        public void onTick(long l) {
            mTvSendCode.setClickable(false);
            mTvSendCode.setText((l / 1000) + "s后重新发送");
        }

        @Override
        public void onFinish() {
            mTvSendCode.setClickable(true);
            mTvSendCode.setText(R.string.resend);
        }
    };
}
Also used : CountDownTimer(android.os.CountDownTimer)

Aggregations

CountDownTimer (android.os.CountDownTimer)24 TextView (android.widget.TextView)4 Test (org.junit.Test)2 SharedPreferences (android.content.SharedPreferences)1 TypedArray (android.content.res.TypedArray)1 View (android.view.View)1 WebSettingsClassic (android.webkit.WebSettingsClassic)1 CheckBox (android.widget.CheckBox)1 EditText (android.widget.EditText)1 SweetAlertDialog (cn.pedant.SweetAlert.SweetAlertDialog)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 AVException (com.avos.avoscloud.AVException)1 RequestMobileCodeCallback (com.avos.avoscloud.RequestMobileCodeCallback)1 HmsPicker (com.doomonafireball.betterpickers.hmspicker.HmsPicker)1 HmsView (com.doomonafireball.betterpickers.hmspicker.HmsView)1 MarkerUpdate (com.omkarmoghe.pokemap.models.events.MarkerUpdate)1 Timer (java.util.Timer)1 Before (org.junit.Before)1