Code example for SeekBar

Methods: getMaxgetProgress

0
 
        public void onStartTrackingTouch(SeekBar seekBar) {
        } 
 
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            boolean before = progress == 0, after = seekBar.getMax() == progress, middle = seekBar.getMax() / 2 ==
                    progress;
            if (before || after || middle) {
                vibrator.vibrate(17);
            } 
            // sadly makes the damn seekbar wiggle 
//            beforeTextView.setTypeface(before?boldTypeFace:defaultTypeface); 
//            afterTextView.setTypeface(after?boldTypeFace:defaultTypeface); 
            float unitProgress = unitProgress(seekBar);
 
            notifyTheOthers(unitProgress);
 
        } 
 
 
        private float unitProgress(SeekBar seekBar) {
            return ((float) seekBar.getProgress()) / seekBar.getMax();
        } 
    } 
 
    private void notifyTheOthers(float unitProgress) {
        Log.d(TAG, "notifyTheOthers stateUpdateListener=" + stateUpdateListener);