android.widget.Chronometer Java Examples

The following examples show how to use android.widget.Chronometer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MiscViewsDemoFragment.java    From overscroll-decor with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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;
}
 
Example #2
Source File: MediaShootActivity.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: MiscViewsDemoFragment.java    From elasticity with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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;
}
 
Example #4
Source File: ChronoActivity2.java    From android-lifecycles with Apache License 2.0 6 votes vote down vote up
@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
            = new ViewModelProvider(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();
}
 
Example #5
Source File: ChatActivity.java    From ChatMessagesAdapter-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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);
}
 
Example #6
Source File: CountDownView.java    From FastWaiMai with MIT License 5 votes vote down vote up
@Override
public void onChronometerTick(Chronometer chronometer) {
	if (mNextTime <= 0) {
		if (mNextTime == 0) {
			CountDownView.this.stop();
			if (null != mListener)
				mListener.onTimeComplete();
		}
		mNextTime = 0;
		updateTimeText();
		return;
	}
	mNextTime--;
	updateTimeText();
}
 
Example #7
Source File: CallActivity.java    From linphone-android with GNU General Public License v3.0 5 votes vote down vote up
private void displayConferenceCall(final Call call) {
    LinearLayout conferenceCallView =
            (LinearLayout)
                    LayoutInflater.from(this)
                            .inflate(R.layout.call_conference_cell, null, false);

    TextView contactNameView = conferenceCallView.findViewById(R.id.contact_name);
    LinphoneContact contact =
            ContactsManager.getInstance().findContactFromAddress(call.getRemoteAddress());
    if (contact != null) {
        ContactAvatar.displayAvatar(
                contact, conferenceCallView.findViewById(R.id.avatar_layout), true);
        contactNameView.setText(contact.getFullName());
    } else {
        String displayName = LinphoneUtils.getAddressDisplayName(call.getRemoteAddress());
        ContactAvatar.displayAvatar(
                displayName, conferenceCallView.findViewById(R.id.avatar_layout), true);
        contactNameView.setText(displayName);
    }

    Chronometer timer = conferenceCallView.findViewById(R.id.call_timer);
    timer.setBase(SystemClock.elapsedRealtime() - 1000 * call.getDuration());
    timer.start();

    ImageView removeFromConference =
            conferenceCallView.findViewById(R.id.remove_from_conference);
    removeFromConference.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    LinphoneManager.getCallManager().removeCallFromConference(call);
                }
            });

    mConferenceList.addView(conferenceCallView);
}
 
Example #8
Source File: CallActivity.java    From linphone-android with GNU General Public License v3.0 5 votes vote down vote up
private void displayPausedCall(final Call call) {
    LinearLayout callView =
            (LinearLayout)
                    LayoutInflater.from(this).inflate(R.layout.call_inactive_row, null, false);

    TextView contactName = callView.findViewById(R.id.contact_name);
    Address address = call.getRemoteAddress();
    LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(address);
    if (contact == null) {
        String displayName = LinphoneUtils.getAddressDisplayName(address);
        contactName.setText(displayName);
        ContactAvatar.displayAvatar(displayName, callView.findViewById(R.id.avatar_layout));
    } else {
        contactName.setText(contact.getFullName());
        ContactAvatar.displayAvatar(contact, callView.findViewById(R.id.avatar_layout));
    }

    Chronometer timer = callView.findViewById(R.id.call_timer);
    timer.setBase(SystemClock.elapsedRealtime() - 1000 * call.getDuration());
    timer.start();

    ImageView resumeCall = callView.findViewById(R.id.call_pause);
    resumeCall.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    togglePause(call);
                }
            });

    mCallsList.addView(callView);
}
 
Example #9
Source File: RecorderVideoActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
private void initViews() {
	btn_switch = (Button) findViewById(R.id.switch_btn);
	btn_switch.setOnClickListener(this);
	btn_switch.setVisibility(View.VISIBLE);
	mVideoView = (VideoView) findViewById(R.id.mVideoView);
	btnStart = (ImageView) findViewById(R.id.recorder_start);
	btnStop = (ImageView) findViewById(R.id.recorder_stop);
	btnStart.setOnClickListener(this);
	btnStop.setOnClickListener(this);
	mSurfaceHolder = mVideoView.getHolder();
	mSurfaceHolder.addCallback(this);
	mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
	chronometer = (Chronometer) findViewById(R.id.chronometer);
}
 
Example #10
Source File: MainActivity.java    From VideoRecorderTest with Apache License 2.0 5 votes vote down vote up
private void initView() {
    mSurfaceView  = (SurfaceView)findViewById(R.id.capture_surfaceview);
    mBtnStartStop = (ImageButton) findViewById(R.id.ib_stop);
    mBtnSet= (ImageButton) findViewById(R.id.capture_imagebutton_setting);
    mBtnShowFile= (ImageButton) findViewById(R.id.capture_imagebutton_showfiles);
    mTimer= (Chronometer) findViewById(R.id.crm_count_time);
}
 
Example #11
Source File: CustomCapturerVideoActivity.java    From video-quickstart-android with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom_capturer);

    capturedView = (LinearLayout) findViewById(R.id.captured_view);
    videoView = (VideoView) findViewById(R.id.video_view);
    timerView = (Chronometer) findViewById(R.id.timer_view);
    timerView.start();

    // Once added we should see our linear layout rendered live below
    localVideoTrack = LocalVideoTrack.create(this, true, new ViewCapturer(capturedView));
    localVideoTrack.addRenderer(videoView);
}
 
Example #12
Source File: ChronoActivity1.java    From android-lifecycles with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Chronometer chronometer = findViewById(R.id.chronometer);

    chronometer.start();
}
 
Example #13
Source File: AudioRecorderActivity.java    From microbit with Apache License 2.0 5 votes vote down vote up
private void create(String action) {
    setContentView(R.layout.activity_audio_recorder);
    filenameTxt = (TextView) findViewById(R.id.filenameTxt);
    chronometer = (Chronometer) findViewById(R.id.chronometer);
    imageMic = (ImageView) findViewById(R.id.imageMic);

    //preallocate to avoid memory leak
    drawable_mic_off = getResources().getDrawable(R.drawable.recording_off);
    drawable_mic_on = getResources().getDrawable(R.drawable.recording);

    backPressed = false;

    notificationLargeIconBitmapRecordingOn = BitmapFactory.decodeResource(getResources(), R.drawable.recording);
    notificationLargeIconBitmapRecordingOff = BitmapFactory.decodeResource(getResources(), R.drawable.recording_off);

    mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setLargeIcon(notificationLargeIconBitmapRecordingOff)
            .setTicker(getString(R.string.audio_recorder_notification))
            .setContentTitle(getString(R.string.audio_recorder_notification));

    Drawable d = getResources().getDrawable(R.drawable.bg);
    if(d != null) {
        d.mutate();//prevent affecting all instances of that drawable with color filter
        d.setColorFilter(Color.argb(187, 0, 0, 0), PorterDuff.Mode.SRC_OVER);
        findViewById(R.id.layout).setBackground(d);
    }
    processIntent(action);
}
 
Example #14
Source File: MainActivity.java    From ViewPrinter with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PrinterLogger.setLogLevel(PrinterLogger.LEVEL_VERBOSE);
    ZoomLogger.setLogLevel(ZoomLogger.LEVEL_ERROR);

    setContentView(R.layout.activity_main);
    mDocument = findViewById(R.id.pdf_preview);
    mJpegPrinter = new JpegPrinter(mDocument, this);
    mPngPrinter = new PngPrinter(mDocument, this);
    mPdfPrinter = new PdfPrinter(mDocument, this);

    mDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
    mFilename = "my-document-" + System.currentTimeMillis();

    findViewById(R.id.print_jpeg).setOnClickListener(this);
    findViewById(R.id.print_pdf).setOnClickListener(this);
    findViewById(R.id.print_png).setOnClickListener(this);
    findViewById(R.id.edit).setOnClickListener(this);
    findViewById(R.id.logo_prompt).setOnClickListener(this);

    Chronometer chrono = findViewById(R.id.chrono);
    chrono.start();

    mPanel = findViewById(R.id.controls);
    mPanel.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            BottomSheetBehavior b = BottomSheetBehavior.from(mPanel);
            b.setState(BottomSheetBehavior.STATE_HIDDEN);
            mPanel.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });
    setupControls();
}
 
