Example usage for android.widget SeekBar getThumb

List of usage examples for android.widget SeekBar getThumb

Introduction

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

Prototype

public Drawable getThumb() 

Source Link

Document

Return the drawable used to represent the scroll thumb - the component that the user can drag back and forth indicating the current value by its position.

Usage

From source file:org.opensilk.common.ui.util.ThemeUtils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void themeSeekBar2(SeekBar seekBar, int color) {
    if (VersionUtils.hasLollipop()) {
        seekBar.getProgressDrawable().setTint(color);
        seekBar.getThumb().setTint(color);
    } else {/*from  w  ww  . ja va2s  .c o  m*/
        seekBar.getProgressDrawable().mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
        if (VersionUtils.hasJellyBean()) {
            seekBar.getThumb().mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
        } else if (seekBar instanceof CompatSeekBar) {
            Drawable thumb = ((CompatSeekBar) seekBar).getThumb();
            if (thumb != null) {
                thumb.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
            }
        }
    }
}

From source file:com.owncloud.android.utils.ThemeUtils.java

/**
 * sets the coloring of the given seek bar to color_accent.
 *
 * @param seekBar the seek bar to be colored
 *//*from  w  w  w  .j  a  v  a2s.co  m*/
public static void colorHorizontalSeekBar(SeekBar seekBar) {
    int color = ThemeUtils.primaryAccentColor();
    colorHorizontalProgressBar(seekBar, color);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
        seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
    }
}

From source file:com.synox.android.utils.DisplayUtils.java

/**
 * sets the coloring of the given seek bar to color_accent.
 *
 * @param seekBar the seek bar to be colored
 *//* w ww  . j  a  va2  s  .  c  o m*/
public static void colorPreLollipopHorizontalSeekBar(SeekBar seekBar) {
    if (seekBar != null && Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
        colorPreLollipopHorizontalProgressBar(seekBar);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            int color = seekBar.getResources().getColor(R.color.accent);
            seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
            seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
        }
    }
}

From source file:com.cerema.cloud2.utils.DisplayUtils.java

/**
 * sets the coloring of the given seek bar to color_accent.
 *
 * @param seekBar the seek bar to be colored
 *//*from ww  w. ja va2  s  . c om*/
public static void colorPreLollipopHorizontalSeekBar(SeekBar seekBar) {
    if (seekBar != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        colorPreLollipopHorizontalProgressBar(seekBar);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            int color = seekBar.getResources().getColor(R.color.color_accent);
            seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
            seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
        }
    }
}

From source file:com.mobicage.rogerthat.util.ui.UIUtils.java

public static void setColors(int color, View... views) {
    if (Build.VERSION.SDK_INT >= 27) {
        return;/*from   w w w.  j a va 2 s  . co  m*/
    }
    for (View view : views) {
        if (view instanceof CheckBox) {
            CheckBox checkbox = (CheckBox) view;
            CompoundButtonCompat.setButtonTintList(checkbox, ColorStateList.valueOf(color));
        } else if (view instanceof FloatingActionButton) {
            //noinspection RedundantCast
            ((FloatingActionButton) view).setBackgroundTintList(ColorStateList.valueOf(color));
        } else if (view instanceof Button || view instanceof ImageButton) {
            Drawable background = view.getBackground();
            if (background != null) {
                background.setColorFilter(color, PorterDuff.Mode.SRC_IN);
            }
        } else if (view instanceof TextInputLayout) {
            UIUtils.colorTextInputLayout((TextInputLayout) view, color);
            // TODO: EditText's who are a child of TextInputLayout their line isn't colored correctly
        } else if (view instanceof EditText) {
            EditText editText = (EditText) view;
            editText.setHighlightColor(color); // When selecting text
            editText.setHintTextColor(color); // Text for the  hint message
            // Line under the textfield
            Drawable background = editText.getBackground();
            if (background != null) {
                DrawableCompat.setTint(background, color);
                editText.setBackground(background);
            }
            UIUtils.setCursorColor(editText, color);
        } else if (view instanceof CheckedTextView) {
            CheckedTextView ctv = (CheckedTextView) view;
            Drawable d = ctv.getCheckMarkDrawable();
            d.setColorFilter(color, PorterDuff.Mode.SRC_IN);
        } else if (view instanceof TextView) {
            ((TextView) view).setLinkTextColor(color);
        } else if (view instanceof SeekBar) {
            SeekBar sb = (SeekBar) view;
            Drawable progress = sb.getProgressDrawable();
            if (progress != null) {
                progress.setColorFilter(color, PorterDuff.Mode.SRC_IN);
            }
            Drawable thumb = sb.getThumb();
            if (thumb != null) {
                thumb.setColorFilter(color, PorterDuff.Mode.SRC_IN);
            }
        } else if (view instanceof ProgressBar) {
            ((ProgressBar) view).getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
        } else {
            L.d("Not coloring view: " + view.toString());
        }
    }
}

