Java 类android.widget.Chronometer.OnChronometerTickListener 实例源码
项目:bachamada
文件:MeasurementFragment.java
@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;
}
项目:WiCamera3D
文件:TimeCounter.java
/**
* 开始计时
*/
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();
}
}
});
}
项目:moveon
文件:Main.java
@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;
}
项目:Android-Pulley-Menu
文件:PulleyMenuSample.java
@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);
}
});
}
项目:iWish
文件:ProgressActivity.java
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);
}
});
}
项目:dadm
文件:Session.java
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();
}