Example #15
Source File: RecordVoiceButton.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initDialogAndStartRecord() {
    //存放录音文件目录
    File rootDir = mContext.getFilesDir();
    String fileDir = rootDir.getAbsolutePath() + "/voice";
    File destDir = new File(fileDir);
    if (!destDir.exists()) {
        destDir.mkdirs();
    }
    //录音文件的命名格式
    myRecAudioFile = new File(fileDir,
            new DateFormat().format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".amr");
    if (myRecAudioFile == null) {
        cancelTimer();
        stopRecording();
        Toast.makeText(mContext, mContext.getString(R.string.jmui_create_file_failed),
                Toast.LENGTH_SHORT).show();
    }
    recordIndicator = new Dialog(getContext(), IdHelper.getStyle(mContext, "jmui_record_voice_dialog"));
    recordIndicator.setContentView(R.layout.jmui_dialog_record_voice);
    mVolumeIv = (ImageView) recordIndicator.findViewById(R.id.jmui_volume_hint_iv);
    mRecordHintTv = (TextView) recordIndicator.findViewById(R.id.jmui_record_voice_tv);
    mVoiceTime = (Chronometer) recordIndicator.findViewById(R.id.voice_time);

    mTimeDown = (TextView) recordIndicator.findViewById(R.id.time_down);
    mMicShow = (LinearLayout) recordIndicator.findViewById(R.id.mic_show);

    mRecordHintTv.setText(mContext.getString(R.string.jmui_move_to_cancel_hint));
    startRecording();
    recordIndicator.show();
}
 
Example #16
Source File: InCallCard.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
private void initControllerView() {
    photo = (ImageView) findViewById(R.id.contact_photo);
    remoteName = (TextView) findViewById(R.id.contact_name_display_name);
    remoteSipAddress = (TextView) findViewById(R.id.contact_name_sip_address);
    elapsedTime = (Chronometer) findViewById(R.id.elapsedTime);
    callStatusText = (TextView) findViewById(R.id.call_status_text);
    callSecureBar = (ViewGroup) findViewById(R.id.call_secure_bar);
    callSecureText = (TextView) findViewById(R.id.call_secure_text);
    endCallBar = (ViewGroup) findViewById(R.id.end_call_bar);


    View btn;
    btn = findViewById(R.id.endButton);
    btn.setOnClickListener(this);

    btnMenuBuilder = new MenuBuilder(getContext());
    btnMenuBuilder.setCallback(this);
    MenuInflater inflater = new MenuInflater(getContext());
    inflater.inflate(R.menu.in_call_card_menu, btnMenuBuilder);
    
    mActionMenuPresenter = new ActionMenuPresenter(getContext());
    mActionMenuPresenter.setReserveOverflow(true);
    
    btnMenuBuilder.addMenuPresenter(mActionMenuPresenter);
    
    updateMenuView();
}
 
Example #17
Source File: RecordFragment.java    From SoundRecorder with GNU General Public License v3.0 4 votes vote down vote up
private void onRecord(boolean start){

        Intent intent = new Intent(getActivity(), RecordingService.class);

        if (start) {
            // start recording
            mRecordButton.setImageResource(R.drawable.ic_media_stop);
            //mPauseButton.setVisibility(View.VISIBLE);
            Toast.makeText(getActivity(),R.string.toast_recording_start,Toast.LENGTH_SHORT).show();
            File folder = new File(Environment.getExternalStorageDirectory() + "/SoundRecorder");
            if (!folder.exists()) {
                //folder /SoundRecorder doesn't exist, create the folder
                folder.mkdir();
            }

            //start Chronometer
            mChronometer.setBase(SystemClock.elapsedRealtime());
            mChronometer.start();
            mChronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
                @Override
                public void onChronometerTick(Chronometer chronometer) {
                    if (mRecordPromptCount == 0) {
                        mRecordingPrompt.setText(getString(R.string.record_in_progress) + ".");
                    } else if (mRecordPromptCount == 1) {
                        mRecordingPrompt.setText(getString(R.string.record_in_progress) + "..");
                    } else if (mRecordPromptCount == 2) {
                        mRecordingPrompt.setText(getString(R.string.record_in_progress) + "...");
                        mRecordPromptCount = -1;
                    }

                    mRecordPromptCount++;
                }
            });

            //start RecordingService
            getActivity().startService(intent);
            //keep screen on while recording
            getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

            mRecordingPrompt.setText(getString(R.string.record_in_progress) + ".");
            mRecordPromptCount++;

        } else {
            //stop recording
            mRecordButton.setImageResource(R.drawable.ic_mic_white_36dp);
            //mPauseButton.setVisibility(View.GONE);
            mChronometer.stop();
            mChronometer.setBase(SystemClock.elapsedRealtime());
            timeWhenPaused = 0;
            mRecordingPrompt.setText(getString(R.string.record_prompt));

            getActivity().stopService(intent);
            //allow the screen to turn off again once recording is finished
            getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
    }
 
