Example usage for android.util TypedValue TYPE_DIMENSION

List of usage examples for android.util TypedValue TYPE_DIMENSION

Introduction

In this page you can find the example usage for android.util TypedValue TYPE_DIMENSION.

Prototype

int TYPE_DIMENSION

To view the source code for android.util TypedValue TYPE_DIMENSION.

Click Source Link

Document

The data field holds a complex number encoding a dimension value.

Usage

From source file:Main.java

public static boolean isPxVal(TypedValue val) {
    if (val != null && val.type == TypedValue.TYPE_DIMENSION
            && getComplexUnit(val.data) == TypedValue.COMPLEX_UNIT_PX) {
        return true;
    }/*from ww w.  jav a  2  s . c  o  m*/
    return false;
}

From source file:Main.java

private static boolean isPxVal(TypedValue val) {
    if (val != null && val.type == TypedValue.TYPE_DIMENSION
            && getComplexUnit(val.data) == TypedValue.COMPLEX_UNIT_PX) {
        return true;
    }//from  w  ww.java2  s .co  m
    return false;
}

From source file:Main.java

public static float getAttributeDimension(final Context context, final Resources.Theme theme, final int resId) {
    final TypedValue typedValue = new TypedValue(); // create a new typed value to received the resolved attribute
    // value/*from   www  . j  ava  2s  . c  o m*/
    final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
    if (!theme.resolveAttribute(resId, typedValue, true)) // if we can't resolve the value
    {
        throw new Resources.NotFoundException("Resource ID #0x" + Integer.toHexString(resId));
    }
    if (typedValue.type != TypedValue.TYPE_DIMENSION) // if the value isn't of the correct type
    {
        throw new Resources.NotFoundException("Resource ID #0x" + Integer.toHexString(resId) + " type #0x"
                + Integer.toHexString(typedValue.type) + " is not valid");
    }
    return typedValue.getDimension(displayMetrics); // return the value of the attribute in terms of the display
}

From source file:com.actionbarsherlock.internal.widget.FakeDialogPhoneWindow.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int width = getMeasuredWidth();
    boolean measure = false;

    widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY);

    final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor;

    if (tv.type != TypedValue.TYPE_NULL) {
        final int min;
        if (tv.type == TypedValue.TYPE_DIMENSION) {
            min = (int) tv.getDimension(metrics);
        } else if (tv.type == TypedValue.TYPE_FRACTION) {
            min = (int) tv.getFraction(metrics.widthPixels, metrics.widthPixels);
        } else {//from  w  ww .  j av a2 s.c o m
            min = 0;
        }

        if (width < min) {
            widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY);
            measure = true;
        }
    }

    // TODO: Support height?

    if (measure) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}

From source file:com.hippo.conductor.dialog.DialogContentView.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    final boolean isPortrait = getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    final TypedValue tv = isPortrait ? minWidthMinor : minWidthMajor;
    boolean measure = false;

    if (widthMode == MeasureSpec.AT_MOST && tv.type != TypedValue.TYPE_NULL) {
        final int min;
        final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
        if (tv.type == TypedValue.TYPE_DIMENSION) {
            min = (int) tv.getDimension(metrics);
        } else if (tv.type == TypedValue.TYPE_FRACTION) {
            min = (int) tv.getFraction(metrics.widthPixels, metrics.widthPixels);
        } else {//from w  w w  .j av a 2 s  .c o m
            min = 0;
        }

        if (getMeasuredWidth() < min) {
            widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, MeasureSpec.EXACTLY);
            measure = true;
        }
    }

    if (measure) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}

