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();
}
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();
}
});
}
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();
}
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);
}
};
}
}
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);
}
};
}
Aggregations