Example #18
Source File: BaseDialogActivity.java    From q-municate-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onChronometerTick(Chronometer chronometer) {
    setChronometerAppropriateColor();
}
 
Example #19
Source File: ChronometerAssert.java    From assertj-android with Apache License 2.0 4 votes vote down vote up
public ChronometerAssert(Chronometer actual) {
  super(actual, ChronometerAssert.class);
}
 
Example #20
Source File: MeasurementActivity.java    From NoiseCapture with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void run() {
    try {
        if(activity.measurementService.isRecording()) {
            int seconds = activity.measurementService.getLeqAdded();
            if(seconds >= MeasurementActivity.DEFAULT_MINIMAL_LEQ && !activity.buttonrecord.isEnabled()) {
                activity.buttonrecord.setEnabled(true);
            }
            Chronometer chronometer = (Chronometer) activity
                    .findViewById(R.id.chronometer_recording_time);
            if (activity.chronometerWaitingToStart.getAndSet(false)) {
                chronometer.setBase(SystemClock.elapsedRealtime() - seconds * 1000);
                TextView overlayMessage = (TextView) activity.findViewById(R.id.textView_message_overlay);
                if(activity.measurementService.isPaused()) {
                    chronometer.stop();
                    chronometer.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.pause_anim));
                    overlayMessage.setText(R.string.measurement_pause);
                } else {
                    chronometer.clearAnimation();
                    chronometer.start();
                    overlayMessage.setText("");
                }
            }

            //Update accuracy hint
            final TextView accuracyText = (TextView) activity.findViewById(R.id.textView_value_gps_precision);
            final ImageView accuracyImageHint = (ImageView) activity.findViewById(R.id.imageView_value_gps_precision);
            Location location = activity.measurementService.getLastLocation();
            if(location != null) {
                float lastPrecision = location.getAccuracy();
                if (lastPrecision < APROXIMATE_LOCATION_ACCURACY) {
                    accuracyImageHint.setImageResource(R.drawable.gps_fixed);
                    accuracyText.setText(activity.getString(R.string.gps_hint_precision,
                            (int)lastPrecision));
                } else {
                    accuracyImageHint.setImageResource(R.drawable.gps_not_fixed);
                    accuracyText.setText(activity.getString(R.string.gps_hint_precision,
                            (int)lastPrecision));
                }
                if (accuracyImageHint.getVisibility() == View.INVISIBLE) {
                    accuracyImageHint.setVisibility(View.VISIBLE);
                }
                long now = System.currentTimeMillis();
                if(now - activity.lastMapLocationRefresh >= REFRESH_MAP_LOCATION_RATE) {
                    activity.getMapControler().updateLocationMarker(new MapFragment.LatLng(location.getLatitude(), location.getLongitude()), location.getAccuracy());
                    activity.lastMapLocationRefresh = now;
                }
            } else {
                accuracyImageHint.setImageResource(R.drawable.gps_off);
                accuracyText.setText(R.string.no_gps_hint);
            }
            // Update current location of user
            final double leq = activity.measurementService.getAudioProcess().getLeq(false);
            activity.setData(activity.measurementService.getAudioProcess().getLeq(false));
            // Change the text and the textcolor in the corresponding textview
            // for the Leqi value
            LeqStats leqStats =
                    activity.measurementService.getFastLeqStats();
            final TextView mTextView = (TextView) activity.findViewById(R.id.textView_value_SL_i);
            formatdBA(leq, mTextView);
            if(activity.measurementService.getLeqAdded() != 0) {
                // Stats are only available if the recording of previous leq are activated
                final TextView valueMin = (TextView) activity.findViewById(R.id
                        .textView_value_Min_i);
                formatdBA(leqStats.getLeqMin(), valueMin);
                final TextView valueMax = (TextView) activity.findViewById(R.id
                        .textView_value_Max_i);
                formatdBA(leqStats.getLeqMax(), valueMax);
                final TextView valueMean = (TextView) activity.findViewById(R.id
                        .textView_value_Mean_i);
                formatdBA(leqStats.getLeqMean(), valueMean);
            }


            int nc = MeasurementActivity.getNEcatColors(leq);    // Choose the color category in
            // function of the sound level
            mTextView.setTextColor(activity.NE_COLORS[nc]);

            // Spectrum data
            activity.updateSpectrumGUI();
        } else {
            activity.initGuiState();
        }

        // Debug processing time
    } finally {
        activity.isComputingMovingLeq.set(false);
    }
}
 
