Example usage for android.content.res TypedArray getInteger

List of usage examples for android.content.res TypedArray getInteger

Introduction

In this page you can find the example usage for android.content.res TypedArray getInteger.

Prototype

public int getInteger(@StyleableRes int index, int defValue) 

Source Link

Document

Retrieve the integer value for the attribute at index.

Usage

From source file:com.origamilabs.library.views2.StaggeredGridView.java

public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (attrs != null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ohsujinStaggeredGridView);
        mColCount = a.getInteger(R.styleable.ohsujinStaggeredGridView_ohsujinNumColumns, 2);
        mDrawSelectorOnTop = a.getBoolean(R.styleable.ohsujinStaggeredGridView_ohsujinDrawSelectorOnTop, false);
        mItemMargin = (int) a.getDimension(R.styleable.ohsujinStaggeredGridView_ohsujinItemMargin, 0);
    } else {/*from w w w  . j a  v  a2  s  .c o m*/
        mColCount = 2;
        mDrawSelectorOnTop = false;
    }

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.from(context);

    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);
    setClipToPadding(false);
    this.setFocusableInTouchMode(false);

    if (mSelector == null) {
        useDefaultSelector();
    }
}

From source file:talex.zsw.baselibrary.widget.NavigationTabBar.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public NavigationTabBar(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTB//from ww w  .j a  v  a  2  s.  c  o m

    // Always draw
    setWillNotDraw(false);
    // More speed!
    setLayerType(LAYER_TYPE_HARDWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
    try {
        setIsScaled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_scaled, false));
        setIsTitled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false));
        setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
        setIsBadgeUseTypeface(
                typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false));
        setTitleMode(typedArray.getInt(R.styleable.NavigationTabBar_ntb_title_mode, ALL_INDEX));
        setBadgePosition(typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_position, RIGHT_INDEX));
        setBadgeGravity(typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_gravity, TOP_INDEX));
        setTypeface(typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_active_color, DEFAULT_ACTIVE_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabBar_ntb_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_corners_radius, 0.0f));

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });

        // Set preview models
        if (isInEditMode()) {
            // Get preview colors
            String[] previewColors = null;
            try {
                final int previewColorsId = typedArray
                        .getResourceId(R.styleable.NavigationTabBar_ntb_preview_colors, 0);
                previewColors = previewColorsId == 0 ? null
                        : typedArray.getResources().getStringArray(previewColorsId);
            } catch (Exception exception) {
                previewColors = null;
                exception.printStackTrace();
            } finally {
                if (previewColors == null) {
                    previewColors = typedArray.getResources().getStringArray(R.array.default_preview);
                }

                for (String previewColor : previewColors) {
                    mModels.add(new Model(null, Color.parseColor(previewColor)));
                }
                requestLayout();
            }
        }
    } finally {
        typedArray.recycle();
    }
}

From source file:com.albedinsky.android.ui.widget.ViewPagerWidget.java

/**
 * Called from one of constructors of this view to perform its initialization.
 * <p>/*  ww  w  .  j av a2 s  . c  om*/
 * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
 * this view specific data from it that can be used to configure this new view instance. The
 * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
 * from the current theme provided by the specified <var>context</var>.
 */
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    this.ensureDecorator();
    mDecorator.processAttributes(context, attrs, defStyleAttr, defStyleRes);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_ViewPager, defStyleAttr,
            defStyleRes);
    if (typedArray != null) {
        final int n = typedArray.getIndexCount();
        for (int i = 0; i < n; i++) {
            final int index = typedArray.getIndex(i);
            if (index == R.styleable.Ui_ViewPager_android_background) {
                int resID = typedArray.getResourceId(index, -1);
                if (resID != -1) {
                    setBackgroundResource(resID);
                } else {
                    setBackgroundColor(typedArray.getColor(0, Color.TRANSPARENT));
                }
            } else if (index == R.styleable.Ui_ViewPager_uiPageMargin) {
                setPageMargin(typedArray.getDimensionPixelSize(index, 0));
            } else if (index == R.styleable.Ui_ViewPager_uiPageMarginDrawable) {
                setPageMarginDrawable(typedArray.getDrawable(index));
            } else if (index == R.styleable.Ui_ViewPager_uiPageSwipingEnabled) {
                mDecorator.updatePrivateFlags(PFLAG_PAGE_SWIPING_ENABLED, typedArray.getBoolean(index, true));
            } else if (index == R.styleable.Ui_ViewPager_uiPageFlingSwipingEnabled) {
                mDecorator.updatePrivateFlags(PFLAG_PAGE_FLING_SWIPING_ENABLED,
                        typedArray.getBoolean(index, false));
            } else if (index == R.styleable.Ui_ViewPager_uiPageFlingSwipingSensitivity) {
                this.mPageFlingSwipingSensitivity = Math.max(0,
                        typedArray.getFloat(index, mPageFlingSwipingSensitivity));
            } else if (index == R.styleable.Ui_ViewPager_uiCurrentPage) {
                this.mCurrentPage = typedArray.getInteger(index, 0);
            } else if (index == R.styleable.Ui_ViewPager_uiOffScreenPageLimit) {
                setOffscreenPageLimit(typedArray.getInt(index, getOffscreenPageLimit()));
            } else if (index == R.styleable.Ui_ViewPager_uiPageScrollDuration) {
                this.mPageScrollDuration = typedArray.getInteger(index, mPageScrollDuration);
            } else if (index == R.styleable.Ui_ViewPager_uiPageScrollRelativeDurationEnabled) {
                mDecorator.updatePrivateFlags(PFLAG_PAGE_SCROLL_RELATIVE_DURATION_ENABLED,
                        typedArray.getBoolean(index, false));
            } else if (index == R.styleable.Ui_ViewPager_uiPullEnabled) {
                setPullEnabled(typedArray.getBoolean(index, false));
            }
        }
        typedArray.recycle();
    }
    // Override default scroller so we can use custom durations for scroll if requested.
    setScroller(new WidgetScroller(context, SCROLLER_INTERPOLATOR));
}

