Java Code Examples for android.widget.SeekBar#setProgress()

The following examples show how to use android.widget.SeekBar#setProgress() . 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: Step4CalculatorActivityTest.java    From android-agera with Apache License 2.0 6 votes vote down vote up
public static ViewAction setProgress(int progress) {
    return new ViewAction() {
        @Override
        public void perform(UiController uiController, View view) {
            SeekBar seekBar = (SeekBar) view;
            seekBar.setProgress(progress);
        }
        @Override
        public String getDescription() {
            return "Set a progress on a SeekBar";
        }
        @Override
        public Matcher<View> getConstraints() {
            return ViewMatchers.isAssignableFrom(SeekBar.class);
        }
    };
}
 
Example 2
Source File: SpringSettingsBottomDialog.java    From CircularReveal with MIT License 6 votes vote down vote up
private SeekBar createConfigurationView(CharSequence label, int defaultVal,
    SeekBar.OnSeekBarChangeListener changeListener) {

  final TextView labelView =
      new AppCompatTextView(getContext(), null, R.style.TextAppearance_AppCompat_Caption);
  labelView.setText(label);
  labelView.setLayoutParams(createMarginLayoutParams(MATCH_PARENT, WRAP_CONTENT, 0, 0, 0, dp(8)));

  final SeekBar seekBar = new SeekBar(getContext());
  seekBar.setProgress(defaultVal);
  seekBar.setMax(100);
  seekBar.setOnSeekBarChangeListener(changeListener);

  seekBar.setLayoutParams(createMarginLayoutParams(MATCH_PARENT, WRAP_CONTENT, 0, 0, 0, dp(16)));

  addView(labelView);
  addView(seekBar);
  return seekBar;
}
 
Example 3
Source File: FABActivity.java    From fab with Apache License 2.0 5 votes vote down vote up
private void initStrokeWidthSeekBar() {
	strokeWidthSeekBar = (SeekBar) findViewById(R.id.fab_activity_seekbar_stroke_width);
	final int progress = (int) (pxToDp(actionButton.getStrokeWidth())
			* SEEKBAR_PROGRESS_MULTIPLIER);
	strokeWidthSeekBar.setProgress(progress);
	strokeWidthSeekBar.setOnSeekBarChangeListener(new StrokeWidthChangeListener());
}
 
Example 4
Source File: ReaderSettingDialog.java    From FriendBook with GNU General Public License v3.0 5 votes vote down vote up
private void setBrightness(int progress, SeekBar seekBar) {
    if (progress < 0 || progress > seekBar.getMax()) {
        return;
    }
    if (readTvLightnessSystem.isSelected()) {
        setAutoBrightness(false, readTvLightnessSystem);
    }
    seekBar.setProgress(progress);
    BrightnessUtils.setBrightness(getOwnerActivity(), progress);
}
 
Example 5
Source File: ColorDialogPreference.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(final SeekBar seekBar, final int progress,
                              final boolean fromUser) {
    int color = Color.rgb(
            mSeekBarRed.getProgress(),
            mSeekBarGreen.getProgress(),
            mSeekBarBlue.getProgress());
    setHeaderText(color);
    if (!fromUser) {
        seekBar.setProgress(progress);
    }
}
 
Example 6
Source File: SeekBarPreference.java    From Lyrically with MIT License 5 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    mSeekBarValue = (TextView) view.findViewById(R.id.seekbarValue);
    mSeekBar = (SeekBar) view.findViewById(R.id.seekbar);
    mSeekBar.setProgress(mProgress);
    mSeekBarValue.setText(mProgress + "");
    mSeekBar.setOnSeekBarChangeListener(this);
}
 
Example 7
Source File: TileOverlayDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tile_overlay_demo);

    transparencyBar = (SeekBar) findViewById(R.id.transparencySeekBar);
    transparencyBar.setMax(TRANSPARENCY_MAX);
    transparencyBar.setProgress(0);

    SupportMapFragment mapFragment =
            (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}
 
Example 8
Source File: SeekBarPreference.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
/**
 * Persist the seekBar's progress value if callChangeListener
 * returns true, otherwise set the seekBar's progress to the stored value
 */
void syncProgress(SeekBar seekBar) {
    int progress = seekBar.getProgress();
    if (progress != mProgress) {
        if (callChangeListener(progress)) {
            setProgress(progress, false);
        } else {
            seekBar.setProgress(mProgress);
        }
    }
}
 
Example 9
Source File: MeServoMotor.java    From Makeblock-App-For-Android with MIT License 5 votes vote down vote up
public void setEnable(Handler handler){
	mHandler = handler;
	valueTxt = (TextView) view.findViewById(R.id.slideBarValue);
	slider = (SeekBar) view.findViewById(R.id.sliderBar);
	slider.setOnSeekBarChangeListener(this);
	slider.setProgress(0);
	return;
}
 