From source file:de.uni_weimar.m18.anatomiederstadt.element.SliderFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_slider, container, false);
    SeekBar sb = (SeekBar) view.findViewById(R.id.seekBar);
    // scale mMin and mMax
    mMin = (int) (mMin / mGranularity);
    mMax = (int) (mMax / mGranularity);
    sb.setMax(mMax - mMin);//w w  w  .j  av  a2s  . c o  m
    sb.setProgress((mMax - mMin) / 2);
    final RelativeLayout balloon = (RelativeLayout) view.findViewById(R.id.indicatorBalloon);
    final Space space = (Space) view.findViewById(R.id.balloonSpace);

    final Context context = getActivity();
    final TextView balloonText = (TextView) view.findViewById(R.id.indicatorTextView);
    final float[] value = { 0.0f };
    sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            p.addRule(RelativeLayout.ABOVE, seekBar.getId());
            Rect thumbRect = seekBar.getThumb().getBounds();
            value[0] = mMin + progress * mGranularity;
            String valueString = new DecimalFormat("#.##").format(value[0]);
            balloonText.setText(String.valueOf(valueString) + " " + mSuffix);
            int balloonWidth = balloonText.getWidth();
            p.setMargins(thumbRect.centerX() - balloonWidth / 2, 0, 0, 0);
            balloon.setLayoutParams(p);
            balloon.setVisibility(View.VISIBLE);

            final Animation animFadeOut = AnimationUtils.loadAnimation(context, R.anim.fade_out);
            balloon.startAnimation(animFadeOut);
            animFadeOut.setStartOffset(1000);
            animFadeOut.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    balloon.setVisibility(View.INVISIBLE);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            LevelStateManager stateManager = ((AnatomieDerStadtApplication) getActivity()
                    .getApplicationContext()).getStateManager(getActivity());
            stateManager.saveFloat(mVar, value[0]);
        }
    });
    return view;
}

From source file:com.rks.musicx.ui.fragments.EqFragment.java

private void initEq(View rootView) {
    try {// w  ww  . ja v  a 2  s.c o m
        for (short i = 0; i < Equalizers.getNumberOfBands(); i++) {
            short eqbands = i;
            short[] bandLevel = Equalizers.getBandLevelRange();
            seekBar = new VerticalSeekBar(getContext());
            textView = new TextView(getContext());
            switch (i) {
            case 0:
                seekBar = (VerticalSeekBar) rootView.findViewById(R.id.seek_bar1);
                textView = (TextView) rootView.findViewById(R.id.level1);
                break;
            case 1:
                seekBar = (VerticalSeekBar) rootView.findViewById(R.id.seek_bar2);
                textView = (TextView) rootView.findViewById(R.id.level2);
                break;
            case 2:
                seekBar = (VerticalSeekBar) rootView.findViewById(R.id.seek_bar3);
                textView = (TextView) rootView.findViewById(R.id.level3);
                break;
            case 3:
                seekBar = (VerticalSeekBar) rootView.findViewById(R.id.seek_bar4);
                textView = (TextView) rootView.findViewById(R.id.level4);
                break;
            case 4:
                seekBar = (VerticalSeekBar) rootView.findViewById(R.id.seek_bar5);
                textView = (TextView) rootView.findViewById(R.id.level5);
                break;
            }
            seekBarFinal[eqbands] = seekBar;
            seekBar.setId(i);
            if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) {
                textView.setTextColor(Color.WHITE);
                seekBar.setThumb(ContextCompat.getDrawable(getContext(), R.drawable.thumb));
                seekBar.getThumb().setTint(accentcolor);
                seekBar.setProgressTintMode(PorterDuff.Mode.SRC_ATOP);
                seekBar.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
            } else {
                textView.setTextColor(Color.WHITE);
                seekBar.setThumb(ContextCompat.getDrawable(getContext(), R.drawable.thumb));
                seekBar.getThumb().setTint(accentcolor);
                seekBar.setProgressTintMode(PorterDuff.Mode.SRC_ATOP);
                seekBar.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
            }
            if (bandLevel != null) {
                seekBar.setMax(bandLevel[1] - bandLevel[0]);
                int presetPos = Extras.getInstance().getPresetPos();
                if (presetPos < Equalizers.getPresetNo()) {
                    seekBarFinal[eqbands].setProgress(Equalizers.getBandLevel(eqbands) - bandLevel[0]);
                } else {
                    seekBarFinal[i].setProgress(
                            Extras.getInstance().saveEq().getInt(BAND_LEVEL + i, 0) - bandLevel[0]);
                }
            }
            int frequency = Equalizers.getCenterFreq(eqbands);
            if (frequency < 1000 * 1000) {
                textView.setText((frequency / 1000) + "Hz");
            } else {
                textView.setText((frequency / (1000 * 1000)) + "kHz");
            }
            seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {
                    try {
                        if (fromUser) {
                            if (bandLevel != null) {
                                int level = seekbar.getProgress() + bandLevel[0];
                                Equalizers.setBandLevel(eqbands, (short) level);
                                int presetNo = Equalizers.getPresetNo();
                                if (presetNo != 0) {
                                    appCompatSpinner.setSelection(Equalizers.getPresetNo());
                                } else {
                                    appCompatSpinner.setSelection(0);
                                }
                                Equalizers.savePrefs(eqbands, level);
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
        }
    } catch (Exception e) {
        e.printStackTrace();
        Log.d(TAG, "Failed to init eq");
    }
}