Example usage for android.widget SeekBar setMax

List of usage examples for android.widget SeekBar setMax

Introduction

In this page you can find the example usage for android.widget SeekBar setMax.

Prototype

@Override
    public synchronized void setMax(int max) 

Source Link

Usage

From source file:org.ciasaboark.tacere.activity.SettingsActivity.java

private void drawMediaWidgets() {
    TextView mediaTV = (TextView) findViewById(id.settings_mediaText);
    if (prefs.getIsServiceActivated()) {
        mediaTV.setTextColor(getResources().getColor(R.color.textcolor));
    } else {//from w  ww.ja v  a 2  s.c  o m
        mediaTV.setTextColor(getResources().getColor(R.color.textColorDisabled));
    }

    //the media volumes toggle
    Switch mediaSwitch = (Switch) findViewById(id.adjustMediaCheckBox);
    SeekBar mediaSB = (SeekBar) findViewById(id.mediaSeekBar);
    if (prefs.getAdjustMedia()) {
        mediaSwitch.setChecked(true);
    } else {
        mediaSwitch.setChecked(false);
    }
    mediaSwitch.setEnabled(prefs.getIsServiceActivated());
    findViewById(id.settings_mediaBox).setEnabled(prefs.getIsServiceActivated());

    //the media volumes slider
    mediaSB.setMax(VolumesManager.getMaxMediaVolume());
    mediaSB.setProgress(prefs.getCurMediaVolume());
    if (prefs.getAdjustMedia() && prefs.getIsServiceActivated()) {
        this.animateRevealView(mediaSB);
        mediaSB.setEnabled(true);
    } else {
        mediaSB.setEnabled(false);
        this.animateHideView(mediaSB);
    }
    mediaSB.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            prefs.setCurMediaVolume(progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            //required stub
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            //required stub
        }
    });
}

From source file:com.cw.litenote.note.NoteUi.java

public static void primaryVideoSeekBarProgressUpdater(ViewPager pager, int curNotePos, int curVideoPos,
        String pictureUri) {// ww  w  . j a  v  a2 s .co  m
    //        System.out.println("NoteUi / _primaryVideoSeekBarProgressUpdater / curNotePos = " + curNotePos);
    if ((UtilVideo.mVideoView == null))
        return;

    ViewGroup pictureGroup = getPictureGroup(curNotePos, pager);

    TextView videoView_currPosition = null;
    SeekBar videoView_seekBar = null;
    TextView videoView_fileLength = null;

    if (pictureGroup != null) {
        videoView_currPosition = (TextView) (pictureGroup.findViewById(R.id.video_current_pos));
        videoView_seekBar = (SeekBar) (pictureGroup.findViewById(R.id.video_seek_bar));
        videoView_fileLength = (TextView) (pictureGroup.findViewById(R.id.video_file_length));
    }

    // show current play position
    if (videoView_currPosition != null) {
        videoView_currPosition.setText(Util.getTimeFormatString(curVideoPos));
        videoView_currPosition.setVisibility(View.VISIBLE);
    }

    // show file length
    if (!Util.isEmptyString(pictureUri)) {
        // set file length
        if (videoView_fileLength != null) {
            videoView_fileLength.setText(Util.getTimeFormatString(videoFileLength_inMilliSeconds));
            videoView_fileLength.setVisibility(View.VISIBLE);
        }
    }

    // show seek bar progress
    if (videoView_seekBar != null) {
        videoView_seekBar.setVisibility(View.VISIBLE);
        videoView_seekBar.setMax(99);
        videoView_progress = (int) (((float) curVideoPos / videoFileLength_inMilliSeconds) * 100);
        videoView_seekBar.setProgress(videoView_progress);
    }
}

From source file:mx.klozz.xperience.tweaker.fragments.CPUAdvanced.java