Example 10
Source File: SeekBarPreference.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
/**
 * Persist the seekBar's progress value if callChangeListener
 * returns true, otherwise set the seekBar's progress to the stored value
 */
void syncProgress(SeekBar seekBar) {
    int progress = seekBar.getProgress();
    if (progress != mProgress) {
        if (callChangeListener(progress)) {
            setProgress(progress, false);
        } else {
            seekBar.setProgress(mProgress);
        }
    }
}
 
Example 11
Source File: SeekBarPreference.java    From always-on-amoled with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected View onCreateDialogView() {

    LinearLayout.LayoutParams params;
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(6, 6, 6, 6);

    TextView mSplashText = new TextView(mContext);
    mSplashText.setPadding(72, 10, 30, 10);
    if (mDialogMessage != null)
        mSplashText.setText(mDialogMessage);
    layout.addView(mSplashText);

    mValueText = new TextView(mContext);
    mValueText.setGravity(Gravity.CENTER_HORIZONTAL);
    mValueText.setTextSize(32);
    params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    layout.addView(mValueText, params);

    mSeekBar = new SeekBar(mContext);
    mSeekBar.setOnSeekBarChangeListener(this);
    layout.addView(mSeekBar, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    if (shouldPersist())
        mValue = getPersistedInt(mDefault);

    mSeekBar.setMax(mMax);
    mSeekBar.setProgress(mValue);

    return layout;
}
 
Example 12
Source File: Main.java    From SMP with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
    final int states = PlayerState.Prepared |
            PlayerState.Started |
            PlayerState.Paused |
            PlayerState.PlaybackCompleted;
    if (serviceBound && musicSrv.isInState(states)) {
        Log.d("Main", "onStopTrackingTouch setProgress" + RowSong.secondsToMinutes(seekBar.getProgress()));
        seekBar.setProgress(seekBar.getProgress());
        // valid state : {Prepared, Started, Paused, PlaybackCompleted}
        musicSrv.seekTo(seekBar.getProgress());
    }

    touchSeekbar = false;
}
 
Example 13
Source File: SeekBarPreference.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Persist the seekBar's progress value if callChangeListener
 * returns true, otherwise set the seekBar's progress to the stored value
 */
private void syncProgress(SeekBar seekBar) {
    float value = seekBarProgressToPrefValue(seekBar.getProgress());
    if (value != mValue) {
        if (callChangeListener(value)) {
            setValue(value, false);
        } else {
            seekBar.setProgress(prefValueToSeekBarProgress(mValue));
        }
    }
}
 
Example 14
Source File: PerformanceLineChart.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_performance_linechart);

    mTvCount = (TextView) findViewById(R.id.tvValueCount);
    mSeekBarValues = (SeekBar) findViewById(R.id.seekbarValues);
    mTvCount.setText("500");

    mSeekBarValues.setProgress(500);
    
    mSeekBarValues.setOnSeekBarChangeListener(this);

    mChart = (LineChart) findViewById(R.id.chart1);
    mChart.setDrawGridBackground(false);

    // no description text
    mChart.setDescription("");
    mChart.setNoDataTextDescription("You need to provide data for the chart.");

    // enable touch gestures
    mChart.setTouchEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);

    // if disabled, scaling can be done on x- and y-axis separately
    mChart.setPinchZoom(false);
          
    mChart.getAxisLeft().setDrawGridLines(false);
    mChart.getAxisRight().setEnabled(false);
    mChart.getXAxis().setDrawGridLines(true);
    mChart.getXAxis().setDrawAxisLine(false);

    // dont forget to refresh the drawing
    mChart.invalidate();
}
 