Example #21
Source File: MeasurementActivity.java    From NoiseCapture with GNU General Public License v3.0 4 votes vote down vote up
private void initGuiState() {
    if(measurementService == null) {
        // measurementService is required
        return;
    }
    // Update buttons: cancel enabled; record button to stop;
    // Show start measure hint
    TextView overlayMessage = (TextView) findViewById(R.id.textView_message_overlay);

    initComponents();
    if (measurementService.isStoring()) {
        overlayMessage.setVisibility(View.INVISIBLE);
        buttonPause.setEnabled(true);
        buttonrecord.setImageResource(R.drawable.button_record_pressed);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        // Start chronometer
        chronometerWaitingToStart.set(true);

        MeasurementManager measurementManager = new MeasurementManager(this);

        MapFragment mapFragment = getMapControler();
        if(mapFragment != null) {
            List<MeasurementManager.LeqBatch> locations = measurementManager
                    .getRecordLocations(measurementService.getRecordId(), true, MAX_LOCATIONS_RESTORE_MAP, null,
                            MINIMAL_DISTANCE_RESTORE_MAP);
            mapFragment.cleanMeasurementPoints();
            for(MeasurementManager.LeqBatch location : locations) {
                Storage.Leq leq = location.getLeq();
                String htmlColor = MeasurementExport.getColorFromLevel
                        (location.computeGlobalLeq());
                mapFragment.addMeasurement(new MapFragment.LatLng(leq.getLatitude(), leq
                        .getLongitude()), htmlColor);
            }
        }
    }
    else
    {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        // Enabled/disabled buttons after measurement
        buttonPause.setEnabled(false);
        buttonrecord.setImageResource(R.drawable.button_record);
        buttonrecord.setEnabled(true);
        // Stop and reset chronometer
        Chronometer chronometer = (Chronometer) findViewById(R.id.chronometer_recording_time);
        chronometer.stop();
        overlayMessage.setText(R.string.no_data_text_description);
        overlayMessage.setVisibility(View.VISIBLE);
    }
}
 
Example #22
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void onChronometerTick(Chronometer.OnChronometerTickListener arg) {
  return BaseDSL.attr("onChronometerTick", arg);
}
 
Example #23
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void chronometer(Anvil.Renderable r) {
  return BaseDSL.v(Chronometer.class, r);
}
 
Example #24
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult chronometer() {
  return BaseDSL.v(Chronometer.class);
}
 
Example #25
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void onChronometerTick(Chronometer.OnChronometerTickListener arg) {
  return BaseDSL.attr("onChronometerTick", arg);
}
 
Example #26
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void chronometer(Anvil.Renderable r) {
  return BaseDSL.v(Chronometer.class, r);
}
 
Example #27
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult chronometer() {
  return BaseDSL.v(Chronometer.class);
}
 
