Android Chronometer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Chronometer class.

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
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
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()); 
        } 
    }; 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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); 
        } 
    }; 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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;
 
    } 
 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLayoutParams, getWidth, requestLayout, stop
					"Expecting child ProgressBar with id 'android.R.id.progress'"); 
		}// Stop Chronometer if we're past duration 
		 
		long now = SystemClock.elapsedRealtime();
		if (now >= mDurationBase) {
			mChronometer.stop();
		} 
		int remaining = (int) (mDurationBase - now);
 
		mProgressBar.setProgress(mDuration - remaining);
 
		if (mChronometerFollow) {
			RelativeLayout.LayoutParams params;
			params = (RelativeLayout.LayoutParams) mProgressBar
					.getLayoutParams();
 
			int contentWidth = mProgressBar.getWidth()
					- (params.leftMargin + params.rightMargin);
 
			int leadingEdge = ((contentWidth * mProgressBar.getProgress()) /

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLayoutParams, getWidth, requestLayout, stop
					"Expecting child ProgressBar with id 'android.R.id.progress'"); 
		}// Stop Chronometer if we're past duration 
		 
		long now = SystemClock.elapsedRealtime();
		if (now >= mDurationBase) {
			mChronometer.stop();
		} 
		int remaining = (int) (mDurationBase - now);
 
		mProgressBar.setProgress(mDuration - remaining);
 
		if (mChronometerFollow) {
			RelativeLayout.LayoutParams params;
			params = (RelativeLayout.LayoutParams) mProgressBar
					.getLayoutParams();
 
			int contentWidth = mProgressBar.getWidth()
					- (params.leftMargin + params.rightMargin);
 
			int leadingEdge = ((contentWidth * mProgressBar.getProgress()) /

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setBase, start
					but.setText("¼ÌÐø");
					but2.setClickable(true);
				} 
				else if(str.equals("¿ªÊ¼"))
				{ 
					ch.setBase(SystemClock.elapsedRealtime());
					ch.start();
					but.setText("ÔÝÍ£");
					but2.setClickable(false);
				} 
			} 
			 
		}); 
		but2.setOnClickListener(new OnClickListener()
		{ 
			@Override 
			public void onClick(View v)
			{ 
				// TODO Auto-generated method stub 
			ch.setBase(0);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setId, setText, setTextColor
 
		if (choice == 1) {
			//T22. Increment view id.  
			chronometerId++;
			//T23. Pass home context to view constructor. 
			Chronometer chronoMeter = new Chronometer(context);
			//T24 Set the view id to previously incremented id. 
			chronoMeter.setId(chronometerId);
			//T25 Set the view text to the name of the view +  the view id.  
			chronoMeter.setText("Chronometer" + chronometerId);
			//T26 Set view colour.  
			chronoMeter.setTextColor(Color.WHITE);
			//T27 Return the view.  
			return chronoMeter;
		} 
      
		if (choice == 2) {
			//T28. Increment view id.  
			analogClockId++;
			//T29. Pass home context to view constructor. 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBase, setBase, start
			} 
		} 
	} 
	//gets the timer in the interface going 
	public static void chronometer(Chronometer c) {
		Log.i(LOG_TAG, "CHRONOTIME = " + c.getBase());
		if (!isRecording) {
			chronoTime = SystemClock.elapsedRealtime();
		} 
		c.setBase(chronoTime);
		c.start();
	} 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android Chronometer Questions & Answers:

See Code Examples for Android Chronometer Methods: