本文整理汇总了Java中android.widget.Chronometer类的典型用法代码示例。如果您正苦于以下问题:Java Chronometer类的具体用法?Java Chronometer怎么用?Java Chronometer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Chronometer类属于android.widget包,在下文中一共展示了Chronometer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.Chronometer; //导入依赖的package包/类
/**
* Called on create of the Activity. Sets up the activity
* with its layout. Also sets up and starts the chronometer to tick
* and check the time. If it's over 3 seconds it'll close.
*/
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.page_splash);
this.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
Chronometer chrono = (Chronometer) findViewById(R.id.chronometer_splash_chrono);
chrono.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
public void onChronometerTick(Chronometer chronometer) {
counter++;
if(counter > 2) {
Intent intent = new Intent(Splash.this, Main.class);
Splash.this.startActivity(intent);
Splash.this.finish();
}
}
});
chrono.start();
}
示例2: initViews
import android.widget.Chronometer; //导入依赖的package包/类
@Override
protected void initViews(View view) {
super.initViews(view);
timerChronometer = (Chronometer) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.chronometer_timer_audio_call);
ImageView firstOpponentAvatarImageView = (ImageView) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.image_caller_avatar);
firstOpponentAvatarImageView.setBackgroundDrawable(UiUtils.getColorCircleDrawable(opponents.get(0).getId()));
alsoOnCallText = (TextView) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.text_also_on_call);
setVisibilityAlsoOnCallTextView();
firstOpponentNameTextView = (TextView) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.text_caller_name);
firstOpponentNameTextView.setText(opponents.get(0).getFullName());
otherOpponentsTextView = (TextView) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.text_other_inc_users);
otherOpponentsTextView.setText(getOtherOpponentsNames());
audioSwitchToggleButton = (ToggleButton) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.toggle_speaker);
audioSwitchToggleButton.setVisibility(View.VISIBLE);
actionButtonsEnabled(false);
}
示例3: setChronometer
import android.widget.Chronometer; //导入依赖的package包/类
private static void setChronometer(Chronometer chronometer, int mode) {
switch (mode) {
case Constant.CHRONOMETER_START:
if (playTime != 0) {
chronometer.setBase(chronometer.getBase() +
(SystemClock.elapsedRealtime() - playTime));
} else {
chronometer.setBase(SystemClock.elapsedRealtime());
}
chronometer.start();
break;
case Constant.CHRONOMETER_STOP:
chronometer.stop();
playTime = SystemClock.elapsedRealtime();
break;
case Constant.CHRONOMETER_RESET:
chronometer.stop();
chronometer.setBase(SystemClock.elapsedRealtime());
playTime = 0;
break;
default:
break;
}
}
示例4: initView
import android.widget.Chronometer; //导入依赖的package包/类
private void initView() {
client = new LocationClient(getApplicationContext());
client.registerLocationListener(new RunningActivity.MyLocationListener());
rootLayout = (LinearLayout) findViewById(R.id.running_root_layout);
mapView = (MapView) findViewById(R.id.bmapView);
startButton = (CircularProgressButton) findViewById(R.id.cpb_button);
latLngText = (TextView) findViewById(R.id.lat_lng_text);
speedNumber = (TextView) findViewById(R.id.speed_text);
distanceNumber = (ImageNumberDisplayView) findViewById(R.id.distance_text);
stepNumber = (ImageNumberDisplayView) findViewById(R.id.running_step);
energyNumber = (ImageNumberDisplayView) findViewById(R.id.running_energy);
setToolbar(R.id.running_toolbar, true);
timer = (Chronometer) findViewById(R.id.timer);
baiduMap = mapView.getMap();
startButton.setClickable(false);
startButton.setIndeterminateProgressMode(true);
}
示例5: findViews
import android.widget.Chronometer; //导入依赖的package包/类
private void findViews() {
if (init || root == null)
return;
topRoot = root.findViewById(R.id.avchat_video_top_control);
switchAudio = topRoot.findViewById(R.id.avchat_video_switch_audio);
switchAudio.setOnClickListener(this);
time = (Chronometer) topRoot.findViewById(R.id.avchat_video_time);
netUnstableTV = (TextView) topRoot.findViewById(R.id.avchat_video_netunstable);
middleRoot = root.findViewById(R.id.avchat_video_middle_control);
headImg = (HeadImageView) middleRoot.findViewById(R.id.avchat_video_head);
nickNameTV = (TextView) middleRoot.findViewById(R.id.avchat_video_nickname);
notifyTV = (TextView) middleRoot.findViewById(R.id.avchat_video_notify);
refuse_receive = middleRoot.findViewById(R.id.avchat_video_refuse_receive);
refuseTV = (TextView) refuse_receive.findViewById(R.id.refuse);
receiveTV = (TextView) refuse_receive.findViewById(R.id.receive);
refuseTV.setOnClickListener(this);
receiveTV.setOnClickListener(this);
recordView = root.findViewById(R.id.avchat_record_layout);
recordTip = recordView.findViewById(R.id.avchat_record_tip);
recordWarning = recordView.findViewById(R.id.avchat_record_warning);
bottomRoot = root.findViewById(R.id.avchat_video_bottom_control);
faceUnityRoot = root.findViewById(R.id.avchat_video_face_unity);
switchCameraToggle = new ToggleView(bottomRoot.findViewById(R.id.avchat_switch_camera), ToggleState.DISABLE, this);
closeCameraToggle = new ToggleView(bottomRoot.findViewById(R.id.avchat_close_camera), ToggleState.DISABLE, this);
muteToggle = new ToggleView(bottomRoot.findViewById(R.id.avchat_video_mute), ToggleState.DISABLE, this);
recordToggle = (ImageView) bottomRoot.findViewById(R.id.avchat_video_record);
recordToggle.setEnabled(false);
recordToggle.setOnClickListener(this);
hangUpImg = (ImageView) bottomRoot.findViewById(R.id.avchat_video_logout);
hangUpImg.setOnClickListener(this);
permissionRoot = root.findViewById(R.id.avchat_video_permission_control);
init = true;
}
示例6: onCreate
import android.widget.Chronometer; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// The ViewModelStore provides a new ViewModel or one previously created.
ChronometerViewModel chronometerViewModel
= ViewModelProviders.of(this).get(ChronometerViewModel.class);
// Get the chronometer reference
Chronometer chronometer = findViewById(R.id.chronometer);
if (chronometerViewModel.getStartTime() == null) {
// If the start date is not defined, it's a new ViewModel so set it.
long startTime = SystemClock.elapsedRealtime();
chronometerViewModel.setStartTime(startTime);
chronometer.setBase(startTime);
} else {
// Otherwise the ViewModel has been retained, set the chronometer's base to the original
// starting time.
chronometer.setBase(chronometerViewModel.getStartTime());
}
chronometer.start();
}
示例7: updateChronometer
import android.widget.Chronometer; //导入依赖的package包/类
private void updateChronometer() {
timerButton.setImageResource(timerActive()
? R.drawable.ic_pause_24dp
: R.drawable.ic_play_arrow_24dp);
long elapsed = this.elapsed.getTimeDurationInSeconds() * 1000L;
if (timerActive()) {
chronometer.setVisibility(View.VISIBLE);
elapsed += DateUtilities.now() - timerStarted;
chronometer.setBase(SystemClock.elapsedRealtime() - elapsed);
if (elapsed > DateUtilities.ONE_DAY) {
chronometer.setOnChronometerTickListener(new Chronometer.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();
}
}
示例8: onCreate
import android.widget.Chronometer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);
ArrayList<QBUser> qbUsers = (ArrayList<QBUser>) getIntent().getExtras().getSerializable(EXTRA_QB_USERS);
chatDialog = new QBChatDialog(DIALOG_ID);
messagesListView = (RecyclerView) findViewById(R.id.list_chat_messages);
progressBar = (ProgressBar) findViewById(R.id.progress_chat);
audioLayout = (LinearLayout) findViewById(R.id.layout_chat_audio_container);
recordButton = (QBRecordAudioButton) findViewById(R.id.button_chat_record_audio);
recordChronometer = (Chronometer) findViewById(R.id.chat_audio_record_chronometer);
bucketView = (ImageView) findViewById(R.id.chat_audio_record_bucket_imageview);
audioRecordTextView = (TextView) findViewById(R.id.chat_audio_record_textview);
vibro = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
requestPermission();
initAudioRecorder();
recordButton.setRecordTouchListener(new RecordTouchListenerImpl());
loadChatHistory(qbUsers);
}
示例9: onCreateView
import android.widget.Chronometer; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View fragmentView = inflater.inflate(R.layout.misc_overscroll_demo, null, false);
View textView = fragmentView.findViewById(R.id.demo_text);
ElasticityHelper.setUpStaticOverScroll(textView, ORIENTATION.HORIZONTAL);
View imageView = fragmentView.findViewById(R.id.demo_image);
ElasticityHelper.setUpStaticOverScroll(imageView, ORIENTATION.VERTICAL);
mChrono = (Chronometer) fragmentView.findViewById(R.id.demo_chronometer);
if (savedInstanceState != null) {
mChrono.setBase(savedInstanceState.getLong(CHRONO_TIME_SAVE_ID));
}
ElasticityHelper.setUpStaticOverScroll(mChrono, ORIENTATION.HORIZONTAL);
mChrono.start();
return fragmentView;
}
示例10: onCreate
import android.widget.Chronometer; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
super.onCreate(savedInstanceState);
setContentView(R.layout.zg_activity_video_shoot);
mFacing = (TextView) findViewById(R.id.tv_facing);
mSurfaceView = (SurfaceView) findViewById(R.id.surfaceview_shoot);
mShoot = (ImageView) findViewById(R.id.img_shoot);
mChronometer = (Chronometer) findViewById(R.id.video_chronometer);
mFacing.setOnClickListener(this);
mShoot.setOnClickListener(this);
initToggle();
findViewById(R.id.iv_left).setOnClickListener(this);
SurfaceHolder mHolder = mSurfaceView.getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
示例11: startCapture
import android.widget.Chronometer; //导入依赖的package包/类
private void startCapture() {
if(captureService != null)
{
try {
captureService.startCapture();
} catch(NoCurrentCaptureException e) {
Intent settingsIntent = new Intent(CaptureActivity.this, NewActivity.class);
startActivity(settingsIntent);
return;
}
vibratorService.vibrate(100);
Toast.makeText(CaptureActivity.this, "Iniciar Trazado..." ,Toast.LENGTH_SHORT).show();
((Chronometer) findViewById(R.id.captureChronometer)).setBase(SystemClock.elapsedRealtime());
((Chronometer) findViewById(R.id.captureChronometer)).start();
initButtons();
}
}
示例12: method
import android.widget.Chronometer; //导入依赖的package包/类
public void method(Chronometer chronometer) {
// Method call
chronometer.<error descr="Call requires API level 3 (current min is 1): android.widget.Chronometer#getOnChronometerTickListener">getOnChronometerTickListener</error>(); // API 3
// Inherited method call (from TextView
chronometer.<error descr="Call requires API level 11 (current min is 1): android.widget.TextView#setTextIsSelectable">setTextIsSelectable</error>(true); // API 11
// Field access
int fillParent = LayoutParams.FILL_PARENT; // API 1
// This is a final int, which means it gets inlined
int matchParent = LayoutParams.MATCH_PARENT; // API 8
// Field access: non final
BatteryInfo batteryInfo = <error descr="Field requires API level 14 (current min is 1): android.app.ApplicationErrorReport#batteryInfo">getReport().batteryInfo</error>;
// Enum access
Mode mode = <error descr="Field requires API level 11 (current min is 1): android.graphics.PorterDuff.Mode#OVERLAY">PorterDuff.Mode.OVERLAY</error>; // API 11
}
示例13: onCreateView
import android.widget.Chronometer; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View fragmentView = inflater.inflate(R.layout.misc_overscroll_demo, null, false);
View textView = fragmentView.findViewById(R.id.demo_text);
OverScrollDecoratorHelper.setUpStaticOverScroll(textView, OverScrollDecoratorHelper.ORIENTATION_HORIZONTAL);
View imageView = fragmentView.findViewById(R.id.demo_image);
OverScrollDecoratorHelper.setUpStaticOverScroll(imageView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL);
mChrono = (Chronometer) fragmentView.findViewById(R.id.demo_chronometer);
if (savedInstanceState != null) {
mChrono.setBase(savedInstanceState.getLong(CHRONO_TIME_SAVE_ID));
}
OverScrollDecoratorHelper.setUpStaticOverScroll(mChrono, OverScrollDecoratorHelper.ORIENTATION_HORIZONTAL);
mChrono.start();
return fragmentView;
}
示例14: onCreateView
import android.widget.Chronometer; //导入依赖的package包/类
@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;
}
示例15: initView
import android.widget.Chronometer; //导入依赖的package包/类
private void initView() {
m_ContentView = m_LayoutInflater.inflate(R.layout.audio_capture, null);
setContentView(m_ContentView);
btnStartRecord = (Button)m_ContentView.findViewById(R.id.start_record);
btnStopRecord = (Button)m_ContentView.findViewById(R.id.stop_record);
btnOk = (Button)m_ContentView.findViewById(R.id.audio_record_ok);
btnBackUp = (Button)m_ContentView.findViewById(R.id.audio_cancel);
btnStartRecord.setOnClickListener(this);
btnStopRecord.setOnClickListener(this);
btnBackUp.setOnClickListener(this);
btnOk.setOnClickListener(this);
mTimer = (Chronometer)m_ContentView.findViewById(R.id.chronometer1);
}