当前位置: 首页>>代码示例>>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;未经允许,请勿转载。