From source file:chan.android.app.bitwise.util.StaggeredGridView.java

public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (attrs != null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.StaggeredGridView);
        mColCount = a.getInteger(R.styleable.StaggeredGridView_numColumns, 2);
        mDrawSelectorOnTop = a.getBoolean(R.styleable.StaggeredGridView_drawSelectorOnTop, false);
    } else {//from  w w  w. ja v a  2 s .c o m
        mColCount = 2;
        mDrawSelectorOnTop = false;
    }

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.from(context);

    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);
    setClipToPadding(false);
    this.setFocusableInTouchMode(false);

    if (mSelector == null) {
        useDefaultSelector();
    }
}

From source file:com.app.afteryou.ui.staggered.StaggeredGridView.java

public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = new Scroller(context);

    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);//from  ww w.ja  v a 2 s.c  o  m
    setClipToPadding(false);

    if (attrs != null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CostomStaggeredGridView);
        mColCountSetting = a.getInteger(R.styleable.CostomStaggeredGridView_columnNumber, 2);
        mDrawSelectorOnTop = a.getBoolean(R.styleable.CostomStaggeredGridView_drawSelectorOnTop, false);
        if (mColCountSetting != -1) {
            mColCount = mColCountSetting;
        }
        mMinColWidth = a.getDimensionPixelSize(R.styleable.CostomStaggeredGridView_minColumnWidth, 0);
        a.recycle();
    }

    this.setFocusableInTouchMode(false);

    if (mSelector == null) {
        useDefaultSelector();
    }

}

From source file:com.example.michaelg.myapplication.Item.discreteseekbar.DiscreteSeekBar.java

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

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;

    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);
    mTrackHeight = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_trackHeight, (int) (1 * density));
    mScrubberHeight = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_scrubberHeight,
            (int) (4 * density));
    int thumbSize = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_thumbSize,
            (int) (density * ThumbDrawable.DEFAULT_SIZE_DP));
    int separation = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_indicatorSeparation,
            (int) (SEPARATION_DP * density));

    //Extra pixels for a minimum touch area of 32dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = Math.max(0, (touchBounds - thumbSize) / 2);

    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), thumbSize,
                thumbSize + mAddedTouchBounds + separation);
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

}

From source file:com.albedinsky.android.support.ui.widget.ViewPagerWidget.java

/**
 * Creates a new instance of ViewPagerWidget within the given <var>context</var>.
 *
 * @param context      Context in which will be this view presented.
 * @param attrs        Set of Xml attributes used to configure the new instance of this view.
 * @param defStyleAttr An attribute which contains a reference to a default style resource for
 *                     this view within a theme of the given context.
 *//*  w w  w  .  j  av  a  2  s. co m*/
