Code example for ProgressBar

Methods: getMaxsetProgress

0
        private long mTimestamp = 0; // Time of last status change in ms
 
        @Override 
        public void handleMessage(Message msg) {
            int rms = msg.arg1;
            int max = mSlider.getMax();
            int progress = (max / 2 * rms) / Math.round(TARGET_RMS);
            if (progress > max) progress = max;
            mSlider.setProgress(progress);
 
            Status state;
            if (rms * TOLERANCE < TARGET_RMS) state = Status.LOW;
            else if (rms > TARGET_RMS * TOLERANCE) state = Status.HIGH;
            else state = Status.OK;
            if (state != mState) {
                long timestamp = System.currentTimeMillis();
                if (timestamp - mTimestamp > DEBOUNCE_TIME) {
                    mStatus.setText(mStatusText[state.ordinal()]);
                    mState = state;
                    mTimestamp = timestamp;
                }