public void openDialog(String title, final int min, final int max, final Preference pref, final String path,
        final String key) {
    Resources res = context.getResources();
    String cancel = res.getString(R.string.cancel);
    String ok = res.getString(R.string.ok);
    final EditText settingText;
    LayoutInflater factory = LayoutInflater.from(context);
    final View alphaDialog = factory.inflate(R.layout.seekbar_dialog, null);

    final SeekBar seekbar = (SeekBar) alphaDialog.findViewById(R.id.seek_bar);
    int currentProgress = Integer.parseInt(Helpers.LeerUnaLinea(path));
    seekbar.setMax(max - min);
    if (currentProgress > max)
        currentProgress = max - min;//from w  w w  .  ja  v a2s  .c om
    else if (currentProgress < min)
        currentProgress = 0;
    else
        currentProgress = currentProgress - min;

    seekbar.setProgress(currentProgress);

    settingText = (EditText) alphaDialog.findViewById(R.id.setting_text);
    settingText.setText(Integer.toString(currentProgress + min));

    settingText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                int val = Integer.parseInt(settingText.getText().toString()) - min;
                seekbar.setProgress(val);
                return true;
            }
            return false;
        }
    });

    settingText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            try {
                int val = Integer.parseInt(s.toString());
                if (val > max) {
                    s.replace(0, s.length(), Integer.toString(max));
                    val = max;
                }
                seekbar.setProgress(val - min);
            } catch (NumberFormatException ex) {
            }
        }
    });

    SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {
            final int mSeekbarProgress = seekbar.getProgress();
            if (fromUser) {
                settingText.setText(Integer.toString(mSeekbarProgress + min));
            }
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekbar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekbar) {
        }
    };
    seekbar.setOnSeekBarChangeListener(seekBarChangeListener);

    new AlertDialog.Builder(context).setTitle(title).setView(alphaDialog)
            .setNegativeButton(cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // nothing
                }
            }).setPositiveButton(ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    int val = min;
                    if (!settingText.getText().toString().equals(""))
                        val = Integer.parseInt(settingText.getText().toString());
                    if (val < min)
                        val = min;
                    seekbar.setProgress(val - min);
                    int newProgress = seekbar.getProgress() + min;
                    new CMDProcessor().su
                            .runWaitFor("busybox echo " + Integer.toString(newProgress) + " > " + path);
                    final String v = Helpers.LeerUnaLinea(path);
                    mPreferences.edit().putString(key, v).commit();
                    pref.setSummary(v);

                }
            }).create().show();
}

From source file:it.scoppelletti.mobilepower.preference.SeekBarPreference.java

/**
 * Collega la preferenza al dialogo. //  w  w  w.  j a va2s.c o m
 * 
 * @param view Dialogo.
 */
@Override
protected void onBindDialogView(View view) {
    SeekBar control;

    if (myValue > myValueMax) {
        myValue = myValueMax;
    }

    myEditingPreview = (TextView) view.findViewById(R.id.txt_value);
    if (!StringUtils.isBlank(myPreview)) {
        myEditingPreview.setText("", TextView.BufferType.SPANNABLE);
        myEditingPreview.setSpannableFactory(new SeekBarPreference.PreviewSpannableFactory(this));
    }

    setEditingValue(myValue);

    control = (SeekBar) view.findViewById(R.id.bar_value);
    control.setMax(myValueMax - myValueMin);
    control.setProgress(myValue - myValueMin);
    control.setOnSeekBarChangeListener(new SeekBarPreference.OnValueChangeListener(this));
}

From source file:mx.klozz.xperience.tweaker.fragments.CPUAdvanced.java

protected void showDialog(final int curval, final int min, final int step, final int total, final String titlu,
        final String key) {
    final LayoutInflater factory = LayoutInflater.from(context);
    final View voltageDialog = factory.inflate(R.layout.voltage_dialog, null);

    final SeekBar voltageSeek = (SeekBar) voltageDialog.findViewById(R.id.voltageSeek);
    final TextView voltageMeter = (TextView) voltageDialog.findViewById(R.id.voltageMeter);

    voltageMeter.setText(String.valueOf(curval) + " V");
    voltageSeek.setMax(total);
    voltageSeek.setProgress(getNearestStepIndex(curval, vmin, vstep, nvsteps));
    voltageSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override//from  ww  w . ja v  a 2s . c o  m
        public void onProgressChanged(SeekBar sb, int progress, boolean fromUser) {
            if (fromUser) {
                final String volt = Integer.toString(progress * step + min);
                voltageMeter.setText(volt + " V");
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    new AlertDialog.Builder(context).setTitle(titlu).setView(voltageDialog)
            .setPositiveButton(getResources().getString(R.string.ps_volt_save),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.cancel();
                            final String value = Integer.toString(voltageSeek.getProgress() * step + min);
                            SharedPreferences.Editor editor = mPreferences.edit();
                            editor.putString(key, value).commit();
                            if (key.equals("pref_krait_hi")) {
                                mKraitHi.setSummary(getString(R.string.ps_krait_hi, value));
                                new CMDProcessor().su
                                        .runWaitFor("busybox echo " + value + " > " + KRAIT_HIGH_PATH);
                            } else if (key.equals("pref_krait_lo")) {
                                mKraitLo.setSummary(getString(R.string.ps_krait_lo, value));
                                new CMDProcessor().su
                                        .runWaitFor("busybox echo " + value + " > " + KRAIT_LOWER_PATH);
                            }
                        }
                    })
            .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.cancel();
                }
            }).create().show();

}

From source file:com.cw.litenote.note.AudioUi_note.java

public static void initAudioProgress(AppCompatActivity act, String audioUriInDB, ViewPager _pager) {
    SeekBar seekBar = (SeekBar) act.findViewById(R.id.pager_img_audio_seek_bar);
    ImageView mPager_audio_play_button = (ImageView) act.findViewById(R.id.pager_btn_audio_play);

    // set audio block listeners
    setAudioBlockListener(act, audioUriInDB, _pager);

    mProgress = 0;/*  www.  j  a  v  a  2s . c o  m*/

    mAudioUriInDB = audioUriInDB;
    showAudioName(act);

    TextView audioTitle = (TextView) act.findViewById(R.id.pager_audio_title);
    audioTitle.setSelected(false);
    mPager_audio_play_button.setImageResource(R.drawable.ic_media_play);
    audioTitle.setTextColor(ColorSet.getPauseColor(act));
    audioTitle.setSelected(false);

    // current position
    int curHour = Math.round((float) (mProgress / 1000 / 60 / 60));
    int curMin = Math.round((float) ((mProgress - curHour * 60 * 60 * 1000) / 1000 / 60));
    int curSec = Math.round((float) ((mProgress - curHour * 60 * 60 * 1000 - curMin * 60 * 1000) / 1000));
    String curr_pos_str = String.format(Locale.ENGLISH, "%2d", curHour) + ":"
            + String.format(Locale.ENGLISH, "%02d", curMin) + ":"
            + String.format(Locale.ENGLISH, "%02d", curSec);

    TextView audio_curr_pos = (TextView) act.findViewById(R.id.pager_audio_current_pos);
    audio_curr_pos.setText(curr_pos_str);
    audio_curr_pos.setTextColor(ColorSet.color_white);

    // audio seek bar
    seekBar.setProgress(mProgress); // This math construction give a percentage of "was playing"/"song length"
    seekBar.setMax(99); // It means 100% .0-99
    seekBar.setVisibility(View.VISIBLE);

    // get audio file length
    try {
        if (Util.isUriExisted(mAudioUriInDB, act)) {
            MediaPlayer mp = MediaPlayer.create(act, Uri.parse(mAudioUriInDB));
            mediaFileLength = mp.getDuration();
            mp.release();
        }
    } catch (Exception e) {
        System.out.println("AudioUi_note / _initAudioProgress / exception");
    }
    // set audio file length
    int fileHour = Math.round((float) (mediaFileLength / 1000 / 60 / 60));
    int fileMin = Math.round((float) ((mediaFileLength - fileHour * 60 * 60 * 1000) / 1000 / 60));
    int fileSec = Math
            .round((float) ((mediaFileLength - fileHour * 60 * 60 * 1000 - fileMin * 1000 * 60) / 1000));

    String strHour = String.format(Locale.ENGLISH, "%2d", fileHour);
    String strMinute = String.format(Locale.ENGLISH, "%02d", fileMin);
    String strSecond = String.format(Locale.ENGLISH, "%02d", fileSec);
    String strLength = strHour + ":" + strMinute + ":" + strSecond;

    TextView audio_length = (TextView) act.findViewById(R.id.pager_audio_file_length);
    audio_length.setText(strLength);
    audio_length.setTextColor(ColorSet.color_white);
}

From source file:re.serialout.MainScreen.java

public void setUpFreqSlider() {
    //sets up the freq slider.
    SeekBar seekBar = (SeekBar) findViewById(R.id.freqSeekBar);
    final TextView freqView = (TextView) findViewById(R.id.freqtext);
    seekBar.setProgress((int) 0.6 * seekBar.getProgress());
    seekBar.setMax(10000);
    seekBar.setProgress(4000);/* w w  w  . j  av  a  2  s.  c  om*/
    freqView.setText("Frequency: " + (10000 + 4000));
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            System.out.println("Current freq: " + (10000 + progress));
            freqView.setText("Frequency: " + (10000 + progress));
            playSine.adjustFreq(10000 + progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
}

From source file:net.xpece.android.support.preference.SeekBarPreference.java

@Override
public void onBindViewHolder(final PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    final SeekBar seekBar = (SeekBar) holder.findViewById(R.id.seekbar);

    holder.itemView.setOnKeyListener(buildSeekBarKeyListener(seekBar));

    final TextView info = (TextView) holder.findViewById(R.id.seekbar_value);
    if (info != null) {
        mInfoViews.put(info, this);
        bindInfo(info);/*from  w  w  w.j  a v a2s  .  c  o m*/
    }

    if (seekBar == null) {
        Log.e(TAG, "SeekBar view is null in onBindViewHolder.");
        return;
    }
    seekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);
    seekBar.setMax(mMax - mMin);
    // If the increment is not zero, use that. Otherwise, use the default mKeyProgressIncrement
    // in AbsSeekBar when it's zero. This default increment value is set by AbsSeekBar
    // after calling setMax. That's why it's important to call setKeyProgressIncrement after
    // calling setMax() since setMax() can change the increment value.
    if (mSeekBarIncrement != 0) {
        seekBar.setKeyProgressIncrement(mSeekBarIncrement);
    } else {
        mSeekBarIncrement = seekBar.getKeyProgressIncrement();
    }
    seekBar.setProgress(mSeekBarValue - mMin);
    seekBar.setEnabled(isEnabled());

    fixDrawableStateOnAndroid2(seekBar);
}

From source file:jp.co.rediscovery.firstflight.ConfigFragment.java

/**
 * ??/*from  w ww  . j  av  a 2 s . com*/
 * @param root
 */
