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

The following examples show how to use android.widget.SeekBar#setThumb() . 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: StatusBarVolumePanel.java    From Noyze with Apache License 2.0 6 votes vote down vote up
protected void toggleSeekBar(final boolean shouldSeek) {
    // If we've got a SeekBar, handle seeking!
    if (seekBar instanceof SeekBar) {
        SeekBar seeker = (SeekBar) seekBar;
        seeker.setOnSeekBarChangeListener((shouldSeek) ? this : null);
        seeker.setOnTouchListener((shouldSeek) ? null : noTouchListener);
        Drawable thumb = null;
        if (shouldSeek) {
            thumb = getResources().getDrawable(R.drawable.scrubber_control_selector_mini);
            thumb.mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            thumb.setBounds(0, 0, thumb.getIntrinsicWidth(), thumb.getIntrinsicHeight());
        }
        seeker.setThumb(thumb);
        // NOTE: there's so weird issue with setting the thumb dynamically.
        // This seems to do the trick (fingers crossed).
        Utils.tap((View) seeker.getParent());
        seeker.invalidate();
    }
}
 
Example 2
Source File: Easel.java    From andela-crypto-app with Apache License 2.0 6 votes vote down vote up
/**
 * Tint the {@link SeekBar}
 *
 * @param seekBar the seekbar
 * @param color   the color
 */