Example #28
Source File: VoiceCallActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        finish();
        return;
    }

    setContentView(R.layout.activity_voice_call);
    avatarLoader = new LoadUserAvatar(this, "/sdcard/fanxin/");
    comingBtnContainer = (LinearLayout) findViewById(R.id.ll_coming_call);
    refuseBtn = (Button) findViewById(R.id.btn_refuse_call);
    answerBtn = (Button) findViewById(R.id.btn_answer_call);
    hangupBtn = (Button) findViewById(R.id.btn_hangup_call);
    muteImage = (ImageView) findViewById(R.id.iv_mute);
    handsFreeImage = (ImageView) findViewById(R.id.iv_handsfree);
    callStateTextView = (TextView) findViewById(R.id.tv_call_state);
    nickTextView = (TextView) findViewById(R.id.tv_nick);
    durationTextView = (TextView) findViewById(R.id.tv_calling_duration);
    chronometer = (Chronometer) findViewById(R.id.chronometer);
    voiceContronlLayout = (LinearLayout) findViewById(R.id.ll_voice_control);
    ImageView swing_card = (ImageView) findViewById(R.id.swing_card);
    refuseBtn.setOnClickListener(this);
    answerBtn.setOnClickListener(this);
    hangupBtn.setOnClickListener(this);
    muteImage.setOnClickListener(this);
    handsFreeImage.setOnClickListener(this);

    getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                    | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                    | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                    | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    // 注册语音电话的状态的监听
    addCallStateListener();
    msgid = UUID.randomUUID().toString();

    username = getIntent().getStringExtra("username");
    // 语音电话是否为接收的
    isInComingCall = getIntent().getBooleanExtra("isComingCall", false);
    String nick = MYApplication.getInstance().getContactList()
            .get(username).getNick();
    if (nick != null) {

        nickTextView.setText(nick);

    } else {
        // 设置通话人
        nickTextView.setText(username);
    }

    String avatar = MYApplication.getInstance().getContactList()
            .get(username).getAvatar();
    if (avatar != null) {
        showUserAvatar(swing_card, avatar);

    }

    if (!isInComingCall) {// 拨打电话
        soundPool = new SoundPool(1, AudioManager.STREAM_RING, 0);
        outgoing = soundPool.load(this, R.raw.outgoing, 1);

        comingBtnContainer.setVisibility(View.INVISIBLE);
        hangupBtn.setVisibility(View.VISIBLE);
        st1 = getResources()
                .getString(R.string.Are_connected_to_each_other);
        callStateTextView.setText(st1);
        handler.postDelayed(new Runnable() {
            public void run() {
                streamID = playMakeCallSounds();
            }
        }, 300);
        try {
            // 拨打语音电话
            EMChatManager.getInstance().makeVoiceCall(username);
        } catch (EMServiceNotReadyException e) {
            e.printStackTrace();
            final String st2 = getResources().getString(
                    R.string.Is_not_yet_connected_to_the_server);
            runOnUiThread(new Runnable() {
                public void run() {
                    Toast.makeText(VoiceCallActivity.this, st2, 0).show();
                }
            });
        }
    } else { // 有电话进来
        voiceContronlLayout.setVisibility(View.INVISIBLE);
        Uri ringUri = RingtoneManager
                .getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        audioManager.setMode(AudioManager.MODE_RINGTONE);
        audioManager.setSpeakerphoneOn(true);
        ringtone = RingtoneManager.getRingtone(this, ringUri);
        ringtone.play();
    }
}
 
Example #29
Source File: VoiceeCallActivity.java    From Social with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if(savedInstanceState != null){
        finish();
        return;
    }
    setContentView(R.layout.my_em_activity_voice_call);

    isVoiceCalling = true;
    callType = 0;

    comingBtnContainer = (LinearLayout) findViewById(R.id.ll_coming_call);
    refuseBtn = (Button) findViewById(R.id.btn_refuse_call);
    answerBtn = (Button) findViewById(R.id.btn_answer_call);
    hangupBtn = (Button) findViewById(R.id.btn_hangup_call);
    muteImage = (ImageView) findViewById(R.id.iv_mute);
    handsFreeImage = (ImageView) findViewById(R.id.iv_handsfree);
    callStateTextView = (TextView) findViewById(R.id.tv_call_state);
    nickTextView = (TextView) findViewById(R.id.tv_nick);
    durationTextView = (TextView) findViewById(R.id.tv_calling_duration);
    chronometer = (Chronometer) findViewById(R.id.chronometer);
    voiceContronlLayout = (LinearLayout) findViewById(R.id.ll_voice_control);
    netwrokStatusVeiw = (TextView) findViewById(R.id.tv_network_status);

    refuseBtn.setOnClickListener(this);
    answerBtn.setOnClickListener(this);
    hangupBtn.setOnClickListener(this);
    muteImage.setOnClickListener(this);
    handsFreeImage.setOnClickListener(this);

    getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                    | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    // 注册语音电话的状态的监听
    addCallStateListener();
    msgid = UUID.randomUUID().toString();

    username = getIntent().getStringExtra("username");
    // 语音电话是否为接收的
    isInComingCall = getIntent().getBooleanExtra("isComingCall", false);

    // 设置通话人
    nickTextView.setText(username);
    if (!isInComingCall) {// 拨打电话
        soundPool = new SoundPool(1, AudioManager.STREAM_RING, 0);
        outgoing = soundPool.load(this, R.raw.em_outgoing, 1);

        comingBtnContainer.setVisibility(View.INVISIBLE);
        hangupBtn.setVisibility(View.VISIBLE);
        st1 = getResources().getString(R.string.Are_connected_to_each_other);
        callStateTextView.setText(st1);
        handler.sendEmptyMessage(MSG_CALL_MAKE_VOICE);
    } else { // 有电话进来
        voiceContronlLayout.setVisibility(View.INVISIBLE);
        Uri ringUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        audioManager.setMode(AudioManager.MODE_RINGTONE);
        audioManager.setSpeakerphoneOn(true);
        ringtone = RingtoneManager.getRingtone(this, ringUri);
        ringtone.play();
    }
}
 
Example #30
Source File: RtcActivity.java    From imsdk-android with MIT License 4 votes vote down vote up
protected void initView()
    {
        //localRender = (SurfaceViewRenderer) findViewById(R.id.atom_rtc_glview_call_surface);
        //remoteRender = (SurfaceViewRenderer) findViewById(R.id.atom_rtc_glview_remote_surface);
        vsv = (GLSurfaceView) findViewById(R.id.pub_imsdk_glview_call);
        videoTop = (LinearLayout) findViewById(R.id.pub_imsdk_rtc_top);
        videoLayout = (LinearLayout) findViewById(R.id.pub_imsdk_video_bottom);
        audioLayout = (LinearLayout) findViewById(R.id.pub_imsdk_audio_bottom);
        preBottom = (LinearLayout) findViewById(R.id.pub_imsdk_pre_bottom);

        rtcGravantar = (SimpleDraweeView) findViewById(R.id.pub_imsdk_rtc_gravantar);
        rtcNick = (TextView) findViewById(R.id.pub_imsdk_rtc_nick);
        rtcStatus = (TextView) findViewById(R.id.pub_imsdk_rtc_status);
        rtcMute = (TextView) findViewById(R.id.pub_imsdk_rtc_mute);
        rtcCameraToggle = (TextView) findViewById(R.id.pub_imsdk_rtc_camera_toggle);
        rtcCameraTurn = (ImageView) findViewById(R.id.pub_imsdk_rtc_camera_turn);

        audioHangup = (TextView) findViewById(R.id.pub_imsdk_audio_hangup);
        audioMute = (TextView) findViewById(R.id.pub_imsdk_audio_mute);
        audioMicrophone = (TextView) findViewById(R.id.pub_imsdk_audio_microphone);

        rtc_hangup = (TextView) findViewById(R.id.pub_imsdk_rtc_hangup);
        preAudioPickup = (TextView) findViewById(R.id.pub_imsdk_rtc_pickup_audio);
        preVideoPickup = (TextView) findViewById(R.id.pub_imsdk_rtc_pickup_video);
        preDeny = (TextView) findViewById(R.id.pub_imsdk_rtc_deny);
        chronometer = (Chronometer) findViewById(R.id.pub_imsdk_rtc_time);

        preAudioPickup.setOnClickListener(this);
        preVideoPickup.setOnClickListener(this);
        preDeny.setOnClickListener(this);
        rtc_hangup.setOnClickListener(this);
        rtcMute.setOnClickListener(this);
        rtcCameraToggle.setOnClickListener(this);
        rtcCameraTurn.setOnClickListener(this);

        audioHangup.setOnClickListener(this);
        audioMute.setOnClickListener(this);
        audioMicrophone.setOnClickListener(this);
        /**
         * mute,摄像头翻转,听筒模式暂时禁用

        videoMute.setVisibility(View.INVISIBLE);
        audioMute.setVisibility(View.INVISIBLE);
        audioTing.setVisibility(View.INVISIBLE);
        videoCamera.setVisibility(View.INVISIBLE);*/

        if(!isCaller)
        {
            hidePreBottom();
            if (videoEnable) {
                hidenAudio();
                shownVideo();
            } else {
                hidenVideo();
                showAudio();
            }
        }
        else {
            shownPreBottom();
            hidenVideo();
            hidenAudio();
            videoTop.setVisibility(View.VISIBLE);
//            if (videoEnable) {
            //localRender.setVisibility(View.VISIBLE);
            //remoteRender.setVisibility(View.VISIBLE);
//            } else {
//                audioGravantar.setVisibility(View.VISIBLE);
//                audioStatus.setVisibility(View.VISIBLE);
//                audioNick.setVisibility(View.VISIBLE);
//            }
        }
    }