Example 15
Source File: EqualizerFragment.java    From Audinaut with GNU General Public License v3.0 4 votes vote down vote up
private void updateBars(boolean changedEnabled) {
    try {
        boolean isEnabled = equalizer.getEnabled();
        short minEQLevel = equalizer.getBandLevelRange()[0];
        short maxEQLevel = equalizer.getBandLevelRange()[1];
        for (Map.Entry<Short, SeekBar> entry : bars.entrySet()) {
            short band = entry.getKey();
            SeekBar bar = entry.getValue();
            bar.setEnabled(isEnabled);
            if (band >= (short) 0) {
                short setLevel;
                if (changedEnabled) {
                    setLevel = (short) (equalizer.getBandLevel(band) - masterLevel);
                    if (isEnabled) {
                        bar.setProgress(equalizer.getBandLevel(band) - minEQLevel);
                    } else {
                        bar.setProgress(-minEQLevel);
                    }
                } else {
                    bar.setProgress(equalizer.getBandLevel(band) - minEQLevel);
                    setLevel = (short) (equalizer.getBandLevel(band) + masterLevel);
                }
                if (setLevel < minEQLevel) {
                    setLevel = minEQLevel;
                } else if (setLevel > maxEQLevel) {
                    setLevel = maxEQLevel;
                }
                equalizer.setBandLevel(band, setLevel);
            } else if (!isEnabled) {
                bar.setProgress(-minEQLevel);
            }
        }

        bassBar.setEnabled(isEnabled);
        if (loudnessBar != null) {
            loudnessBar.setEnabled(isEnabled);
        }
        if (changedEnabled && !isEnabled) {
            bass.setStrength((short) 0);
            bassBar.setProgress(0);
            if (loudnessBar != null) {
                loudnessEnhancer.setGain(0);
                loudnessBar.setProgress(0);
            }
        }

        if (!isEnabled) {
            masterLevel = 0;
            SharedPreferences prefs = Util.getPreferences(context);
            SharedPreferences.Editor editor = prefs.edit();
            editor.putInt(Constants.PREFERENCES_EQUALIZER_SETTINGS, masterLevel);
            editor.apply();
        }
    } catch (Exception e) {
        Log.e(TAG, "Failed to update bars");
    }
}
 
Example 16
Source File: RangeSelector.java    From NClientV2 with Apache License 2.0 4 votes vote down vote up
private View.OnClickListener getNextListener(SeekBar s){
    return v -> s.setProgress(s.getProgress()+1);
}
 
Example 17
Source File: StackedBarActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
	setContentView(R.layout.activity_barchart);

	tvX = (TextView) findViewById(R.id.tvXMax);
	tvY = (TextView) findViewById(R.id.tvYMax);

	mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
	mSeekBarX.setOnSeekBarChangeListener(this);

	mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
	mSeekBarY.setOnSeekBarChangeListener(this);

	mChart = (BarChart) findViewById(R.id.chart1);
	mChart.setOnChartValueSelectedListener(this);

	mChart.setDescription("");

	// if more than 60 entries are displayed in the chart, no values will be
	// drawn
	mChart.setMaxVisibleValueCount(60);

	// scaling can now only be done on x- and y-axis separately
	mChart.setPinchZoom(false);

	mChart.setDrawGridBackground(false);
	mChart.setDrawBarShadow(false);

	mChart.setDrawValueAboveBar(false);

	// change the position of the y-labels
	YAxis leftAxis = mChart.getAxisLeft();
	leftAxis.setValueFormatter(new MyYAxisValueFormatter());
	leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
	mChart.getAxisRight().setEnabled(false);

	XAxis xLabels = mChart.getXAxis();
	xLabels.setPosition(XAxisPosition.TOP);

	// mChart.setDrawXLabels(false);
	// mChart.setDrawYLabels(false);

	// setting data
	mSeekBarX.setProgress(12);
	mSeekBarY.setProgress(100);

	Legend l = mChart.getLegend();
	l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
	l.setFormSize(8f);
	l.setFormToTextSpace(4f);
	l.setXEntrySpace(6f);

	// mChart.setDrawLegend(false);
}
 
