Search in sources :

Example 1 with Chronometer

use of android.widget.Chronometer in project AnkiChinaAndroid by ankichinateam.

the class AbstractFlashcardViewer method initTimer.

protected void initTimer() {
    final TypedValue typedValue = new TypedValue();
    mShowTimer = mCurrentCard.showTimer();
    if (mShowTimer && mCardTimer.getVisibility() == View.INVISIBLE) {
        mCardTimer.setVisibility(View.VISIBLE);
    } else if (!mShowTimer && mCardTimer.getVisibility() != View.INVISIBLE) {
        mCardTimer.setVisibility(View.INVISIBLE);
    }
    // Set normal timer color
    getTheme().resolveAttribute(android.R.attr.textColor, typedValue, true);
    mCardTimer.setTextColor(typedValue.data);
    mCardTimer.setBase(SystemClock.elapsedRealtime());
    mCardTimer.start();
    // Stop and highlight the timer if it reaches the time limit.
    getTheme().resolveAttribute(R.attr.maxTimerColor, typedValue, true);
    final int limit = mCurrentCard.timeLimit();
    mCardTimer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {

        @Override
        public void onChronometerTick(Chronometer chronometer) {
            long elapsed = SystemClock.elapsedRealtime() - chronometer.getBase();
            if (elapsed >= limit) {
                chronometer.setTextColor(typedValue.data);
                chronometer.stop();
            }
        }
    });
}
Also used : Chronometer(android.widget.Chronometer) SuppressLint(android.annotation.SuppressLint) TypedValue(android.util.TypedValue)

Example 2 with Chronometer

use of android.widget.Chronometer in project MOBILE-AND-SOCIAL-SENSINGSYSTEMS by kamran-mehravar.

the class MonitorActivity method startMonitoring.

private void startMonitoring() {
    Chronometer timeRecorded = findViewById(R.id.chronometer1);
    initTempFiles();
    sm.registerListener(this, sAcceleration, SensorManager.SENSOR_DELAY_GAME);
    monitoringStatus = true;
    filteredData = new StringBuilder();
    rawData = new StringBuilder();
    startNewWindow();
    timeRecorded.setBase(SystemClock.elapsedRealtime());
    timeRecorded.start();
}
Also used : Chronometer(android.widget.Chronometer)

Example 3 with Chronometer

use of android.widget.Chronometer in project platform_frameworks_base by android.

the class ElementLayoutActivity method createChronometer.

private void createChronometer() {
    Chronometer chronometer = new Chronometer(this);
    chronometer.setBase(mRandom.nextLong());
    mLayout.addView(chronometer);
    chronometer.start();
}
Also used : Chronometer(android.widget.Chronometer)

Example 4 with Chronometer

use of android.widget.Chronometer in project NoiseCapture by Ifsttar.

the class MeasurementActivity method initGuiState.

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);
    }
}
Also used : Chronometer(android.widget.Chronometer) TextView(android.widget.TextView)

Example 5 with Chronometer

use of android.widget.Chronometer in project android_frameworks_base by DirtyUnicorns.

the class ElementLayoutActivity method createChronometer.

private void createChronometer() {
    Chronometer chronometer = new Chronometer(this);
    chronometer.setBase(mRandom.nextLong());
    mLayout.addView(chronometer);
    chronometer.start();
}
Also used : Chronometer(android.widget.Chronometer)

Aggregations

Chronometer (android.widget.Chronometer)11 TextView (android.widget.TextView)2 SuppressLint (android.annotation.SuppressLint)1 TypedValue (android.util.TypedValue)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 Nullable (androidx.annotation.Nullable)1