Пример #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
  }
Пример #2
0
  private void initHorizontalScrollView(AttributeSet attrs, int defStyleAttr) {
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    TypedArray a =
        getContext()
            .obtainStyledAttributes(attrs, R.styleable.HorizontalScrollView, defStyleAttr, 0);
    for (int i = 0; i < a.getIndexCount(); i++) {
      int attr = a.getIndex(i);
      if (attr == R.styleable.HorizontalScrollView_carbon_overScroll) {
        setOverScrollMode(a.getInt(attr, OVER_SCROLL_ALWAYS));
      }
    }
    a.recycle();

    Carbon.initTint(this, attrs, defStyleAttr);
  }
Пример #3
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);
 }
Пример #4
0
  public ViewPager(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs);
    super.setOnPageChangeListener(internalOnPageChangeListener);

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    TypedArray a =
        getContext().obtainStyledAttributes(attrs, R.styleable.ViewPager, defStyleAttr, 0);
    for (int i = 0; i < a.getIndexCount(); i++) {
      int attr = a.getIndex(i);
      if (attr == R.styleable.ViewPager_carbon_overScroll) {
        setOverScrollMode(a.getInt(attr, OVER_SCROLL_ALWAYS));
      }
    }
    a.recycle();

    Carbon.initTint(this, attrs, defStyleAttr);
  }