當前位置: 首頁>>代碼示例>>Java>>正文


Java CountDownTimer類代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:Dentacoin,項目名稱:aftercare-app-android,代碼行數:20,代碼來源:DCDashboardFragment.java

示例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);
  }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:24,代碼來源:Reg.java

示例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);
  }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:24,代碼來源:msf_shell.java

示例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);
        }
    };
}
 
開發者ID:datdescartes,項目名稱:pokequest,代碼行數:21,代碼來源:PokeQuizActivity.java

示例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();
}
 
開發者ID:Zhaoss,項目名稱:WeiXinRecordedDemo,代碼行數:21,代碼來源:MediaRecorderBase.java

示例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();
    }
}
 
開發者ID:Longalei,項目名稱:Edu,代碼行數:22,代碼來源:TimerView.java

示例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();
}
 
開發者ID:googlesamples,項目名稱:android-WearAccessibilityApp,代碼行數:19,代碼來源:CircledImageViewPreference.java

示例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();
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:29,代碼來源:DownTimer.java

示例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();
            }
        });
    }
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:33,代碼來源:Toaster.java

示例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();
}
 
開發者ID:zhaobao,項目名稱:AppsTimeline,代碼行數:17,代碼來源:SplashActivity.java

示例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();
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:29,代碼來源:TimerUtils.java

示例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();
}
 
開發者ID:cuplv,項目名稱:ChimpCheck,代碼行數:17,代碼來源:CountdownFragment.java

示例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();
}
 
開發者ID:wzc25151,項目名稱:lrs_android,代碼行數:26,代碼來源:SimpleController.java

示例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();
    }
 
開發者ID:wzc25151,項目名稱:lrs_android,代碼行數:20,代碼來源:GameActivity.java

示例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();

    }
 
開發者ID:aidaferreira,項目名稱:synesthesiavision,代碼行數:18,代碼來源:ConnectBluetooth.java


注:本文中的android.os.CountDownTimer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。