Best code examples for Android Chronometer class (android.widget.Chronometer)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Chronometer class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android Chronometer examples from Open Source projects
This code example shows how to use the following methods: getLayoutParams, getWidth, requestLayout, stop
        } 
         
        // Stop Chronometer if we're past duration 
        long now = SystemClock.elapsedRealtime();
        if (now >= mDurationBase) {
            mChronometer.stop();
        } 
 
        // Update the ProgressBar status 
        int remaining = (int) (mDurationBase - now);
        mProgressBar.setProgress(mDuration - remaining);
         
        // Move the Chronometer if gravity is set correctly 
        if (mChronometerFollow) {
            RelativeLayout.LayoutParams params;
             
            // Calculate estimate of ProgressBar leading edge position 
            params = (RelativeLayout.LayoutParams) mProgressBar.getLayoutParams();
            int contentWidth = mProgressBar.getWidth() - (params.leftMargin + params.rightMargin);
            int leadingEdge = ((contentWidth * mProgressBar.getProgress()) /

8
CodeRank
This code example shows how to use the following methods: getLayoutParams, getWidth, requestLayout, stop
        } 
         
        // Stop Chronometer if we're past duration 
        long now = SystemClock.elapsedRealtime();
        if (now >= mDurationBase) {
            mChronometer.stop();
        } 
 
        // Update the ProgressBar status 
        int remaining = (int) (mDurationBase - now);
        mProgressBar.setProgress(mDuration - remaining);
         
        // Move the Chronometer if gravity is set correctly 
        if (mChronometerFollow) {
            RelativeLayout.LayoutParams params;
             
            // Calculate estimate of ProgressBar leading edge position 
            params = (RelativeLayout.LayoutParams) mProgressBar.getLayoutParams();
            int contentWidth = mProgressBar.getWidth() - (params.leftMargin + params.rightMargin);
            int leadingEdge = ((contentWidth * mProgressBar.getProgress()) /

8
CodeRank
This code example shows how to use the following methods: start
        button.setOnClickListener(mClearFormatListener);
    } 
 
    View.OnClickListener mStartListener = new OnClickListener() {
        public void onClick(View v) { 
            mChronometer.start(); 
        } 
    }; 
 
    View.OnClickListener mStopListener = new OnClickListener() {
        public void onClick(View v) { 
            mChronometer.stop(); 
        } 
    }; 
 
    View.OnClickListener mResetListener = new OnClickListener() {
        public void onClick(View v) { 
            mChronometer.setBase(SystemClock.elapsedRealtime()); 
        } 
    }; 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setBase
        } 
    }; 
 
    View.OnClickListener mResetListener = new OnClickListener() {
        public void onClick(View v) { 
            mChronometer.setBase(SystemClock.elapsedRealtime()); 
        } 
    }; 
 
    View.OnClickListener mSetFormatListener = new OnClickListener() {
        public void onClick(View v) { 
            mChronometer.setFormat("Formatted time (%s)"); 
        } 
    }; 
 
    View.OnClickListener mClearFormatListener = new OnClickListener() {
        public void onClick(View v) { 
            mChronometer.setFormat(null); 
        } 
    }; 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getBase, setBase, start
    /** 
     * Starts a new level because it is paused during the victory or loss vibration pattern (to preserve time). 
     * Almost the same as resumeTimer() but also sets a new levelStartTimeLeft. 
     */ 
    public void startLevel() { 
        chronoTimer.setBase(getCurrentTime() - pauseChronoElapsed);
        chronoTimer.start();
        pauseChronoElapsed = 0;
        levelStartTimeLeft = startTime - (getCurrentTime() - chronoTimer.getBase());
    } 
 
 
    public void resumeTimer() { 
        chronoTimer.setBase(getCurrentTime() - pauseChronoElapsed);
        chronoTimer.start();
        pauseChronoElapsed = 0;
 
    } 
 
 
Full Snippet Info
5
CodeRank
Related Android Chronometer Questions & Answers:
See Code Examples for Android Chronometer Methods: