Java Code Examples for androidx.appcompat.widget.AppCompatSeekBar#setMax()

The following examples show how to use androidx.appcompat.widget.AppCompatSeekBar#setMax() . 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: AudioControlManager.java    From onpc with GNU General Public License v3.0 6 votes vote down vote up
private void updateVolumeGroup(@NonNull final State state, @NonNull final LinearLayout group)
{
    final AppCompatSeekBar progressBar = group.findViewWithTag("tone_progress_bar");
    final ReceiverInformationMsg.Zone zone = state.getActiveZoneInfo();
    final int maxVolume = Math.min(getVolumeMax(state, zone),
            activity.getConfiguration().audioControl.getMasterVolumeMax());

    updateProgressLabel(group, R.string.master_volume, State.getVolumeLevelStr(state.volumeLevel, zone));

    final TextView minValue = group.findViewWithTag("tone_min_value");
    minValue.setText("0");

    final TextView maxValue = group.findViewWithTag("tone_max_value");
    maxValue.setText(State.getVolumeLevelStr(maxVolume, zone));

    progressBar.setMax(maxVolume);
    progressBar.setProgress(Math.max(0, state.volumeLevel));
}
 
Example 2
Source File: AudioControlManager.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("SetTextI18n")
private void updateToneGroup(@NonNull final State state,
                             @NonNull final String toneKey,
                             @NonNull final LinearLayout group,
                             @StringRes final int labelId,
                             int toneLevel, final int noLevel, final int maxZone)
{
    final AppCompatSeekBar progressBar = group.findViewWithTag("tone_progress_bar");
    final ReceiverInformationMsg.ToneControl toneControl = state.getToneControl(toneKey, forceAudioControl);
    final boolean isTone = toneControl != null && toneLevel != noLevel && state.getActiveZone() < maxZone;
    group.setVisibility(isTone ? View.VISIBLE : View.GONE);
    if (isTone)
    {
        updateProgressLabel(group, labelId, Integer.toString(toneLevel));

        final TextView minText = group.findViewWithTag("tone_min_value");
        if (minText != null)
        {
            minText.setText(Integer.toString(toneControl.getMin()));
        }

        final TextView maxText = group.findViewWithTag("tone_max_value");
        if (maxText != null)
        {
            maxText.setText(Integer.toString(toneControl.getMax()));
        }

        final float step = toneControl.getStep() == 0 ? 0.5f : toneControl.getStep();
        final int max = (int) ((float) (toneControl.getMax() - toneControl.getMin()) / step);
        final int progress = (int) ((float) (toneLevel - toneControl.getMin()) / step);
        progressBar.setMax(max);
        progressBar.setProgress(progress);
    }
}
 
Example 3
Source File: SettingsActivity.java    From TwistyTimer with GNU General Public License v3.0 5 votes vote down vote up
private MaterialDialog createAverageSeekDialog(@StringRes int prefKeyResID,
                                     int minValue, int maxValue, @IntegerRes int defaultValueRes) {

    final View dialogView = LayoutInflater.from(
            getActivity()).inflate(R.layout.dialog_settings_progress, null);
    final AppCompatSeekBar seekBar = dialogView.findViewById(R.id.seekbar);

    int defaultValue = getContext().getResources().getInteger(defaultValueRes);

    seekBar.setMax(maxValue);
    seekBar.setProgress(Prefs.getInt(prefKeyResID, defaultValue));

    return ThemeUtils.roundDialog(mContext, new MaterialDialog.Builder(mContext)
            .customView(dialogView, true)
            .positiveText(R.string.action_done)
            .negativeText(R.string.action_cancel)
            .onPositive((dialog, which) -> {
                final int seekProgress = seekBar.getProgress();

                Prefs.edit()
                        .putInt(prefKeyResID, seekProgress > minValue ? seekProgress : minValue)
                        .apply();
            })
            .neutralText(R.string.action_default)
            .onNeutral((dialog, which) -> Prefs.edit().putInt(prefKeyResID, defaultValue).apply())
            .build());
}
 
Example 4
Source File: SeekBarPreference.java    From MaxLock with GNU General Public License v3.0 5 votes vote down vote up
private void initPreference(Context context, AttributeSet attrs) {
    setValuesFromXml(attrs);
    mSeekBar = new AppCompatSeekBar(context, attrs);
    mSeekBar.setPadding(0,0,0,0);
    mSeekBar.setMax(mMaxValue - mMinValue);
    mSeekBar.setOnSeekBarChangeListener(this);
    setWidgetLayoutResource(R.layout.seek_bar_preference);
}