@Override public void onInfo(MediaRecorder mr, int what, int extra) { EMLog.v("video", "onInfo"); if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) { EMLog.v("video", "max duration reached"); stopRecording(); btn_switch.setVisibility(View.VISIBLE); chronometer.stop(); btnStart.setVisibility(View.VISIBLE); btnStop.setVisibility(View.INVISIBLE); chronometer.stop(); if (localPath == null) { return; } String st3 = getResources().getString(R.string.Whether_to_send); new AlertDialog.Builder(this) .setMessage(st3) .setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { arg0.dismiss(); sendVideo(null); } }) .setNegativeButton(R.string.cancel, null) .setCancelable(false) .show(); } }
@Override public void onClick(View v) { boolean isPlaying = mMediaPlayer.isPlaying(); if (v == mButtonPlayPause) { if (isPlaying) { mMediaPlayer.pause(); mChronometer.stop(); mButtonPlayPause.setImageResource(R.drawable.media_play); mButtonPlayPause.setContentDescription(getResources().getText(R.string.play)); } else { mMediaPlayer.start(); mChronometer.setBase(SystemClock.elapsedRealtime() - mMediaPlayer.getCurrentPosition()); mChronometer.start(); mButtonPlayPause.setImageResource(R.drawable.media_pause); mButtonPlayPause.setContentDescription(getResources().getText(R.string.pause)); } } else if (v == mButtonSkip) { mIndex = (mIndex + 1) % mItems.size(); onClick(mButtonStop); if (isPlaying) { onClick(mButtonPlayPause); } } else if (v == mButtonRewind) { // mMediaPlayer.seekTo(0); mChronometer.setBase(SystemClock.elapsedRealtime()); if (mIndex == 0) { mIndex = mItems.size(); } if (mIndex > 0) { mIndex = (mIndex - 1) % mItems.size(); } onClick(mButtonStop); if (isPlaying) { onClick(mButtonPlayPause); } } else if (v == mButtonStop) { mMediaPlayer.stop(); mMediaPlayer.reset(); mChronometer.stop(); mChronometer.setBase(SystemClock.elapsedRealtime()); prepare(); } else if (v == mButtonConfig) { Intent i = new Intent(this, ConfigActivity.class); startActivity(i); Toast.makeText(this, "Config", Toast.LENGTH_LONG).show(); } }
public void stopRecording(View v) { if (counter == 0) { EditDialog(); counter++; } else if (chronometer != null && myAudioRecorder != null && recording) { recording = false; // timer.cancel(); chronometer.stop(); counter--; myAudioRecorder.stop(); myAudioRecorder.release(); Intent intent = new Intent(RecordActivity.this, MainActivity.class); intent.putExtra("act", "record"); // ActivityOptionsCompat options = // ActivityOptionsCompat.makeSceneTransitionAnimation( // // the context of the activity // RecordActivity.this, // // // For each shared element, add to this method a new Pair item, // // which contains the reference of the view we are transitioning *from*, // // and the value of the transitionName attribute // // new Pair<View, String>(v.findViewById(R.id.record), // "fab"), // new Pair<View, String>(v.findViewById(R.id.bottomBar), // "bottom") // ); startActivity(intent); } }
private void stopRecording(boolean isComingFromViewClick) { if (countDownTimer != null) { countDownTimer.cancel(); } // //// ****** Handles UI items on button click ****** /////// editStopButton.setVisibility(View.GONE); editPlayButton.setVisibility(View.VISIBLE); editRerecordButton.setVisibility(View.VISIBLE); // //// ******* Stop Recording Audio and stop chronometer ******** //////// if (mRecordingHelper != null && mRecordingHelper.isRecording()) { mRecordingHelper.stopRecording(); } editTimeDetailsChronometer.stop(); if (mAudioPlay != null && mAudioPlay.isAudioPlaying()) { mAudioPlay.stopPlayBack(); } if (isFromFavorite) { mAudioPlay = new AudioPlay(mFavoriteList.id, this, isFromFavorite); } else { mAudioPlay = new AudioPlay(entry.id, this, isFromFavorite); } String displayTime = new DisplayTimeForChronometer().getDisplayTime(mAudioPlay.getPlayBackTime()); editTimeDetailsChronometer.setText(displayTime); Map<String, String> map = new HashMap<String, String>(); map.put("Display Time ", displayTime); FlurryAgent.onEvent(getString(R.string.audio_recording_time), map); }
/** Stop the timer of the chronometer. */ private void stopTimer() { startBn.setEnabled(true); stopBn.setEnabled(false); isPaused = true; matchChron.stop(); isPausedFirstRun = true; }
public void pause() { // Show the finish button finishButton.setVisibility(View.VISIBLE); // Changes the text and the colour of the button startButton.setText("Resume"); startButton.getBackground().setColorFilter(Color.GREEN, PorterDuff.Mode.MULTIPLY); // Save the current time timeWhenPaused = myChrono.getBase() - SystemClock.elapsedRealtime(); myChrono.stop(); // Set a yellow marker on the current paused location LatLng pauseLocation = new LatLng(latitude, longitude); map.addMarker( new MarkerOptions() .position(pauseLocation) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW))); // Zoom out to fit route points on the map. // This shows the user the total distance travelled on the map int last = routePoints.size(); if (last >= 2) { LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); for (int i = 0; i < last; i++) { boundsBuilder.include(routePoints.get(i)); } LatLngBounds bounds = boundsBuilder.build(); map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 180)); } else ; }
public void stop_GPS_Capture() { Chronometer chrono = (Chronometer) findViewById(R.id.chronometer); chronoBase = SystemClock.elapsedRealtime(); chrono.stop(); locationManager.removeUpdates(this); GPS_captureStarted = false; }
/** * 根据状态,修改按钮属性及关闭操作 * * @param reason */ private void finishCalling() { try { // set Chronometer view gone.. mChronometer.stop(); // mChronometer.setVisibility(View.GONE); // 3 second mis , finsh this activit ... mHandler.postDelayed(finish, 3000); mVideoTopTips.setVisibility(View.VISIBLE); mCameraSwitch.setVisibility(View.GONE); mVideoTopTips.setText(R.string.voip_calling_finish); if (isConnect) { mVideoLayout.setVisibility(View.GONE); mVideoIcon.setVisibility(View.VISIBLE); // bottom can't click ... mVideoStop.setEnabled(false); } else { mVideoCancle.setEnabled(false); } } catch (Exception e) { e.printStackTrace(); } }
@Override public void onClick(View view) { switch (view.getId()) { case R.id.switch_btn: switchCamera(); break; case R.id.recorder_start: // start recording if (!startRecording()) return; Toast.makeText(this, R.string.The_video_to_start, Toast.LENGTH_SHORT).show(); btn_switch.setVisibility(View.INVISIBLE); btnStart.setVisibility(View.INVISIBLE); btnStart.setEnabled(false); btnStop.setVisibility(View.VISIBLE); // 重置其他 chronometer.setBase(SystemClock.elapsedRealtime()); chronometer.start(); break; case R.id.recorder_stop: btnStop.setEnabled(false); // 停止拍摄 stopRecording(); btn_switch.setVisibility(View.VISIBLE); chronometer.stop(); btnStart.setVisibility(View.VISIBLE); btnStop.setVisibility(View.INVISIBLE); new AlertDialog.Builder(this) .setMessage(R.string.Whether_to_send) .setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); sendVideo(null); } }) .setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (localPath != null) { File file = new File(localPath); if (file.exists()) file.delete(); } finish(); } }) .setCancelable(false) .show(); break; default: break; } }
protected void stopChronoAndSeek() { if (observer != null) observer.stop(); seekBarSound.setProgress(0); firstChornometer.stop(); firstChornometer.setBase(SystemClock.elapsedRealtime()); if (soundLeft != null) soundLeft.cancel(); secondChronometer.setText("00:00"); }
// stop recodrding for extaudio class private void stopRecording() { mExtAudioRecorder.stop(); mExtAudioRecorder.release(); mRecordTime.stop(); // mRecordTime.setVisibility(View.INVISIBLE); showSoundController(); mIsRecording = false; mRecordingTimer.cancel(); }
public static void stop() { chrono.stop(); lapTimes.add(saveLapTime()); adapter.notifyDataSetChanged(); startButt.setEnabled(true); lapButt.setEnabled(false); stopButt.setEnabled(false); }
public void resetData() { fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_play)); refresh.setVisibility(View.INVISIBLE); time.stop(); maxSpeed.setText(""); averageSpeed.setText(""); distance.setText(""); time.setText("00:00:00"); data = new Data(onGpsServiceUpdate); }
// @Override public void onClick(View v) { switch (v.getId()) { /* case R.id.recordIntent: Intent i = new Intent("android.provider.MediaStore.RECORD_SOUND"); startActivityForResult(i, 0); break;*/ case R.id.playAudio: watch.setBase(SystemClock.elapsedRealtime()); watch.start(); playRecording(); watch.stop(); break; case R.id.startAudio: watch.setBase(SystemClock.elapsedRealtime()); watch.start(); startRecording(); break; case R.id.stopAudio: watch.stop(); stopRecording(); break; case R.id.pickDateAudio: showDatePickerDialog(v); break; case R.id.pickTimeAudio: showTimePickerDialog(v); break; case R.id.saveAudio: saveAudioData(v); break; case R.id.cancelAudio: break; } }
@Override protected void onPause() { super.onPause(); Log.d(TAG, "onPause"); if (mMediaPlayer != null) { mMediaPlayer.reset(); mMediaPlayer.release(); mMediaPlayer = null; mChronometer.stop(); } }
private void pauseSnapping() { Log.d(LOG_TAG, "pauseSnapping"); mFlightDuraChrono.stop(); mDurationOfFlight = SystemClock.elapsedRealtime() - mFlightDuraChrono.getBase(); isSnapping = false; if (mCamera != null) { mCamera.release(); mCamera = null; } }
private void endGame() { // stop the timer mTimer.stop(); // reset flag mGameInProgress = false; // calculate elapsed time long elapsedTime = SystemClock.elapsedRealtime() - mTimer.getBase(); // calculate score mGameScore = calculateScore(elapsedTime); }
@Override public void onClick(View v) { int i = v.getId(); if (i == R.id.btn_refuse_call) { refuseBtn.setEnabled(false); handler.sendEmptyMessage(MSG_CALL_REJECT); } else if (i == R.id.btn_answer_call) { answerBtn.setEnabled(false); closeSpeakerOn(); callStateTextView.setText("正在接听..."); comingBtnContainer.setVisibility(View.INVISIBLE); hangupBtn.setVisibility(View.VISIBLE); voiceContronlLayout.setVisibility(View.VISIBLE); handler.sendEmptyMessage(MSG_CALL_ANSWER); } else if (i == R.id.btn_hangup_call) { hangupBtn.setEnabled(false); chronometer.stop(); endCallTriggerByMe = true; callStateTextView.setText(getResources().getString(R.string.hanging_up)); handler.sendEmptyMessage(MSG_CALL_END); } else if (i == R.id.iv_mute) { if (isMuteState) { // 关闭静音 muteImage.setImageResource(R.drawable.em_icon_mute_normal); EMClient.getInstance().callManager().resumeVoiceTransfer(); isMuteState = false; } else { // 打开静音 muteImage.setImageResource(R.drawable.em_icon_mute_on); EMClient.getInstance().callManager().pauseVoiceTransfer(); isMuteState = true; } } else if (i == R.id.iv_handsfree) { if (isHandsfreeState) { // 关闭免提 handsFreeImage.setImageResource(R.drawable.em_icon_speaker_normal); closeSpeakerOn(); isHandsfreeState = false; } else { handsFreeImage.setImageResource(R.drawable.em_icon_speaker_on); openSpeakerOn(); isHandsfreeState = true; } } else { } }
private void stopRecordingAndPlayback() { if (mRecordingHelper != null && mRecordingHelper.isRecording()) { if (editTimeDetailsChronometer != null) { editTimeDetailsChronometer.stop(); } mRecordingHelper.stopRecording(); } if (mAudioPlay != null && mAudioPlay.isAudioPlaying()) { if (editTimeDetailsChronometer != null) { editTimeDetailsChronometer.stop(); } if (isFromFavorite) { mAudioPlay = new AudioPlay(mFavoriteList.id, this, isFromFavorite); } else { mAudioPlay = new AudioPlay(entry.id, this, isFromFavorite); } if (editTimeDetailsChronometer != null) { editTimeDetailsChronometer.setText( new DisplayTimeForChronometer().getDisplayTime(mAudioPlay.getPlayBackTime())); } mAudioPlay.stopPlayBack(); } }
private void finishCalling() { mInfoLl.setVisibility(View.VISIBLE); answer.setVisibility(View.GONE); handUpBefore.setVisibility(View.GONE); mLoaclVideoView.setVisibility(View.GONE); mVideoTopTips.setText(R.string.ec_voip_calling_finish); if (isConnect) { duration = SystemClock.elapsedRealtime() - mChronometer.getBase(); mChronometer.stop(); mVedioGoing.setVisibility(View.GONE); mLoaclVideoView.setVisibility(View.GONE); } // insertCallLog(); finish(); isConnect = false; }
@SuppressLint("SimpleDateFormat") public void run() { if (rbZone1.isChecked()) { gasto += 0.25; monto -= 0.25; timeHora = (int) (monto / 0.25); } else { gasto += 0.50; monto -= 0.50; timeHora = (int) (monto / 0.50); } txtViewGasto.setText("$" + String.format("%.2f", gasto)); txtViewMonto.setText("$" + String.format("%.2f", monto)); txtViewTimeRestante.setText(timeHora + ":00:00"); /* * Date d = new Date(chronometer.getBase()); SimpleDateFormat sdf = * new SimpleDateFormat("HH:mm:ss"); * txtViewZona.setText(sdf.format(d)); */ if (monto <= 1) { imgState.setImageResource(R.drawable.state_yellow); } if (monto <= -2) { imgState.setImageResource(R.drawable.state_red); MainActivity.monto = monto; start = false; btnStart.setEnabled(true); btnFinish.setEnabled(false); chronometer.stop(); AlertDialog.Builder alertaSimple = new AlertDialog.Builder(mycontext); alertaSimple.setTitle("Mensaje"); alertaSimple.setMessage( "El Monto de su Parquimetro se agotado y se ha cargado a su cuenta $2. Debido ha que sobrepaso el limite. Realice una recarga para continuar."); alertaSimple.setPositiveButton("Aceptar", null); alertaSimple.create(); alertaSimple.show(); } else if (monto < -1) { imgState.setImageResource(R.drawable.state_red); } }
private void finishCalling(int reason) { mInfoLl.setVisibility(View.VISIBLE); answer.setVisibility(View.GONE); handUpBefore.setVisibility(View.GONE); mVideoTopTips.setText(CallFailReason.getCallFailReason(reason)); mLoaclVideoView.setVisibility(View.GONE); if (isConnect) { duration = SystemClock.elapsedRealtime() - mChronometer.getBase(); mChronometer.stop(); mVedioGoing.setVisibility(View.GONE); } isConnect = false; VoIPCallHelper.releaseCall(mCallId); if (reason == 175603) { return; } // insertCallLog(); finish(); }
private void stopSnapping() { Log.d(LOG_TAG, "stopSnapping"); isSnapping = false; mFlightDuraChrono.stop(); mDurationOfFlight = SystemClock.elapsedRealtime() - mFlightDuraChrono.getBase(); if (mCamera != null) { mCamera.release(); mCamera = null; } mSnapDisbatcher.stopDisbatching(); mDirectionListener.stopListening(); Intent resultIntent = new Intent(); resultIntent.putExtra(mRes.getString(R.string.intent_extra_flight_duration), mDurationOfFlight); resultIntent.putExtra(mRes.getString(R.string.intent_extra_snap_count), mNumberOfSnapsTaken); setResult(RESULT_OK, resultIntent); finish(); }
private void finishCalling(Reason reason) { try { // mChronometer.setVisibility(View.GONE); mVideoTopTips.setVisibility(View.VISIBLE); mCameraSwitch.setVisibility(View.GONE); if (isConnect) { mChronometer.stop(); mVideoLayout.setVisibility(View.GONE); mVideoIcon.setVisibility(View.VISIBLE); isConnect = false; // bottom can't click ... mVideoStop.setEnabled(false); } else { mVideoCancle.setEnabled(false); } mHandler.postDelayed(finish, 3000); // 处理通话结束状态 if (reason == Reason.DECLINED) { mVideoTopTips.setText( getString( R.string.str_video_call_end, mVoipAccount.substring(mVoipAccount.length() - 3, mVoipAccount.length()))); } else if (reason == Reason.CALLMISSED) { mVideoTopTips.setText(getString(R.string.voip_calling_timeout)); } else if (reason == Reason.PAYMENT) { mVideoTopTips.setText(getString(R.string.voip_call_fail_no_cash)); } else if (reason == Reason.UNKNOWN) { mVideoTopTips.setText(getString(R.string.voip_calling_finish)); } else if (reason == Reason.NOTRESPONSE) { mVideoTopTips.setText(getString(R.string.voip_call_fail)); } else if (reason == Reason.VERSIONNOTSUPPORT) { mVideoTopTips.setText(getString(R.string.str_video_not_support)); } else if (reason == Reason.OTHERVERSIONNOTSUPPORT) { mVideoTopTips.setText(getString(R.string.str_other_voip_not_support)); } else { mVideoTopTips.setText(getString(R.string.voip_calling_network_instability)); } } catch (Exception e) { e.printStackTrace(); } }
@Override public void onClick(View view) { if (view.getId() == R.id.id_button_start) { vibrator.vibrate(500); chronometer.setBase(SystemClock.elapsedRealtime()); chronometer.start(); singleton.setChronoIsStarted(true); changeButtonStartStop(); communicationFragments.inverseButtonsInLap(); } else if (view.getId() == R.id.id_button_stop) { chronometer.stop(); singleton.setChronoIsStarted(false); changeButtonStartStop(); communicationFragments.inverseButtonsInLap(); } else if (view.getId() == R.id.id_button_direct_to_lap) { communicationFragments.changeFragment(VIEW_LAP); changeButtonDirect(VIEW_LAP); } else if (view.getId() == R.id.id_button_back_to_menu) { communicationFragments.changeFragment(VIEW_MENU); changeButtonDirect(VIEW_MENU); } }
public void onClick_Finish(View v) { // Send message to Watch String message = "Finish"; new SendToDataLayerThread("/message_path", message).start(); // Stop the Stopwatch myChrono.stop(); String finalText = myChrono.getText().toString(); final double finalDist = totalDist; // Take returned value from below function to calculate the average speed double avgSpeed = calculateAverageSpeed(); // Start the final Activity Intent intentFinished = new Intent(MapsActivity.this, FinishedActivity.class); intentFinished.putExtra("speed", avgSpeed); intentFinished.putExtra("time", finalText); intentFinished.putExtra("distance", finalDist); intentFinished.putExtra("speedList", speedList); startActivity(intentFinished); }
public void setLocation(Location location) { if (projectSite == null) return; this.location = location; txtLat.setText("" + location.getLatitude()); txtLng.setText("" + location.getLongitude()); txtAccuracy.setText("" + location.getAccuracy()); if (location.getAccuracy() == seekBar.getProgress() || location.getAccuracy() < seekBar.getProgress()) { listener.onEndScanRequested(); isScanning = false; stopRotatingLogo(); chronometer.stop(); resetLogo(); btnScan.setText(ctx.getString(R.string.start_scan)); btnSave.setVisibility(View.VISIBLE); projectSite.setLatitude(location.getLatitude()); projectSite.setLongitude(location.getLongitude()); projectSite.setAccuracy(location.getAccuracy()); Util.expand(btnSave, 200, null); Log.d(LOG, "----------- onEndScanRequested - stopped scanning"); } Util.flashSeveralTimes(hero, 300, 1, null); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_refuse_call: // 拒绝接听 refuseBtn.setEnabled(false); if (ringtone != null) ringtone.stop(); try { EMChatManager.getInstance().rejectCall(); } catch (Exception e1) { e1.printStackTrace(); saveCallRecord(0); finish(); } callingState = CallingState.REFUESD; break; case R.id.btn_answer_call: // 接听电话 answerBtn.setEnabled(false); if (ringtone != null) ringtone.stop(); if (isInComingCall) { try { callStateTextView.setText("正在接听..."); EMChatManager.getInstance().answerCall(); isAnswered = true; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); saveCallRecord(0); finish(); return; } } comingBtnContainer.setVisibility(View.INVISIBLE); hangupBtn.setVisibility(View.VISIBLE); voiceContronlLayout.setVisibility(View.VISIBLE); closeSpeakerOn(); break; case R.id.btn_hangup_call: // 挂断电话 hangupBtn.setEnabled(false); if (soundPool != null) soundPool.stop(streamID); chronometer.stop(); endCallTriggerByMe = true; callStateTextView.setText(getResources().getString(R.string.hanging_up)); try { EMChatManager.getInstance().endCall(); } catch (Exception e) { e.printStackTrace(); saveCallRecord(0); finish(); } break; case R.id.iv_mute: // 静音开关 if (isMuteState) { // 关闭静音 muteImage.setImageResource(R.drawable.icon_mute_normal); audioManager.setMicrophoneMute(false); isMuteState = false; } else { // 打开静音 muteImage.setImageResource(R.drawable.icon_mute_on); audioManager.setMicrophoneMute(true); isMuteState = true; } break; case R.id.iv_handsfree: // 免提开关 if (isHandsfreeState) { // 关闭免提 handsFreeImage.setImageResource(R.drawable.icon_speaker_normal); closeSpeakerOn(); isHandsfreeState = false; } else { handsFreeImage.setImageResource(R.drawable.icon_speaker_on); openSpeakerOn(); isHandsfreeState = true; } break; default: break; } }
public void onClick(View v) { mChronometer.stop(); }
@Override protected void deleteFile() { editTimeDetailsChronometer.stop(); fileHelper.deleteAllEntryFiles(entry.id); }