本文整理汇总了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();
}