List of usage examples for android.widget Chronometer getBase
public long getBase()
From source file:com.todoroo.astrid.timers.TimerActionControlSet.java
private void updateDisplay() { final int drawable; if (timerActive) { drawable = R.drawable.icn_timer_stop; } else {//from www . j av a 2 s.c om drawable = R.drawable.icn_edit_timer; } timerButton.setImageResource(drawable); long elapsed = model.getElapsedSeconds() * 1000L; if (timerActive) { chronometer.setVisibility(View.VISIBLE); elapsed += DateUtilities.now() - model.getTimerStart(); chronometer.setBase(SystemClock.elapsedRealtime() - elapsed); if (elapsed > DateUtilities.ONE_DAY) { chronometer.setOnChronometerTickListener(new OnChronometerTickListener() { @Override public void onChronometerTick(Chronometer cArg) { long t = SystemClock.elapsedRealtime() - cArg.getBase(); cArg.setText(DateFormat.format("d'd' h:mm", t)); //$NON-NLS-1$ } }); } chronometer.start(); } else { chronometer.setVisibility(View.GONE); chronometer.stop(); } }
From source file:com.att.android.arodatacollector.activities.AROCollectorHomeActivity.java
/** * Initializes data members with a saved instance of an AROCollectorHomeActivity object. * Overrides the android.app.Activity#onCreate method. * @param savedInstanceState A saved instance of an AROCollectorHomeActivity object. * @see android.app.Activity#onCreate(android.os.Bundle) *///from w ww. ja va 2 s . c o m @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AROLogger.d(TAG, "inside onCreate"); mApp = (ARODataCollector) getApplication(); //mAroUtils = new AROCollectorUtils(); setContentView(R.layout.arocollector_home_screen); initHomeScreenControls(); initHomeScreenControlListeners(); //All code until end of the method is used to maintain the on screen timer. stopWatch = (Chronometer) findViewById(R.id.chrono); stopWatch.setBase(mApp.getElapsedTimeStartTime()); timerText = (TextView) findViewById(R.id.timer); stopWatch.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { @Override public void onChronometerTick(Chronometer arg0) { countUp = (System.currentTimeMillis() - arg0.getBase()) / 1000; String asText; String minPlace = ""; String secPlace = ""; if (((countUp / 60) % 60) < 10) { minPlace = "0"; } if (countUp % 60 < 10) { secPlace = "0"; } //Display the time in standard "Hours:Minutes:Seconds" | "00:00:00" asText = "0" + (countUp / 3600) + ":" + minPlace + ((countUp / 60) % 60) + ":" + secPlace + (countUp % 60); timerText.setText(getText(R.string.aro_traceTimer) + " " + asText); } }); stopWatch.start(); final Bundle apkCommandLineParameters = getIntent().getExtras(); if (apkCommandLineParameters != null) { String mAROStopRequestFromAnalyzer = apkCommandLineParameters.getString("StopCollector"); if (mAROStopRequestFromAnalyzer != null) { stopARODataCollector(); } } registerAnalyzerCloseCmdReceiver(); }
From source file:kr.ac.kpu.wheeling.blackbox.Camera2VideoFragment.java
@Override public void onViewCreated(final View view, Bundle savedInstanceState) { mTextureView = (AutoFitTextureView) view.findViewById(kr.ac.kpu.wheeling.R.id.texture); //------------------------------------------- tracker_layout = (LinearLayout) view.findViewById(R.id.tracker_layout); mButtonVisible = (Button) view.findViewById(R.id.btn_visible); mButtonVisible.setOnClickListener(this); mButtonRiding = (Button) view.findViewById(R.id.btn_visible_riding); mButtonRiding.setOnClickListener(this); btn_btest = (Button) view.findViewById(R.id.btn_btest); btn_btest.setOnClickListener(this); sqLiteHandler = new SQLiteHandler(getActivity()); //---------------------------------------------- mButtonVideo = (Button) view.findViewById(kr.ac.kpu.wheeling.R.id.video); mButtonVideo.setOnClickListener(this); mButtonSetting = (Button) view.findViewById(kr.ac.kpu.wheeling.R.id.interval); mButtonSetting.setOnClickListener(this); //view.findViewById(R.id.info).setOnClickListener(this); chronometer = (Chronometer) view.findViewById(kr.ac.kpu.wheeling.R.id.chronometer); sensorManager.registerListener(gyroListener, sensor, SensorManager.SENSOR_DELAY_NORMAL); mButtonGallery = (Button) view.findViewById(kr.ac.kpu.wheeling.R.id.menu); mButtonGallery.setOnClickListener(this); galleryActivity = new Intent(getActivity(), GalleryActivity.class); chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { @Override/*from w w w . j a va 2s . c o m*/ public void onChronometerTick(Chronometer chronometer) { if ((int) (((SystemClock.elapsedRealtime() - chronometer.getBase()))) > 10500) { try { stopRecordingVideo(); mIsSensorChanged = false; } catch (Exception e) { } chronometer.stop(); } } }); }
From source file:com.saulcintero.moveon.fragments.Main.java
private void showHiitTrainingDataInDisplay(Chronometer arg0) { int interval_spent_time = (int) (SystemClock.elapsedRealtime() - arg0.getBase()) / 1000; if (interval_spent_time < hiit_total_time) { if (hiit_passedRounds == 1) { hiit_actionSecondsByRound = hiit_prepSeconds + hiit_actionSeconds; hiit_lastRoundsSeconds = hiit_prepSeconds; } else {//from w w w. j a va 2s .c o m hiit_actionSecondsByRound = hiit_prepSeconds + (hiit_actionSeconds * (hiit_passedRounds - 1)) + hiit_actionSeconds; hiit_lastRoundsSeconds = hiit_prepSeconds + (hiit_actionSeconds * (hiit_passedRounds - 1)); } if ((interval_spent_time <= hiit_prepSeconds) && (hiit_prepSeconds > 0)) { display5_label.setTextColor(res.getColor(R.color.gray)); int countDownTime = hiit_prepSeconds - interval_spent_time; hiit_information = getString(R.string.warm_up_description) + " " + FunctionUtils.shortFormatTime(countDownTime); hiit_label = hiit_name; } else if ((interval_spent_time <= hiit_actionSecondsByRound) && (interval_spent_time < (hiit_total_time - hiit_coolDownSeconds))) { int action = hiit_intervals.size(), accum_intervals = 0; int[] accum_intervals_array = new int[hiit_intervals.size()]; for (int m = 0; m <= (hiit_intervals.size() - 1); m++) { accum_intervals = accum_intervals + hiit_intervals.get(m)[1]; accum_intervals_array[m] = accum_intervals; if (interval_spent_time <= (hiit_lastRoundsSeconds + accum_intervals)) { action -= 1; } } hiit_information = ""; switch (hiit_intervals.get(action)[0]) { case 1: display5_label.setTextColor(res.getColor(R.color.green)); hiit_information = getString(R.string.hiit_type_description1).toLowerCase(Locale.getDefault()) + " (" + hiit_passedRounds + "/" + hiit_rounds + ") "; break; case 2: display5_label.setTextColor(res.getColor(R.color.yellow)); hiit_information = getString(R.string.hiit_type_description2).toLowerCase(Locale.getDefault()) + " (" + hiit_passedRounds + "/" + hiit_rounds + ") "; break; case 3: display5_label.setTextColor(res.getColor(R.color.orange)); hiit_information = getString(R.string.hiit_type_description3).toLowerCase(Locale.getDefault()) + " (" + hiit_passedRounds + "/" + hiit_rounds + ") "; break; case 4: display5_label.setTextColor(res.getColor(R.color.red)); hiit_information = getString(R.string.hiit_type_description4).toLowerCase(Locale.getDefault()) + " (" + hiit_passedRounds + "/" + hiit_rounds + ") "; break; } accum_intervals = 0; for (int j = 0; j <= action; j++) { accum_intervals = accum_intervals + hiit_intervals.get(j)[1]; } int countDownTime; if (hiit_passedRounds == 1) { countDownTime = ((hiit_prepSeconds + accum_intervals) - hiit_lastRoundsSeconds) - (interval_spent_time - hiit_lastRoundsSeconds); hiit_information = hiit_information + FunctionUtils.shortFormatTime(countDownTime); } else { countDownTime = ((hiit_lastRoundsSeconds + accum_intervals) - interval_spent_time); hiit_information = hiit_information + FunctionUtils.shortFormatTime(countDownTime); } hiit_label = hiit_name; } else { display5_label.setTextColor(res.getColor(R.color.blue)); hiit_information = getString(R.string.cool_down) + " " + FunctionUtils.shortFormatTime(hiit_total_time - interval_spent_time); hiit_label = hiit_name; } if ((hiit_prepSeconds + (hiit_passedRounds * hiit_actionSeconds)) <= interval_spent_time) { hiit_passedRounds += 1; } } else { display5_label.setTextColor(res.getColor(R.color.white)); hiit_information = getString(R.string.practice_completed); hiit_label = hiit_name; } showObjetiveData(display5_image, display5_label, display5_text1, hiit_information, hiit_label); }
From source file:com.saulcintero.moveon.fragments.Main.java
private void showCalculatedData(TextView tv, int option, Chronometer arg0) { DisplayTypes whichDisplay = DisplayTypes.values()[option]; switch (whichDisplay) { case TIME://from www . j a va 2 s .c o m tv.setText(FunctionUtils.longFormatTime((SystemClock.elapsedRealtime() - arg0.getBase()) / 1000)); break; case AVG_SPEED: tv.setText(FunctionUtils.calculateAvg(mContext, ((SystemClock.elapsedRealtime() - arg0.getBase()) / 1000), mDistance, isMetric)); break; case RITM: tv.setText(FunctionUtils.calculateRitm(mContext, ((SystemClock.elapsedRealtime() - arg0.getBase()) / 1000), mDistance, isMetric, false)); break; case KCAL: tv.setText(String.valueOf(MoveOnService.getCalories())); break; default: break; } }
From source file:com.ichi2.anki.AbstractFlashcardViewer.java
protected void initTimer() { final TypedValue typedValue = new TypedValue(); mShowTimer = mCurrentCard.showTimer(); if (mShowTimer && mCardTimer.getVisibility() == View.INVISIBLE) { mCardTimer.setVisibility(View.VISIBLE); } else if (!mShowTimer && mCardTimer.getVisibility() != View.INVISIBLE) { mCardTimer.setVisibility(View.INVISIBLE); }/* w ww . j av a 2 s.c o m*/ // Set normal timer color getTheme().resolveAttribute(android.R.attr.textColor, typedValue, true); mCardTimer.setTextColor(typedValue.data); mCardTimer.setBase(SystemClock.elapsedRealtime()); mCardTimer.start(); // Stop and highlight the timer if it reaches the time limit. getTheme().resolveAttribute(R.attr.maxTimerColor, typedValue, true); final int limit = mCurrentCard.timeLimit(); mCardTimer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { @Override public void onChronometerTick(Chronometer chronometer) { long elapsed = SystemClock.elapsedRealtime() - chronometer.getBase(); if (elapsed >= limit) { chronometer.setTextColor(typedValue.data); chronometer.stop(); } } }); }