private void initConfigFlight(final View root) {
    if (DEBUG)
        Log.v(TAG, "initConfigFlight:");
    // 
    mMaxAltitudeLabel = root.findViewById(R.id.max_altitude_textview);
    SeekBar seekbar = root.findViewById(R.id.max_altitude_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mMaxAltitude = mFlightController.getMaxAltitude();
    try {
        seekbar.setProgress((int) ((mMaxAltitude.current() - mMaxAltitude.min())
                / (mMaxAltitude.max() - mMaxAltitude.min()) * 1000));
    } catch (final Exception e) {
        seekbar.setProgress(0);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateMaxAltitude(mMaxAltitude.current());
    // 
    // bebop?5-3050km/hr???13.9m/s/300.46[m/s/]
    mMaxTiltLabel = root.findViewById(R.id.max_tilt_textview);
    seekbar = root.findViewById(R.id.max_tilt_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mMaxTilt = mFlightController.getMaxTilt();
    try {
        seekbar.setProgress(
                (int) ((mMaxTilt.current() - mMaxTilt.min()) / (mMaxTilt.max() - mMaxTilt.min()) * 1000));
    } catch (final Exception e) {
        seekbar.setProgress(0);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateMaxTilt(mMaxTilt.current());
    // /?
    mMaxVerticalSpeedLabel = root.findViewById(R.id.max_vertical_speed_textview);
    seekbar = root.findViewById(R.id.max_vertical_speed_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mMaxVerticalSpeed = mFlightController.getMaxVerticalSpeed();
    try {
        seekbar.setProgress((int) ((mMaxVerticalSpeed.current() - mMaxVerticalSpeed.min())
                / (mMaxVerticalSpeed.max() - mMaxVerticalSpeed.min()) * 1000));
    } catch (final Exception e) {
        seekbar.setProgress(0);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateMaxVerticalSpeed(mMaxVerticalSpeed.current());
    // 
    mMaxRotationSpeedLabel = root.findViewById(R.id.max_rotation_speed_textview);
    seekbar = root.findViewById(R.id.max_rotation_speed_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mMaxRotationSpeed = mFlightController.getMaxRotationSpeed();
    try {
        seekbar.setProgress((int) ((mMaxRotationSpeed.current() - mMaxRotationSpeed.min())
                / (mMaxRotationSpeed.max() - mMaxRotationSpeed.min()) * 1000));
    } catch (final Exception e) {
        seekbar.setProgress(0);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateMaxRotationSpeed(mMaxRotationSpeed.current());
}

From source file:jp.co.rediscovery.firstflight.ConfigFragment.java

/**
 * ??//from w  ww .j a  va2s.  c  om
 * @param root
 */
private void initConfigGamepad(final View root) {
    // 
    //      final CheckBox checkbox = (CheckBox)root.findViewById(R.id.usb_driver_checkbox);
    //      checkbox.setChecked(mPref.getBoolean(KEY_GAMEPAD_USE_DRIVER, false));
    //      checkbox.setOnCheckedChangeListener(mOnCheckedChangeListener);
    mGamepadMaxControlValueLabel = root.findViewById(R.id.gamepad_sensitivity_textview);
    SeekBar seekbar = root.findViewById(R.id.gamepad_sensitivity_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadMaxControlValue = mPref.getFloat(APP_CONFIG_KEY_GAMEPAD_SENSITIVITY, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadMaxControlValue + APP_SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(APP_SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadMaxControlValue(mGamepadMaxControlValue);
    // X
    mGamepadScaleXLabel = root.findViewById(R.id.gamepad_scale_x_textview);
    seekbar = root.findViewById(R.id.gamepad_scale_seekbar_x);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleX = mPref.getFloat(APP_CONFIG_KEY_GAMEPAD_SCALE_X, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleX * APP_SCALE_FACTOR + APP_SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(APP_SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleX(mGamepadScaleX);
    // Y
    mGamepadScaleYLabel = root.findViewById(R.id.gamepad_scale_y_textview);
    seekbar = root.findViewById(R.id.gamepad_scale_seekbar_y);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleY = mPref.getFloat(APP_CONFIG_KEY_GAMEPAD_SCALE_Y, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleY * APP_SCALE_FACTOR + APP_SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(APP_SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleY(mGamepadScaleY);
    // Z
    mGamepadScaleZLabel = root.findViewById(R.id.gamepad_scale_z_textview);
    seekbar = root.findViewById(R.id.gamepad_scale_seekbar_z);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleZ = mPref.getFloat(APP_CONFIG_KEY_GAMEPAD_SCALE_Z, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleZ * APP_SCALE_FACTOR + APP_SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(APP_SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleZ(mGamepadScaleZ);
    // R
    mGamepadScaleRLabel = root.findViewById(R.id.gamepad_scale_r_textview);
    seekbar = root.findViewById(R.id.gamepad_scale_seekbar_r);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleR = mPref.getFloat(APP_CONFIG_KEY_GAMEPAD_SCALE_R, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleR * APP_SCALE_FACTOR + APP_SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(APP_SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleR(mGamepadScaleR);
}