Esempio n. 1
0
  private void initSeekBar(AttributeSet attrs, int defStyleAttr) {
    if (isInEditMode()) return;

    colorControl = Carbon.getThemeColor(getContext(), R.attr.colorControlNormal);

    thumbRadius = thumbRadius2 = THUMB_RADIUS = Carbon.getDip(getContext()) * 8;
    THUMB_RADIUS_DRAGGED = Carbon.getDip(getContext()) * 10;
    STROKE_WIDTH = Carbon.getDip(getContext()) * 2;

    if (attrs != null) {
      Carbon.initAnimations(this, attrs, defStyleAttr);
      Carbon.initTint(this, attrs, defStyleAttr);
      Carbon.initRippleDrawable(this, attrs, defStyleAttr);

      TypedArray a =
          getContext().obtainStyledAttributes(attrs, R.styleable.SeekBar, defStyleAttr, 0);

      setStyle(Style.values()[a.getInt(R.styleable.SeekBar_carbon_barStyle, 0)]);
      setMin(a.getFloat(R.styleable.SeekBar_carbon_min, 0));
      setMax(a.getFloat(R.styleable.SeekBar_carbon_max, 0));
      setStepSize(a.getFloat(R.styleable.SeekBar_carbon_stepSize, 0));
      setValue(a.getFloat(R.styleable.SeekBar_carbon_value, 0));
      setValue2(a.getFloat(R.styleable.SeekBar_carbon_value2, 0));

      a.recycle();
    }

    setFocusableInTouchMode(false); // TODO: from theme
  }
Esempio n. 2
0
 protected void onDrawVerticalScrollBar(
     Canvas canvas, Drawable scrollBar, int l, int t, int r, int b) {
   if (scrollBarDrawable == null) {
     Class<? extends Drawable> scrollBarClass = scrollBar.getClass();
     try {
       Field mVerticalThumbField = scrollBarClass.getDeclaredField("mVerticalThumb");
       mVerticalThumbField.setAccessible(true);
       scrollBarDrawable =
           new RectDrawable(Carbon.getThemeColor(getContext(), R.attr.colorPrimary));
       mVerticalThumbField.set(scrollBar, scrollBarDrawable);
     } catch (NoSuchFieldException e) {
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       e.printStackTrace();
     }
   }
   scrollBar.setBounds(l, t, r, b);
   scrollBar.draw(canvas);
 }