public static void tint(@NonNull SeekBar seekBar, @ColorInt int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
Example 3
Source File: MDTintHelper.java    From NewsMe with Apache License 2.0 6 votes vote down vote up
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
Example 4
Source File: MDTintHelper.java    From talk-android with MIT License 6 votes vote down vote up
@SuppressLint("NewApi")
public static void setTint(SeekBar seekBar, int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
Example 5
Source File: UberVolumePanel.java    From Noyze with Apache License 2.0 6 votes vote down vote up
protected void toggleSeekBar(final boolean shouldSeek) {
    // If we've got a SeekBar, handle seeking!
    if (seekBar instanceof SeekBar) {
        SeekBar seeker = (SeekBar) seekBar;
        seeker.setOnSeekBarChangeListener((shouldSeek) ? this : null);
        seeker.setOnTouchListener((shouldSeek) ? null : noTouchListener);
        Drawable thumb = null;
        if (shouldSeek) {
            thumb = getResources().getDrawable(R.drawable.scrubber_control_selector_mini);
            thumb.mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            thumb.setBounds(0,0, thumb.getIntrinsicWidth(), thumb.getIntrinsicHeight());
        }
        seeker.setThumb(thumb);
        // NOTE: there's so weird issue with setting the thumb dynamically.
        // This seems to do the trick (fingers crossed).
        Utils.tap((View) seeker.getParent());
        seeker.invalidate();
    }
}
 
Example 6
Source File: EmTintUtils.java    From AndroidTint with Apache License 2.0 6 votes vote down vote up
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
Example 7
Source File: TodayWidgetConfigureActivity.java    From ETSMobile-Android2 with Apache License 2.0 6 votes vote down vote up
private void setUpOpacitySeekBar() {
    int mOpacitySeekBarColor = ContextCompat.getColor(this, R.color.ets_red_fonce);
    mOpacitySeekBar = (SeekBar) findViewById(R.id.opacity_seekbar);

    mOpacitySeekBar.setProgress(loadOpacityDefaultPref());

    mOpacitySeekBar.setOnSeekBarChangeListener(mOpacityListener);

    mOpacitySeekBar.getProgressDrawable().setColorFilter(mOpacitySeekBarColor,
            PorterDuff.Mode.SRC_IN);

    if (android.os.Build.VERSION.SDK_INT < 16) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setShape(GradientDrawable.OVAL);
        gradientDrawable.setSize(50, 50);
        gradientDrawable.setColor(mOpacitySeekBarColor);
        mOpacitySeekBar.setThumb(gradientDrawable);
    } else {
        mOpacitySeekBar.getThumb().setColorFilter(mOpacitySeekBarColor, PorterDuff.Mode.SRC_IN);
    }
}
 
Example 8
Source File: HeadsUpVolumePanel.java    From Noyze with Apache License 2.0 6 votes vote down vote up
protected void toggleSeekBar(final boolean shouldSeek) {
    // If we've got a SeekBar, handle seeking!
    if (seekBar instanceof SeekBar) {
        SeekBar seeker = (SeekBar) seekBar;
        seeker.setOnSeekBarChangeListener((shouldSeek) ? this : null);
        seeker.setOnTouchListener((shouldSeek) ? null : noTouchListener);
        Drawable thumb = null;
        if (shouldSeek) {
            thumb = getResources().getDrawable(R.drawable.scrubber_control_selector_mini);
            thumb.mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            thumb.setBounds(0,0, thumb.getIntrinsicWidth(), thumb.getIntrinsicHeight());
        }
        seeker.setThumb(thumb);
        // NOTE: there's so weird issue with setting the thumb dynamically.
        // This seems to do the trick (fingers crossed).
        Utils.tap((View) seeker.getParent());
        seeker.invalidate();
    }
}
 
Example 9
Source File: UberVolumePanel.java    From Noyze with Apache License 2.0 6 votes vote down vote up
protected void toggleSeekBar(final boolean shouldSeek) {
    // If we've got a SeekBar, handle seeking!
    if (seekBar instanceof SeekBar) {
        SeekBar seeker = (SeekBar) seekBar;
        seeker.setOnSeekBarChangeListener((shouldSeek) ? this : null);
        seeker.setOnTouchListener((shouldSeek) ? null : noTouchListener);
        Drawable thumb = null;
        if (shouldSeek) {
            thumb = getResources().getDrawable(R.drawable.scrubber_control_selector_mini);
            thumb.mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            thumb.setBounds(0,0, thumb.getIntrinsicWidth(), thumb.getIntrinsicHeight());
        }
        seeker.setThumb(thumb);
        // NOTE: there's so weird issue with setting the thumb dynamically.
        // This seems to do the trick (fingers crossed).
        Utils.tap((View) seeker.getParent());
        seeker.invalidate();
    }
}
 
Example 10
Source File: StatusBarVolumePanel.java    From Noyze with Apache License 2.0 6 votes vote down vote up
protected void toggleSeekBar(final boolean shouldSeek) {
    // If we've got a SeekBar, handle seeking!
    if (seekBar instanceof SeekBar) {
        SeekBar seeker = (SeekBar) seekBar;
        seeker.setOnSeekBarChangeListener((shouldSeek) ? this : null);
        seeker.setOnTouchListener((shouldSeek) ? null : noTouchListener);
        Drawable thumb = null;
        if (shouldSeek) {
            thumb = getResources().getDrawable(R.drawable.scrubber_control_selector_mini);
            thumb.mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            thumb.setBounds(0, 0, thumb.getIntrinsicWidth(), thumb.getIntrinsicHeight());
        }
        seeker.setThumb(thumb);
        // NOTE: there's so weird issue with setting the thumb dynamically.
        // This seems to do the trick (fingers crossed).
        Utils.tap((View) seeker.getParent());
        seeker.invalidate();
    }
}
 
Example 11
Source File: HeadsUpVolumePanel.java    From Noyze with Apache License 2.0 6 votes vote down vote up
protected void toggleSeekBar(final boolean shouldSeek) {
    // If we've got a SeekBar, handle seeking!
    if (seekBar instanceof SeekBar) {
        SeekBar seeker = (SeekBar) seekBar;
        seeker.setOnSeekBarChangeListener((shouldSeek) ? this : null);
        seeker.setOnTouchListener((shouldSeek) ? null : noTouchListener);
        Drawable thumb = null;
        if (shouldSeek) {
            thumb = getResources().getDrawable(R.drawable.scrubber_control_selector_mini);
            thumb.mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            thumb.setBounds(0,0, thumb.getIntrinsicWidth(), thumb.getIntrinsicHeight());
        }
        seeker.setThumb(thumb);
        // NOTE: there's so weird issue with setting the thumb dynamically.
        // This seems to do the trick (fingers crossed).
        Utils.tap((View) seeker.getParent());
        seeker.invalidate();
    }
}
 
Example 12
Source File: PasswordGenerator.java    From Passbook with Apache License 2.0 6 votes vote down vote up
private void tintSeekBar(SeekBar sb) {
    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        if( getContext() == null) {
            return;
        }
        LayerDrawable progress = (LayerDrawable)ContextCompat.getDrawable(getContext(),
                R.drawable.progress);
        if (progress == null) {
            return;
        }
        progress.getDrawable(0).setColorFilter(C.ThemedColors[C.colorIconNormal],
                PorterDuff.Mode.SRC_ATOP);
        progress.getDrawable(1).setColorFilter(C.ThemedColors[C.colorAccent],
                PorterDuff.Mode.SRC_ATOP);
        sb.setProgressDrawable(progress);

        Drawable thumb = ContextCompat.getDrawable(getContext(), R.drawable.thumb);
        if (thumb == null) {
            return;
        }
        thumb.setColorFilter(C.ThemedColors[C.colorAccent], PorterDuff.Mode.SRC_ATOP);
        sb.setThumb(thumb);
    }
}
 