From source file:android.support.v7ox.widget.ContentFrameLayout.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;

    final int widthMode = getMode(widthMeasureSpec);
    final int heightMode = getMode(heightMeasureSpec);

    boolean fixedWidth = false;
    if (widthMode == AT_MOST) {
        final TypedValue tvw = isPortrait ? mFixedWidthMinor : mFixedWidthMajor;
        if (tvw != null && tvw.type != TypedValue.TYPE_NULL) {
            int w = 0;
            if (tvw.type == TypedValue.TYPE_DIMENSION) {
                w = (int) tvw.getDimension(metrics);
            } else if (tvw.type == TypedValue.TYPE_FRACTION) {
                w = (int) tvw.getFraction(metrics.widthPixels, metrics.widthPixels);
            }/*from w w w.j  a v a  2 s.  co  m*/
            if (w > 0) {
                w -= (mDecorPadding.left + mDecorPadding.right);
                final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
                widthMeasureSpec = MeasureSpec.makeMeasureSpec(Math.min(w, widthSize), EXACTLY);
                fixedWidth = true;
            }
        }
    }

    if (heightMode == AT_MOST) {
        final TypedValue tvh = isPortrait ? mFixedHeightMajor : mFixedHeightMinor;
        if (tvh != null && tvh.type != TypedValue.TYPE_NULL) {
            int h = 0;
            if (tvh.type == TypedValue.TYPE_DIMENSION) {
                h = (int) tvh.getDimension(metrics);
            } else if (tvh.type == TypedValue.TYPE_FRACTION) {
                h = (int) tvh.getFraction(metrics.heightPixels, metrics.heightPixels);
            }
            if (h > 0) {
                h -= (mDecorPadding.top + mDecorPadding.bottom);
                final int heightSize = MeasureSpec.getSize(heightMeasureSpec);
                heightMeasureSpec = MeasureSpec.makeMeasureSpec(Math.min(h, heightSize), EXACTLY);
            }
        }
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int width = getMeasuredWidth();
    boolean measure = false;

    widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY);

    if (!fixedWidth && widthMode == AT_MOST) {
        final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor;
        if (tv != null && tv.type != TypedValue.TYPE_NULL) {
            int min = 0;
            if (tv.type == TypedValue.TYPE_DIMENSION) {
                min = (int) tv.getDimension(metrics);
            } else if (tv.type == TypedValue.TYPE_FRACTION) {
                min = (int) tv.getFraction(metrics.widthPixels, metrics.widthPixels);
            }
            if (min > 0) {
                min -= (mDecorPadding.left + mDecorPadding.right);
            }
            if (width < min) {
                widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY);
                measure = true;
            }
        }
    }

    if (measure) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}

From source file:com.acious.android.paginationseekbar.PaginationSeekBar.java

public PaginationSeekBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFocusable(true);/*w  w  w. j a v  a2s  . c  o  m*/
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;
    mTrackHeight = (int) (1 * density);
    mScrubberHeight = (int) (4 * density);
    int thumbSize = (int) (density * ThumbDrawable.DEFAULT_SIZE_DP);

    //Extra pixels for a touch area of 48dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = (touchBounds - thumbSize) / 2;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PaginationSeekBar,
            R.attr.paginationSeekBarStyle, defStyle);

    int max = 100;
    int min = 0;
    int value = 1;
    mMirrorForRtl = a.getBoolean(R.styleable.PaginationSeekBar_psb_mirrorForRtl, mMirrorForRtl);
    mAllowTrackClick = a.getBoolean(R.styleable.PaginationSeekBar_psb_allowTrackClickToDrag, mAllowTrackClick);

    int indexMax = R.styleable.PaginationSeekBar_psb_max;
    int indexMin = R.styleable.PaginationSeekBar_psb_min;
    int indexValue = R.styleable.PaginationSeekBar_psb_value;
    pageCountPerOneBoard = R.styleable.PaginationSeekBar_psb_pageCountPerOneBoard;
    final TypedValue out = new TypedValue();
    //Not sure why, but we wanted to be able to use dimensions here...
    if (a.getValue(indexMax, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            max = a.getDimensionPixelSize(indexMax, max);
        } else {
            max = a.getInteger(indexMax, max);
        }
    }
    if (a.getValue(indexMin, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            min = a.getDimensionPixelSize(indexMin, min);
        } else {
            min = a.getInteger(indexMin, min);
        }
    }
    if (a.getValue(indexValue, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            value = a.getDimensionPixelSize(indexValue, value);
        } else {
            value = a.getInteger(indexValue, value);
        }
    }
    if (a.getValue(pageCountPerOneBoard, out)) {
        pageCountPerOneBoard = a.getInteger(pageCountPerOneBoard, pageCountPerOneBoard);
    }
    mMin = min;
    mMax = Math.max(min + 1, max);
    mValue = Math.max(min, Math.min(max, value));
    updateKeyboardRange();

    mPrevPageText = a.getString(R.styleable.PaginationSeekBar_psb_indicatorPrevPageText);
    mNextPageText = a.getString(R.styleable.PaginationSeekBar_psb_indicatorNextPageText);
    mIndicatorFormatter = a.getString(R.styleable.PaginationSeekBar_psb_indicatorFormatter);

    ColorStateList trackColor = a.getColorStateList(R.styleable.PaginationSeekBar_psb_trackColor);
    ColorStateList progressColor = a.getColorStateList(R.styleable.PaginationSeekBar_psb_progressColor);
    ColorStateList rippleColor = a.getColorStateList(R.styleable.PaginationSeekBar_psb_rippleColor);
    int thumbTextColor = a.getColor(R.styleable.PaginationSeekBar_psb_thumbTextColor, Color.WHITE);
    boolean editMode = isInEditMode();
    if (editMode && rippleColor == null) {
        rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY });
    }
    if (editMode && trackColor == null) {
        trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY });
    }
    if (editMode && progressColor == null) {
        progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { 0xff009688 });
    }
    if (editMode && thumbTextColor == 0) {
        thumbTextColor = Color.WHITE;
    }
    mRipple = SeekBarCompat.getRipple(rippleColor);
    if (isLollipopOrGreater) {
        SeekBarCompat.setBackground(this, mRipple);
    } else {
        mRipple.setCallback(this);
    }

    TrackRectDrawable shapeDrawable = new TrackRectDrawable(trackColor);
    mTrack = shapeDrawable;
    mTrack.setCallback(this);

    shapeDrawable = new TrackRectDrawable(progressColor);
    mScrubber = shapeDrawable;
    mScrubber.setCallback(this);

    ThumbDrawable thumbDrawable = new ThumbDrawable(progressColor, thumbTextColor, thumbSize, mValue);
    mThumb = thumbDrawable;
    mThumb.setCallback(this);
    mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight());

    if (!editMode) {
        mIndicator = new PopupIndicator(context, attrs, defStyle, convertValueToMessage(mMax), mPrevPageText,
                mNextPageText);
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

    initPagecountPerOneboard(pageCountPerOneBoard);

}

From source file:com.hezaijin.advance.widgets.view.progress.DiscreteSeekBar.java

public DiscreteSeekBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFocusable(true);/*  ww w. j a v a2 s  .co  m*/
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;
    mTrackHeight = (int) (1 * density);
    mScrubberHeight = (int) (4 * density);
    int thumbSize = (int) (density * ThumbDrawable.DEFAULT_SIZE_DP);

    //Extra pixels for a touch area of 48dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = (touchBounds - thumbSize) / 2;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscreteSeekBar,
            R.attr.discreteSeekBarStyle, defStyle);

    int max = 100;
    int min = 0;
    int value = 0;
    mMirrorForRtl = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_mirrorForRtl, mMirrorForRtl);
    mAllowTrackClick = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_allowTrackClickToDrag, mAllowTrackClick);

    int indexMax = R.styleable.DiscreteSeekBar_dsb_max;
    int indexMin = R.styleable.DiscreteSeekBar_dsb_min;
    int indexValue = R.styleable.DiscreteSeekBar_dsb_value;
    final TypedValue out = new TypedValue();
    //Not sure why, but we wanted to be able to use dimensions here...
    if (a.getValue(indexMax, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            max = a.getDimensionPixelSize(indexMax, max);
        } else {
            max = a.getInteger(indexMax, max);
        }
    }
    if (a.getValue(indexMin, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            min = a.getDimensionPixelSize(indexMin, min);
        } else {
            min = a.getInteger(indexMin, min);
        }
    }
    if (a.getValue(indexValue, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            value = a.getDimensionPixelSize(indexValue, value);
        } else {
            value = a.getInteger(indexValue, value);
        }
    }

    mMin = min;
    mMax = Math.max(min + 1, max);
    mValue = Math.max(min, Math.min(max, value));
    updateKeyboardRange();

    mIndicatorFormatter = a.getString(R.styleable.DiscreteSeekBar_dsb_indicatorFormatter);

    ColorStateList trackColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_trackColor);
    ColorStateList progressColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_progressColor);
    ColorStateList rippleColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_rippleColor);
    boolean editMode = isInEditMode();
    if (editMode && rippleColor == null) {
        rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY });
    }
    if (editMode && trackColor == null) {
        trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY });
    }
    if (editMode && progressColor == null) {
        progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { 0xff009688 });
    }
    mRipple = SeekBarCompat.getRipple(rippleColor);
    if (isLollipopOrGreater) {
        SeekBarCompat.setBackground(this, mRipple);
    } else {
        mRipple.setCallback(this);
    }

    TrackRectDrawable shapeDrawable = new TrackRectDrawable(trackColor);
    mTrack = shapeDrawable;
    mTrack.setCallback(this);

    shapeDrawable = new TrackRectDrawable(progressColor);
    mScrubber = shapeDrawable;
    mScrubber.setCallback(this);

    ThumbDrawable thumbDrawable = new ThumbDrawable(progressColor, thumbSize);
    mThumb = thumbDrawable;
    mThumb.setCallback(this);
    mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight());

    if (!editMode) {
        mIndicator = new PopupIndicator(context, attrs, defStyle, convertValueToMessage(mMax));
        mIndicator.setValue(convertValueToMessage(mValue));
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

}

From source file:com.doomy.library.DiscreteSeekBar.java

public DiscreteSeekBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFocusable(true);/*  w  w  w  .  j  a  v a 2 s  .c  om*/
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;
    mTrackHeight = (int) (1 * density);
    mScrubberHeight = (int) (4 * density);
    int thumbSize = (int) (density * ThumbDrawable.DEFAULT_SIZE_DP);

    //Extra pixels for a touch area of 48dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = (touchBounds - thumbSize) / 2;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscreteSeekBar,
            R.attr.discreteSeekBarStyle, defStyle);

    int max = 100;
    int min = 0;
    int value = 0;
    mMirrorForRtl = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_mirrorForRtl, mMirrorForRtl);
    mAllowTrackClick = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_allowTrackClickToDrag, mAllowTrackClick);

    int indexMax = R.styleable.DiscreteSeekBar_dsb_max;
    int indexMin = R.styleable.DiscreteSeekBar_dsb_min;
    int indexValue = R.styleable.DiscreteSeekBar_dsb_value;
    final TypedValue out = new TypedValue();
    //Not sure why, but we wanted to be able to use dimensions here...
    if (a.getValue(indexMax, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            max = a.getDimensionPixelSize(indexMax, max);
        } else {
            max = a.getInteger(indexMax, max);
        }
    }
    if (a.getValue(indexMin, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            min = a.getDimensionPixelSize(indexMin, min);
        } else {
            min = a.getInteger(indexMin, min);
        }
    }
    if (a.getValue(indexValue, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            value = a.getDimensionPixelSize(indexValue, value);
        } else {
            value = a.getInteger(indexValue, value);
        }
    }

    mMin = min;
    mMax = Math.max(min + 1, max);
    mValue = Math.max(min, Math.min(max, value));
    updateKeyboardRange();

    mIndicatorFormatter = a.getString(R.styleable.DiscreteSeekBar_dsb_indicatorFormatter);

    ColorStateList trackColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_trackColor);
    ColorStateList progressColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_progressColor);
    ColorStateList rippleColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_rippleColor);
    boolean editMode = isInEditMode();
    if (editMode && rippleColor == null) {
        rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY });
    }
    if (editMode && trackColor == null) {
        trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY });
    }
    if (editMode && progressColor == null) {
        progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { 0xff009688 });
    }
    mRipple = SeekBarCompat.getRipple(rippleColor);
    if (isLollipopOrGreater) {
        SeekBarCompat.setBackground(this, mRipple);
    } else {
        mRipple.setCallback(this);
    }

    TrackRectDrawable shapeDrawable = new TrackRectDrawable(trackColor);
    mTrack = shapeDrawable;
    mTrack.setCallback(this);

    shapeDrawable = new TrackRectDrawable(progressColor);
    mScrubber = shapeDrawable;
    mScrubber.setCallback(this);

    ThumbDrawable thumbDrawable = new ThumbDrawable(progressColor, thumbSize);
    mThumb = thumbDrawable;
    mThumb.setCallback(this);
    mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight());

    if (!editMode) {
        mIndicator = new PopupIndicator(context, attrs, defStyle, convertValueToMessage(mMax));
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

}

