本文整理匯總了Java中android.os.CountDownTimer類的典型用法代碼示例。如果您正苦於以下問題:Java CountDownTimer類的具體用法?Java CountDownTimer怎麽用?Java CountDownTimer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CountDownTimer類屬於android.os包,在下文中一共展示了CountDownTimer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resumeRecording
import android.os.CountDownTimer; //導入依賴的package包/類
protected void resumeRecording() {
if (paused) {
paused = false;
timer = new CountDownTimer(milisUntilFinished, 100) {
@Override
public void onTick(long millisUntilFinished) {
handleClockTick(millisUntilFinished);
DCDashboardFragment.this.milisUntilFinished = millisUntilFinished;
}
@Override
public void onFinish() {
stopRecording();
}
};
timer.start();
updateView();
}
}
示例2: onStartCommand
import android.os.CountDownTimer; //導入依賴的package包/類
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// 第一個參數是總時間, 第二個參數是間隔
mCodeTimer = new CountDownTimer(129000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
// 廣播剩餘時間
broadcastUpdate(IN_RUNNING, millisUntilFinished / 1000 + "");
}
@Override
public void onFinish() {
// 廣播倒計時結束
broadcastUpdate(END_RUNNING);
// 停止服務
stopSelf();
}
};
// 開始倒計時
mCodeTimer.start();
return super.onStartCommand(intent, flags, startId);
}
示例3: onStartCommand
import android.os.CountDownTimer; //導入依賴的package包/類
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// 第一個參數是總時間, 第二個參數是間隔
mCodeTimer = new CountDownTimer(60000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
// 廣播剩餘時間
broadcastUpdate(IN_RUNNING, millisUntilFinished / 1000 + "");
}
@Override
public void onFinish() {
// 廣播倒計時結束
broadcastUpdate(END_RUNNING);
// 停止服務
stopSelf();
}
};
// 開始倒計時
mCodeTimer.start();
return super.onStartCommand(intent, flags, startId);
}
示例4: initCountDownTimer
import android.os.CountDownTimer; //導入依賴的package包/類
/**
* init countdown timer
*
* @param timeSeconds total time in seconds to countdown
*/
void initCountDownTimer(int timeSeconds) {
mCountDownTimer = new CountDownTimer(timeSeconds * 1000 + 100, 1000) {
@Override
public void onTick(long millisUntilFinished) {
mTvTimer.setText(Long.toString(millisUntilFinished / 1000));
}
@Override
public void onFinish() {
mTvTimer.setText("0");
mCurPokeQuiz.finishQuestion();
showResult(R.string.quiz_result_timeout);
}
};
}
示例5: testPreviewFrameCallCount
import android.os.CountDownTimer; //導入依賴的package包/類
/**
* 測試PreviewFrame回調次數,時間1分鍾
*
*/
public void testPreviewFrameCallCount() {
new CountDownTimer(1 * 60 * 1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
Log.e("[Vitamio Recorder]", "testFrameRate..." + mPreviewFrameCallCount);
mPreviewFrameCallCount = 0;
}
@Override
public void onFinish() {
}
}.start();
}
示例6: startTimer
import android.os.CountDownTimer; //導入依賴的package包/類
public void startTimer(){
if(!isBegin){
isBegin = true;
timerview.setBackground(getResources().getDrawable(R.drawable.shape_bo_grey_cccccc_r4dp));
timerview.setTextColor(ColorStateList.valueOf(ContextCompat.getColor(getContext(),R.color.grey_cccccc)));
new CountDownTimer(60000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
timerview.setText(millisUntilFinished/1000 + "s");
}
@Override
public void onFinish() {
timerview.setBackground(getResources().getDrawable(R.drawable.shape_bo_white_r4dp));
timerview.setTextColor(ColorStateList.valueOf(ContextCompat.getColor(getContext(),R.color.white)));
timerview.setText("獲取驗證碼");
isBegin = false;
}
}.start();
}
}
示例7: setLoadingCircledImageView
import android.os.CountDownTimer; //導入依賴的package包/類
public void setLoadingCircledImageView() {
mCircledImageText.setText(R.string.loading);
mCircledImage.setImageResource(R.drawable.stop);
mCircledImage.setCircleBorderColor(mColorAccent);
mCountDownTimer =
new CountDownTimer(10000, 10) {
@Override
public void onTick(long millisUntilFinished) {
float timeElapsed = (10000.0f - millisUntilFinished) / 10000.0f;
mCircledImage.setProgress(timeElapsed);
}
@Override
public void onFinish() {
setStartCircledImageView();
}
}.start();
}
示例8: startDown
import android.os.CountDownTimer; //導入依賴的package包/類
/**
* [倒計為time長的時間,時間間隔為mills]
* @param time
* @param mills
*/
public void startDown(long time, long mills) {
mCountDownTimer = new CountDownTimer(time, mills) {
@Override
public void onTick(long millisUntilFinished) {
if (listener != null) {
listener.onTick(millisUntilFinished);
} else {
NLog.e(TAG, "DownTimerListener can not be null");
}
}
@Override
public void onFinish() {
if (listener != null) {
listener.onFinish();
} else {
NLog.e(TAG, "DownTimerListener can not be null");
}
if (mCountDownTimer != null)mCountDownTimer.cancel();
}
} .start();
}
示例9: msgLong
import android.os.CountDownTimer; //導入依賴的package包/類
/**
* Long toast message
* TOAST_DURATION_MILLS controls the duration
* currently set to 6 seconds
* @param context Application Context
* @param msg Message to send
*/
public static void msgLong(final Context context, final String msg) {
if (context != null && msg != null) {
if (toast != null) {
toast.cancel();
}
new Handler(context.getMainLooper()).post(new Runnable() {
@Override
public void run() {
toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
new CountDownTimer(Math.max(TOAST_DURATION_MILLS - SHORT_TOAST_DURATION, 1000), 1000) {
@Override
public void onFinish() {
toast.show();
}
@Override
public void onTick(long millisUntilFinished) {
toast.show();
}
}.start();
}
});
}
}
示例10: onCreate
import android.os.CountDownTimer; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new CountDownTimer(1200, 1200) {
@Override
public void onTick(long l) {
}
@Override
public void onFinish() {
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
}
}.start();
}
示例11: getCountDownInstance
import android.os.CountDownTimer; //導入依賴的package包/類
/**
* 倒計時,不需要手動開啟和結束,僅中途取消需要手動cancel
*
* @param millisInFuture
* 總時間
* @param countDownInterval
* 間隔時間
* @param timerListener
* 響應回調
* @return
*/
public static CountDownTimer getCountDownInstance(long millisInFuture,
long countDownInterval, final TimerListener timerListener) {
if (timerListener == null)
return null;
return new CountDownTimer(millisInFuture, countDownInterval) {
@Override
public void onTick(long millisUntilFinished) {
timerListener.onTimerUpdate(millisUntilFinished);
}
@Override
public void onFinish() {
timerListener.onTimerStop();
}
}.start();
}
示例12: startCounting
import android.os.CountDownTimer; //導入依賴的package包/類
public void startCounting(long cdtTime){
if(cdt != null){
cdt.cancel();
}
cdt = new CountDownTimer(cdtTime, 1000) {
@Override
public void onTick(long l) {
textCount.setText("seconds remaining: " + l / 1000);
}
@Override
public void onFinish() {
textCount.setText(getString(R.string.count_default));
}
}.start();
}
示例13: start
import android.os.CountDownTimer; //導入依賴的package包/類
public void start() {
if (skip()) {
return;
}
//判斷該類角色是否有幸存者
long time = new Random().nextInt((int) millisInFuture);
if (isCanRandom) {
if (time < 3000) {
time = 3000;
}
} else {
time = millisInFuture;
}
new CountDownTimer(time, COUNT_DOWN_INTERVAL) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
runnable.run();
}
}.start();
}
示例14: doTimer
import android.os.CountDownTimer; //導入依賴的package包/類
private void doTimer(long time) {
if (timer != null) {
timer.cancel();
}
timer = new CountDownTimer(time, 1000) {
@Override
public void onTick(long millisUntilFinished) {
// day_v.setVisibility(View.VISIBLE);
// day_timer_tv.setText(millisUntilFinished / 1000 + " s");
DialogManager.showGameDay(GameActivity.this, myRole_v, null, null, millisUntilFinished / 1000 + " s");
}
@Override
public void onFinish() {
// day_v.setVisibility(View.GONE);
DialogManager.dismissDialog();
}
}.start();
}
示例15: startMain
import android.os.CountDownTimer; //導入依賴的package包/類
private void startMain() {
new CountDownTimer(500, 500) {
@Override
public void onTick(long millisUntilFinished) {
Log.d("Timer", "Timer ok");
}
@Override
public void onFinish() {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
close();
}
}.start();
}