Example 13
Source File: ParanoidVolumePanel.java    From Noyze with Apache License 2.0 5 votes vote down vote up
protected void setProgressColor(SeekBar seekbar, final int tcolor) {
    Drawable thumb = null;
    LOGI(TAG, "setProgressColor(" + color + ")");
    LayerDrawable layer = (LayerDrawable) seekbar.getProgressDrawable();
    layer.findDrawableByLayerId(android.R.id.progress).mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
    thumb = getResources().getDrawable(R.drawable.scrubber_control_selector_white);
    thumb.mutate().setColorFilter(tcolor, PorterDuff.Mode.MULTIPLY);
    thumb.setBounds(0, 0, thumb.getIntrinsicWidth(), thumb.getIntrinsicHeight());
    seekbar.setThumb(thumb);
    // NOTE: The call to Utils.tap was removed because it causes an update
    // to the volume progress and creates strange behaviour.
    seekbar.invalidate();
}
 
Example 14
Source File: ParanoidVolumePanel.java    From Noyze with Apache License 2.0 5 votes vote down vote up
protected void setProgressColor(SeekBar seekbar, final int tcolor) {
    Drawable thumb = null;
    LOGI(TAG, "setProgressColor(" + color + ")");
    LayerDrawable layer = (LayerDrawable) seekbar.getProgressDrawable();
    layer.findDrawableByLayerId(android.R.id.progress).mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
    thumb = getResources().getDrawable(R.drawable.scrubber_control_selector_white);
    thumb.mutate().setColorFilter(tcolor, PorterDuff.Mode.MULTIPLY);
    thumb.setBounds(0, 0, thumb.getIntrinsicWidth(), thumb.getIntrinsicHeight());
    seekbar.setThumb(thumb);
    // NOTE: The call to Utils.tap was removed because it causes an update
    // to the volume progress and creates strange behaviour.
    seekbar.invalidate();
}
 
Example 15
Source File: CommentActivity.java    From NoiseCapture with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
    if(!userInputSeekBar.getAndSet(true)) {
        seekBar.setThumb(seekBar.getResources().getDrawable(
                R.drawable.seekguess_scrubber_control_normal_holo));
    }
}
 
Example 16
Source File: TintHelper.java    From a with GNU General Public License v3.0 5 votes vote down vote up
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color, boolean useDarker) {
    final ColorStateList s1 = getDisabledColorStateList(color,
            ContextCompat.getColor(seekBar.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else {
        Drawable progressDrawable = createTintedDrawable(seekBar.getProgressDrawable(), s1);
        seekBar.setProgressDrawable(progressDrawable);
        Drawable thumbDrawable = createTintedDrawable(seekBar.getThumb(), s1);
        seekBar.setThumb(thumbDrawable);
    }
}
 
Example 17
Source File: TintHelper.java    From APlayer with GNU General Public License v3.0 5 votes vote down vote up
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color, boolean useDarker) {
  final ColorStateList s1 = getDisabledColorStateList(color,
      ContextCompat.getColor(seekBar.getContext(),
          useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    seekBar.setThumbTintList(s1);
    seekBar.setProgressTintList(s1);
  } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
    Drawable progressDrawable = createTintedDrawable(seekBar.getProgressDrawable(), s1);
    seekBar.setProgressDrawable(progressDrawable);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      Drawable thumbDrawable = createTintedDrawable(seekBar.getThumb(), s1);
      seekBar.setThumb(thumbDrawable);
    }
  } else {
    PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
      mode = PorterDuff.Mode.MULTIPLY;
    }
    if (seekBar.getIndeterminateDrawable() != null) {
      seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
    }
    if (seekBar.getProgressDrawable() != null) {
      seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
  }
}
 
Example 18
Source File: TintHelper.java    From MyBookshelf with GNU General Public License v3.0 5 votes vote down vote up
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color, boolean useDarker) {
    final ColorStateList s1 = getDisabledColorStateList(color,
            ContextCompat.getColor(seekBar.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else {
        Drawable progressDrawable = createTintedDrawable(seekBar.getProgressDrawable(), s1);
        seekBar.setProgressDrawable(progressDrawable);
        Drawable thumbDrawable = createTintedDrawable(seekBar.getThumb(), s1);
        seekBar.setThumb(thumbDrawable);
    }
}