From source file:com.github.shareme.gwsdiscreteseekbar.library.DiscreteSeekBar.java

public DiscreteSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setFocusable(true);// ww  w . j  a  va 2 s .  c o m
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;
    mTrackHeight = (int) (1 * density);
    mScrubberHeight = (int) (4 * density);
    int thumbSize = (int) (density * ThumbDrawable.DEFAULT_SIZE_DP);

    //Extra pixels for a touch area of 48dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = (touchBounds - thumbSize) / 2;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscreteSeekBar, defStyleAttr,
            R.style.Widget_DiscreteSeekBar);

    int max = 100;
    int min = 0;
    int value = 0;
    mMirrorForRtl = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_mirrorForRtl, mMirrorForRtl);
    mAllowTrackClick = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_allowTrackClickToDrag, mAllowTrackClick);
    mIndicatorPopupEnabled = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_indicatorPopupEnabled,
            mIndicatorPopupEnabled);
    int indexMax = R.styleable.DiscreteSeekBar_dsb_max;
    int indexMin = R.styleable.DiscreteSeekBar_dsb_min;
    int indexValue = R.styleable.DiscreteSeekBar_dsb_value;
    final TypedValue out = new TypedValue();
    //Not sure why, but we wanted to be able to use dimensions here...
    if (a.getValue(indexMax, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            max = a.getDimensionPixelSize(indexMax, max);
        } else {
            max = a.getInteger(indexMax, max);
        }
    }
    if (a.getValue(indexMin, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            min = a.getDimensionPixelSize(indexMin, min);
        } else {
            min = a.getInteger(indexMin, min);
        }
    }
    if (a.getValue(indexValue, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            value = a.getDimensionPixelSize(indexValue, value);
        } else {
            value = a.getInteger(indexValue, value);
        }
    }

    mMin = min;
    mMax = Math.max(min + 1, max);
    mValue = Math.max(min, Math.min(max, value));
    updateKeyboardRange();

    mIndicatorFormatter = a.getString(R.styleable.DiscreteSeekBar_dsb_indicatorFormatter);

    ColorStateList trackColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_trackColor);
    ColorStateList progressColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_progressColor);
    ColorStateList rippleColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_rippleColor);
    boolean editMode = isInEditMode();
    if (editMode || rippleColor == null) {
        rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY });
    }
    if (editMode || trackColor == null) {
        trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY });
    }
    if (editMode || progressColor == null) {
        progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { DEFAULT_THUMB_COLOR });
    }
    mRipple = SeekBarCompat.getRipple(rippleColor);
    if (isLollipopOrGreater) {
        SeekBarCompat.setBackground(this, mRipple);
    } else {
        mRipple.setCallback(this);
    }

    TrackRectDrawable shapeDrawable = new TrackRectDrawable(trackColor);
    mTrack = shapeDrawable;
    mTrack.setCallback(this);

    shapeDrawable = new TrackRectDrawable(progressColor);
    mScrubber = shapeDrawable;
    mScrubber.setCallback(this);

    mThumb = new ThumbDrawable(progressColor, thumbSize);
    mThumb.setCallback(this);
    mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight());

    if (!editMode) {
        mIndicator = new PopupIndicator(context, attrs, defStyleAttr, convertValueToMessage(mMax));
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

}