Java Code Examples for android.widget.Chronometer.OnChronometerTickListener

The following are top voted examples for showing how to use android.widget.Chronometer.OnChronometerTickListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: bachamada   File: MeasurementFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    SharedPreferences sharedPref = getActivity().getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);
    mTime = sharedPref.getInt(getString(R.string.value_timer), mTime);
    View rootView = inflater.inflate(R.layout.fragment_layout_measurement, container, false);

    mStopWatch = (CustomStopwatch) rootView.findViewById(R.id.stopwatch);

    mStopWatch.setTime(mTime);
    mStopWatch.setOnChronometerTickListener(new OnChronometerTickListener() {

                                                public void onChronometerTick(Chronometer arg0) {
                                                    boolean isAlert = false;
                                                    if (mStopWatch.measurementIsFinished() && !isAlert) {
                                                        mCallback.onTimerEnd(mTime);
                                                        stopTimer();
                                                        isAlert = true;
                                                    }
                                                }
                                            }
    );
    return rootView;
}
 
Example 2
Project: WiCamera3D   File: TimeCounter.java   View source code 5 votes vote down vote up
/**
 * 开始计时
 */
public void start() {
	// System.out.println("开始计时了。。。");
	// 显示录制时间的textview
	m_csbtn_recordtime.setVisibility(View.VISIBLE);
	// 计时器控件重新置数,并开始启动计时器
	m_chronometer_recordtime.setBase(SystemClock.elapsedRealtime());
	m_chronometer_recordtime.start();
	// 当背景改变是后背景改变
	m_chronometer_recordtime
			.setOnChronometerTickListener(new OnChronometerTickListener() {
				// 记录录制时间变量
				@Override
				public void onChronometerTick(Chronometer chronometer) {
					// TODO Auto-generated method stub

					// 为显示录制时间的textview赋值
					String time = chronometer.getText().toString();
					System.out.println("time为" + time);
					// 确保显示时间的格式为00:00:00
					if (time.length() == 5) {
						m_csbtn_recordtime.setText("00:"
								+ chronometer.getText());
					} else if (time.length() == 7) {
						m_csbtn_recordtime.setText("0"
								+ chronometer.getText());
					} else if (time.length() == 8) {
						m_csbtn_recordtime.setText(chronometer.getText());
					}

					if (WiCameraActivity.mCurrentDegree == 90||WiCameraActivity.mCurrentDegree == 270) {
						WiCameraActivity.m_al_camera_overlayui
								.postInvalidate();
					}
				}

			});
}
 
Example 3
Project: moveon   File: Main.java   View source code 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	fragmentView = (LinearLayout) inflater.inflate(R.layout.main, container, false);

	layout1 = (LinearLayout) fragmentView.findViewById(R.id.linearLayout1);
	layout2 = (LinearLayout) fragmentView.findViewById(R.id.linearLayout2);
	layout4 = (LinearLayout) fragmentView.findViewById(R.id.linearLayout4);
	layout5 = (LinearLayout) fragmentView.findViewById(R.id.linearLayout5);

	defineWidgets(fragmentView);

	if (savedInstanceState != null)
		chrono.setBase(chronoBaseValue);

	chrono.setOnChronometerTickListener(new OnChronometerTickListener() {
		public void onChronometerTick(Chronometer arg0) {
			showCalculatedData(arg0);

			if (prefs.getInt("practice_display5", TypesOfPractices.BASIC_PRACTICE.getTypes()) == TypesOfPractices.HIIT_PRACTICE
					.getTypes())
				showHiitTrainingDataInDisplay(arg0);
		}
	});

	mapView = (MapView) fragmentView.findViewById(R.id.practice_mapview);
	mapView.getOverlays().clear();
	mapView.setBuiltInZoomControls(true);
	mapView.setMultiTouchControls(true);
	mapView.setUseSafeCanvas(true);

	setHardwareAccelerationOff();

	mapController = (MapController) mapView.getController();

	ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(mContext);
	mapView.getOverlays().add(mScaleBarOverlay);

	pathOverlay = new PathOverlay(Color.BLUE, mContext);
	pathOverlay.getPaint().setStyle(Style.STROKE);
	pathOverlay.getPaint().setStrokeWidth(3);
	pathOverlay.getPaint().setAntiAlias(true);
	mapView.getOverlays().add(pathOverlay);

	this.mCompassOverlay = new CompassOverlay(mContext, new InternalCompassOrientationProvider(mContext),
			mapView);
	mCompassOverlay.setEnabled(true);
	mapView.getOverlays().add(mCompassOverlay);

	this.mLocationOverlay = new MyLocationNewOverlay(mContext, new GpsMyLocationProvider(mContext),
			mapView);
	mLocationOverlay.setDrawAccuracyEnabled(true);
	mapView.getOverlays().add(mLocationOverlay);

	MapOverlay touchOverlay = new MapOverlay(mContext);
	mapView.getOverlays().add(touchOverlay);

	mLocationOverlay.runOnFirstFix(new Runnable() {
		public void run() {
			if (centerPoint == null)
				centerPoint = mLocationOverlay.getMyLocation();

			centerMyLocation(centerPoint);
		}
	});

	mapView.postInvalidate();

	return fragmentView;
}
 
Example 4
Project: Android-Pulley-Menu   File: PulleyMenuSample.java   View source code 5 votes vote down vote up
@Override
protected void onStart() {
	// TODO Auto-generated method stub
	super.onStart();
	stopwatch.setOnChronometerTickListener(new OnChronometerTickListener() {
		@Override
		public void onChronometerTick(Chronometer arg0) {

			int countup = (int) ((SystemClock.elapsedRealtime() - arg0
					.getBase()) / 1000);
			String asText = (countup / 60) + ":" + (countup % 60);
			tvtimer.setText("Time Elapsed :- " + asText);
		}
	});
}
 
Example 5
Project: iWish   File: ProgressActivity.java   View source code 5 votes vote down vote up
private void setOnChronometer(){

		ch.setOnChronometerTickListener(new OnChronometerTickListener() {
			@Override
			public void onChronometerTick(Chronometer chronometer) {
				long aux = SystemClock.elapsedRealtime() - chronometer.getBase();
				hmmss = timeFormat.format(aux);	
				chronometer.setText(hmmss);
			}
		});

	}
 
Example 6
Project: dadm   File: Session.java   View source code 3 votes vote down vote up
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	

	getFigureFromPreferences();
	getTypeFromPreferences();
	musicOn();		
	play();	
	oldfigure=Preferences.getFigureName(this);

	
	
	//ActionBar actionbar=getActionBar(); //SDK 11 Needed!
	

        setStopWatch((Chronometer) findViewById(R.id.chrono));
       startTime = SystemClock.elapsedRealtime();

       //textGoesHere = (TextView) findViewById(R.id.textGoesHere);
       getStopWatch().setOnChronometerTickListener(new OnChronometerTickListener(){
           @Override
           public void onChronometerTick(Chronometer arg0) {
               countUp = (SystemClock.elapsedRealtime() - arg0.getBase()) / 1000;
               //String asText = (countUp / 60) + ":" + (countUp % 60); 
              // textGoesHere.setText(asText);
               game.setSeconds((int)countUp);
               setPlayerNameFromsetUPreferences();
               game.setCurrentPlayer(playerName);
           }
       });
       
       getStopWatch().start();
       

	

}