public ViewPagerWidget(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs);
    /**
     * Process attributes.
     */
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_Widget_ViewPager,
            defStyleAttr, 0);
    if (typedArray != null) {
        this.ensurePullController();
        mPullController.setUpFromAttrs(context, attrs, defStyleAttr);

        final int n = typedArray.getIndexCount();
        for (int i = 0; i < n; i++) {
            final int index = typedArray.getIndex(i);
            if (index == R.styleable.Ui_Widget_ViewPager_android_background) {
                int resID = typedArray.getResourceId(index, -1);
                if (resID != -1) {
                    setBackgroundResource(resID);
                } else {
                    setBackgroundColor(typedArray.getColor(0, Color.TRANSPARENT));
                }
            } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageMargin) {
                setPageMargin(typedArray.getDimensionPixelSize(index, 0));
            } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageMarginDrawable) {
                setPageMarginDrawable(typedArray.getDrawable(index));
            } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageSwipingEnabled) {
                updatePrivateFlags(PFLAG_PAGE_SWIPING_ENABLED, typedArray.getBoolean(index, true));
            } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageFlingSwipingEnabled) {
                updatePrivateFlags(PFLAG_PAGE_FLING_SWIPING_ENABLED, typedArray.getBoolean(index, false));
            } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageFlingSwipingSensitivity) {
                this.mPageFlingSwipingSensitivity = Math.max(0,
                        typedArray.getFloat(index, mPageFlingSwipingSensitivity));
            } else if (index == R.styleable.Ui_Widget_ViewPager_uiCurrentPage) {
                this.mCurrentPage = typedArray.getInteger(index, 0);
            } else if (index == R.styleable.Ui_Widget_ViewPager_uiOffScreenPageLimit) {
                setOffscreenPageLimit(typedArray.getInt(index, getOffscreenPageLimit()));
            } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageScrollDuration) {
                this.mPageScrollDuration = typedArray.getInteger(index, mPageScrollDuration);
            } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageScrollRelativeDurationEnabled) {
                updatePrivateFlags(PFLAG_PAGE_SCROLL_RELATIVE_DURATION_ENABLED,
                        typedArray.getBoolean(index, false));
            } else if (index == R.styleable.Ui_Widget_ViewPager_uiPullEnabled) {
                setPullEnabled(typedArray.getBoolean(index, false));
            }
        }
    }

    // Override default scroller so we can use custom durations for scroll if requested.
    this.mScroller = new WidgetScroller(context, SCROLLER_INTERPOLATOR);
}

From source file:com.astuetz.PagerSlidingTabStripPlus.java

public PagerSlidingTabStripPlus(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true); // ScrollView stretch his content height to fill his viewport
    setWillNotDraw(false);//from  w  ww.  j  a v a  2  s  . c  o m

    // Layout parameters
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    // Converting values to floating point value
    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPaddingLeft = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPaddingLeft, dm);
    tabPaddingRight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPaddingRight, dm);
    tabPaddingTop = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPaddingTop, dm);
    tabPaddingBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPaddingBottom, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStripPlus);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStripPlus_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStripPlus_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStripPlus_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsDividerPadding,
            dividerPadding);
    tabPaddingLeft = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsTabPaddingLeft,
            tabPaddingLeft);
    tabPaddingRight = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStripPlus_pstsTabPaddingRight,
            tabPaddingRight);
    tabPaddingTop = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStripPlus_pstsTabPaddingTop,
            tabPaddingTop);
    tabPaddingBottom = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStripPlus_pstsTabPaddingBottom,
            tabPaddingBottom);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStripPlus_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStripPlus_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStripPlus_pstsTextAllCaps, textAllCaps);
    textColorTab = a.getColorStateList(R.styleable.PagerSlidingTabStripPlus_pstsTextColorTab);
    indicatorAlpha = a.getInteger(R.styleable.PagerSlidingTabStripPlus_pstsIndicatorAlpha, indicatorAlpha);
    hasDivider = a.getBoolean(R.styleable.PagerSlidingTabStripPlus_pstsHasDivider, hasDivider);
    tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsTabTextSize, tabTextSize);
    tabsGravity = a.getInteger(R.styleable.PagerSlidingTabStripPlus_pstsTabsTitleGravity, tabsGravity);
    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }

}

From source file:mrfu.blurstaggered.lib.view.StaggeredGridView.java

public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (attrs != null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.StaggeredGridView);
        mColCount = a.getInteger(R.styleable.StaggeredGridView_numColumns, 2);
        mDrawSelectorOnTop = a.getBoolean(R.styleable.StaggeredGridView_drawSelectorOnTop1, false);
    } else {//from   w w  w.j a v a2s.  c  om
        mColCount = 2;
        mDrawSelectorOnTop = false;
    }

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.from(context);

    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);
    setClipToPadding(false);
    this.setFocusableInTouchMode(false);

    if (mSelector == null) {
        useDefaultSelector();
    }
}

From source file:com.bolaa.medical.view.pulltorefreshgrid.StaggeredGridView.java

public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (attrs != null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.StaggeredGridView);
        mColCount = a.getInteger(R.styleable.StaggeredGridView_numColumnsStag, 2);
        mDrawSelectorOnTop = a.getBoolean(R.styleable.StaggeredGridView_drawSelectorOnTopStag, false);
    } else {/*from ww  w .  j  ava2  s . c  om*/
        mColCount = 2;
        mDrawSelectorOnTop = false;
    }

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.from(context);

    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);
    setClipToPadding(false);
    this.setFocusableInTouchMode(false);

    if (mSelector == null) {
        useDefaultSelector();
    }
}