本文整理了Java中android.os.CountDownTimer
类的一些代码示例,展示了CountDownTimer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CountDownTimer
类的具体详情如下:
包路径:android.os.CountDownTimer
类名称:CountDownTimer
暂无
代码示例来源:origin: guardianproject/haven
public void stopHeartbeatTimer ()
{
mCountdownTimer.cancel();
mCountdownTimer = null;
Log.d("HEARTBEAT TIMER", "Stopped" );
}
代码示例来源:origin: guardianproject/haven
private void initTimer() {
txtTimer.setTextColor(getResources().getColor(R.color.colorAccent));
cTimer = new CountDownTimer((preferences.getTimerDelay()) * 1000, 1000) {
public void onTick(long millisUntilFinished) {
mOnTimerTicking = true;
txtTimer.setText(getTimerText(millisUntilFinished));
}
public void onFinish() {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
txtTimer.setText(R.string.status_on);
initMonitor();
mOnTimerTicking = false;
}
};
cTimer.start();
}
代码示例来源:origin: robolectric/robolectric
public void invokeFinish() {
countDownTimer.onFinish();
}
代码示例来源:origin: AmazMod/AmazMod
private static void checkSave(final Context context) {
//Create timer if not already, for 2 seconds. Call save after completion
if (countDownTimer == null) countDownTimer = new CountDownTimer(2000, 2000) {
@Override
public void onTick(long l) {
}
@Override
public void onFinish() {
save(context);
}
};
//Cancel and start timer. This means that this method must be called ONCE in 2 seconds before save will be called, it prevents save from being called more than once every 2 seconds (buffers moving)
countDownTimer.cancel();
countDownTimer.start();
}
代码示例来源:origin: stackoverflow.com
cd = new CountDownTimer(300000, 1000) {
lastPressedButton = blue;
if (blueTimer.getText().toString().contains("5:00")){
cd.start();
cd.cancel();
cd.onFinish();
lastPressedButton = red;
if (redTimer.getText().toString().contains("5:00")){
cd.start();
} else {
cd.cancel();
cd.onFinish();
代码示例来源:origin: stackoverflow.com
countDownTimer.cancel();
countDownTimer.onFinish();
mProgressBar1.setVisibility(View.GONE);
mProgressBar.setVisibility(View.VISIBLE);
countDownTimer = new CountDownTimer(totalTimeCountInMilliseconds, 1) {
@Override
public void onTick(long leftTimeInMilliseconds) {
代码示例来源:origin: stackoverflow.com
for(CountDownTimer t : mFadeTimers){
Log.d("tag", "Cancelling fade timer on destroy."); // ought to read "in onPause", right?
t.cancel();
t.onFinish();
}
mFadeTimers.clear();
代码示例来源:origin: robolectric/robolectric
public void invokeTick(long millisUntilFinished) {
countDownTimer.onTick(millisUntilFinished);
}
代码示例来源:origin: BlinkID/blinkid-android
/**
* Method that is called during recognition process when/if the glare is detected on the
* scanned document.
*
* @param glareDetected whether glare is detected or not.
*/
private void onGlareStatus(boolean glareDetected) {
if (mGlareMsg != null) {
if (glareDetected) {
mGlareCountDownTimer.cancel();
runOnUiThread(new Runnable() {
@Override
public void run() {
mGlareMsg.setVisibility(View.VISIBLE);
}
});
mGlareCountDownTimer.start();
}
}
}
代码示例来源:origin: stackoverflow.com
cdt = new CountDownTimer(100 * 60 * 1000, 500) {
public void onTick(long millisUntilFinished) {
mNotifyManager.notify(id, mBuilder.build());
cdt.start();
.setOngoing(false)
.setProgress(0, 0, false);
cdt.onFinish();
cdt.cancel();
代码示例来源:origin: huntermr/FastAndroid
/**
* 停止倒计时
*/
public void stopCountDown(){
countDownTimer.cancel();
countDownTimer.onFinish();
}
}
代码示例来源:origin: com.github.japgolly.android.test/robolectric
/**
* ******************************************************
* Non-implementation methods for firing abstract methods
* *******************************************************
*/
public void invokeTick(long millisUntilFinished) {
countDownTimer.onTick(millisUntilFinished);
}
代码示例来源:origin: guardianproject/haven
private void showSettings() {
Intent i = new Intent(this, SettingsActivity.class);
if (cTimer != null) {
cTimer.cancel();
cTimer = null;
startActivityForResult(i, REQUEST_TIMER);
} else {
startActivity(i);
}
}
代码示例来源:origin: googleads/googleads-mobile-android-examples
private void createTimer(long time) {
final TextView textView = findViewById(R.id.timer);
if (countDownTimer != null) {
countDownTimer.cancel();
}
countDownTimer = new CountDownTimer(time * 1000, 50) {
@Override
public void onTick(long millisUnitFinished) {
timeRemaining = ((millisUnitFinished / 1000) + 1);
textView.setText("seconds remaining: " + timeRemaining);
}
@Override
public void onFinish() {
if (rewardedVideoAd.isLoaded()) {
showVideoButton.setVisibility(View.VISIBLE);
}
textView.setText("You Lose!");
addCoins(GAME_OVER_REWARD);
retryButton.setVisibility(View.VISIBLE);
gameOver = true;
}
};
countDownTimer.start();
}
代码示例来源:origin: multidots/android-app-common-tasks
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
System.out
.println("001 OauthStart onPostExecute shouldOverrideUrlLoading-->" + url);
if (url.startsWith(OAUTH_CALLBACK_URL)) {
System.out
.println("001 OauthStart onPostExecute shouldOverrideUrlLoading IN IF-->" + url);
new OauthEnd().execute(url);
return true;
}
System.out.println("view:" + view);
countDownTimer = new MyCountDownTimer(startTime,
intervalTime);
countDownTimer.start();
return super.shouldOverrideUrlLoading(view, url);
}
});
代码示例来源:origin: TestSmirk/WelcomeView
@Override
public void onClick(View v) {
start.onFinish();
}
});
代码示例来源:origin: org.robolectric/shadows-core
public void invokeTick(long millisUntilFinished) {
countDownTimer.onTick(millisUntilFinished);
}
代码示例来源:origin: guardianproject/haven
private void doCancel() {
boolean wasTimer = false;
if (cTimer != null) {
cTimer.cancel();
cTimer = null;
mOnTimerTicking = false;
wasTimer = true;
}
if (mIsMonitoring) {
mIsMonitoring = false;
stopService(new Intent(this, MonitorService.class));
finish();
} else {
findViewById(R.id.btnStartNow).setVisibility(View.VISIBLE);
findViewById(R.id.timer_text_title).setVisibility(View.VISIBLE);
((Button) findViewById(R.id.btnStartLater)).setText(R.string.start_later);
int timeM = preferences.getTimerDelay() * 1000;
txtTimer.setText(getTimerText(timeM));
if (!wasTimer)
finish();
}
}
代码示例来源:origin: blundell/QuickSand
latestAnimationCountdown.start();
isANewAnimationSet = true;
} else {
parallelAnimationCountdown.cancel();
isANewAnimationSet = false;
代码示例来源:origin: multidots/android-app-common-tasks
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
System.out
.println("001 OauthStart onPostExecute shouldOverrideUrlLoading-->" + url);
if (url.startsWith(OAUTH_CALLBACK_URL)) {
System.out
.println("001 OauthStart onPostExecute shouldOverrideUrlLoading IN IF-->" + url);
new OauthEnd().execute(url);
return true;
}
System.out.println("view:" + view);
countDownTimer = new MyCountDownTimer(startTime,
intervalTime);
countDownTimer.start();
return super.shouldOverrideUrlLoading(view, url);
}
});
内容来源于网络,如有侵权,请联系作者删除!