Example 18
Source File: PlayerActivity.java    From monkeyboard-radio-android with GNU General Public License v3.0 4 votes vote down vote up
public void initialisePlayerAttributesUi(Bundle savedInstanceState) {
    channelStatusBarLayout = (ConstraintLayout) findViewById(R.id.channel_status_bar_constraint_layout);
    fmFrequencyTextView = (TextView) findViewById(R.id.fm_frequency_text);
    channelNameTextView = (TextView) findViewById(R.id.channel_name);
    slideshowImageView = (ImageView) findViewById(R.id.slideshow_image);
    dataRateTextView = (TextView) findViewById(R.id.data_rate);
    ensembleTextView = (TextView) findViewById(R.id.station_ensemble_name);
    genreTextView = (TextView) findViewById(R.id.station_genre);
    playStatusTextView = (TextView) findViewById(R.id.play_status);
    signalStrengthView = (TextView) findViewById(R.id.signal_strength);
    signalStrengthIcon = (ImageView) findViewById(R.id.signal_strength_icon);
    programTextTextView = (TextView) findViewById(R.id.program_text);
    stereoStateTextView = (TextView) findViewById(R.id.program_stereo_mode);

    volumeSeekBar = (SeekBar) findViewById(R.id.volume_seek_bar);
    volumeText = (TextView) findViewById(R.id.volume_text);
    volumeSeekbarHolder = findViewById(R.id.volume_seekbar_holder);

    noStationsTextView = (TextView) findViewById(R.id.no_saved_stations_text);

    closeVolumeUi();

    if (savedInstanceState != null) {
        Log.v(TAG, "Loading previous states");
        fmFrequencyTextView.setText(
                savedInstanceState.getString(String.valueOf(R.id.fm_frequency_text))
        );

        if (!fmFrequencyTextView.getText().toString().isEmpty()) {
            fmFrequencyTextView.setVisibility(View.VISIBLE);
        } else {
            fmFrequencyTextView.setVisibility(View.GONE);
        }

        updateChannelNameText(
                savedInstanceState.getString(String.valueOf(R.id.channel_name))
        );

        dataRateTextView.setText(
                savedInstanceState.getString(String.valueOf(R.id.data_rate))
        );
        ensembleTextView.setText(
                savedInstanceState.getString(String.valueOf(R.id.station_ensemble_name))
        );
        genreTextView.setText(
                savedInstanceState.getString(String.valueOf(R.id.station_genre))
        );
        playStatusTextView.setText(
                savedInstanceState.getString(String.valueOf(R.id.play_status))
        );

        programTextTextView.setText(
                savedInstanceState.getString(String.valueOf(R.id.program_text))
        );

        updateSlideshowImage(
                (Bitmap) savedInstanceState.getParcelable(String.valueOf(R.id.slideshow_image))
        );

        stereoStateTextView.setText(
                savedInstanceState.getString(String.valueOf(R.id.program_stereo_mode))
        );

        volumeSeekBar.setProgress(
                savedInstanceState.getInt(String.valueOf(R.id.volume_seek_bar))
        );
        volumeText.setText(
                savedInstanceState.getString(String.valueOf(R.id.volume_text))
        );

        onDabSignalQualityChanged(savedInstanceState.getInt(String.valueOf(R.id.signal_strength)));
    }
}
 
Example 19
Source File: BarChartActivitySinus.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_barchart_sinus);
    
    mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(),"othersine.txt");

    tvX = (TextView) findViewById(R.id.tvValueCount);

    mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues);

    mChart = (BarChart) findViewById(R.id.chart1);

    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);

    mChart.setDescription("");

    // if more than 60 entries are displayed in the chart, no values will be
    // drawn
    mChart.setMaxVisibleValueCount(60);

    // scaling can now only be done on x- and y-axis separately
    mChart.setPinchZoom(false);

    // draw shadows for each bar that show the maximum value
    // mChart.setDrawBarShadow(true);

    // mChart.setDrawXLabels(false);

    mChart.setDrawGridBackground(false);
    // mChart.setDrawYLabels(false);

    mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setTypeface(mTf);
    xAxis.setDrawGridLines(false);
    xAxis.setEnabled(false);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(mTf);
    leftAxis.setLabelCount(6, false);
    leftAxis.setAxisMinValue(-2.5f);
    leftAxis.setAxisMaxValue(2.5f);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setTypeface(mTf);
    rightAxis.setLabelCount(6, false);
    rightAxis.setAxisMinValue(-2.5f);
    rightAxis.setAxisMaxValue(2.5f);

    mSeekBarX.setOnSeekBarChangeListener(this);
    mSeekBarX.setProgress(150); // set data

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.BELOW_CHART_LEFT);
    l.setForm(LegendForm.SQUARE);
    l.setFormSize(9f);
    l.setTextSize(11f);
    l.setXEntrySpace(4f);

    mChart.animateXY(2000, 2000);
}
 
Example 20
Source File: BubbleChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_bubblechart);

    tvX = (TextView) findViewById(R.id.tvXMax);
    tvY = (TextView) findViewById(R.id.tvYMax);

    mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBarX.setOnSeekBarChangeListener(this);

    mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
    mSeekBarY.setOnSeekBarChangeListener(this);

    mChart = (BubbleChart) findViewById(R.id.chart1);
    mChart.setDescription("");

    tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");

    mChart.setOnChartValueSelectedListener(this);

    mChart.setDrawGridBackground(false);

    mChart.setTouchEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);

    mChart.setMaxVisibleValueCount(200);
    mChart.setPinchZoom(true);

    mSeekBarX.setProgress(5);
    mSeekBarY.setProgress(50);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
    l.setTypeface(tf);

    YAxis yl = mChart.getAxisLeft();
    yl.setTypeface(tf);
    yl.setSpaceTop(30f);
    yl.setSpaceBottom(30f);
    yl.setDrawZeroLine(false);
    
    mChart.getAxisRight().setEnabled(false);

    XAxis xl = mChart.getXAxis();
    xl.setPosition(XAxis.XAxisPosition.BOTTOM);
    xl.setTypeface(tf);
}