Example usage for android.content.res TypedArray getInt

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

Introduction

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

Prototype

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

Source Link

Document

Retrieve the integer value for the attribute at index.

Usage

From source file:com.solutions.myo.ankietapp.ui.breadcrumb.PropertiesHelper.java

static void init(BreadcrumbsView breadcrumbsView, AttributeSet attrs) {
    TypedArray a = breadcrumbsView.getContext().getTheme().obtainStyledAttributes(attrs,
            R.styleable.BreadcrumbsView, 0, 0);

    try {//  ww w .  j  a va  2 s  .co m
        breadcrumbsView.nSteps = a.getInt(R.styleable.BreadcrumbsView_numberOfSteps, 0);
        if (breadcrumbsView.nSteps == 0) {
            throw new IllegalStateException(
                    "You must set a number of steps. Use 'numberOfSteps' attribute to supply a value greater than 1");
        }

        breadcrumbsView.visitedStepBorderDotColor = a
                .getColor(R.styleable.BreadcrumbsView_visitedStepBorderDotColor, ContextCompat
                        .getColor(breadcrumbsView.getContext(), R.color.def_visited_step_border_dot_color));
        breadcrumbsView.visitedStepFillDotColor = a.getColor(
                R.styleable.BreadcrumbsView_visitedStepFillDotColor,
                ContextCompat.getColor(breadcrumbsView.getContext(), R.color.def_visited_step_fill_dot_color));
        breadcrumbsView.nextStepBorderDotColor = a.getColor(R.styleable.BreadcrumbsView_nextStepBorderDotColor,
                ContextCompat.getColor(breadcrumbsView.getContext(), R.color.def_next_step_border_dot_color));
        breadcrumbsView.nextStepFillDotColor = a.getColor(R.styleable.BreadcrumbsView_nextStepFillDotColor,
                ContextCompat.getColor(breadcrumbsView.getContext(), R.color.def_next_step_fill_dot_color));
        breadcrumbsView.visitedStepSeparatorColor = a.getColor(
                R.styleable.BreadcrumbsView_visitedStepSeparatorColor,
                ContextCompat.getColor(breadcrumbsView.getContext(), R.color.def_visited_step_separator_color));
        breadcrumbsView.nextStepSeparatorColor = a.getColor(R.styleable.BreadcrumbsView_nextStepSeparatorColor,
                ContextCompat.getColor(breadcrumbsView.getContext(), R.color.def_next_step_separator_color));
        breadcrumbsView.radius = a.getDimensionPixelSize(R.styleable.BreadcrumbsView_radiusDot,
                breadcrumbsView.getResources().getDimensionPixelSize(R.dimen.def_radius_dot));
        breadcrumbsView.sizeDotBorder = a.getDimensionPixelSize(R.styleable.BreadcrumbsView_sizeDotBorder,
                breadcrumbsView.getResources().getDimensionPixelSize(R.dimen.def_size_dot_border));
        breadcrumbsView.heightSeparator = a.getDimensionPixelSize(R.styleable.BreadcrumbsView_heightSeparator,
                breadcrumbsView.getResources().getDimensionPixelSize(R.dimen.def_height_separator));
    } finally {
        a.recycle();
    }
}

From source file:com.facebook.litho.widget.HorizontalScrollSpec.java

@OnLoadStyle
static void onLoadStyle(ComponentContext c, Output<Boolean> scrollbarEnabled) {

    final TypedArray a = c.obtainStyledAttributes(R.styleable.HorizontalScroll, 0);

    for (int i = 0, size = a.getIndexCount(); i < size; i++) {
        final int attr = a.getIndex(i);

        if (attr == R.styleable.HorizontalScroll_android_scrollbars) {
            scrollbarEnabled.set(a.getInt(attr, 0) != 0);
        }/*from  ww w  .  j a va  2  s  .com*/
    }

    a.recycle();
}

From source file:com.google.cloud.android.dialogflow.ui.BubbleView.java

@SuppressWarnings("WrongConstant")
public BubbleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mTintIncoming = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.incoming));
    mTintOutgoing = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.outgoing));
    final Resources resources = getResources();
    mPaddingVertical = resources.getDimensionPixelSize(R.dimen.bubble_padding_vertical);
    mPaddingHorizontalShort = resources.getDimensionPixelSize(R.dimen.bubble_padding_horizontal_short);
    mPaddingHorizontalLong = resources.getDimensionPixelSize(R.dimen.bubble_padding_horizontal_long);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BubbleView);
    setDirection(a.getInt(R.styleable.BubbleView_direction, DIRECTION_INCOMING));
    a.recycle();/*from   w  w w  . jav a 2  s .  com*/
}

From source file:com.bar.foldinglayout.folding.FoldingPaneLayout.java

private void initView(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FoldingMenu);
    int mFoldNumber = ta.getInt(R.styleable.FoldingMenu_foldNumber, mNumberOfFolds);
    if (mFoldNumber > 0 && mFoldNumber < 7) {
        mNumberOfFolds = mFoldNumber;//www.  j ava 2  s .c o m
    } else {
        mNumberOfFolds = 2;
    }
    ta.recycle();

    foldingNavigationLayout = new BaseFoldingLayout(getContext());
    foldingNavigationLayout.setNumberOfFolds(mNumberOfFolds);
    foldingNavigationLayout.setAnchorFactor(0);

}

From source file:com.google.blockly.android.CategorySelectorFragment.java

@Override
public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(context, attrs, savedInstanceState);
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.BlocklyCategory, 0, 0);

    try {//from   w ww .ja  va 2s  .c  o  m
        mScrollOrientation = a.getInt(R.styleable.BlocklyCategory_scrollOrientation, mScrollOrientation);
        //noinspection ResourceType
        mLabelRotation = a.getInt(R.styleable.BlocklyCategory_labelRotation, mLabelRotation);
    } finally {
        a.recycle();
    }
}

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticImageView.java

private void setTypeArray(TypedArray typedArray) {
    scale = typedArray.getFloat(R.styleable.ElasticImageView_imageview_scale, scale);
    duration = typedArray.getInt(R.styleable.ElasticImageView_imageview_duration, duration);
}

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticFloatingActionButton.java

private void setTypeArray(TypedArray typedArray) {
    scale = typedArray.getFloat(R.styleable.ElasticFloatingActionButton_fabutton_scale, scale);
    duration = typedArray.getInt(R.styleable.ElasticFloatingActionButton_fabutton_duration, duration);
}

From source file:com.pavelsikun.seekbarpreference.SeekBarPreference.java

@Override
protected Object onGetDefaultValue(TypedArray ta, int index) {
    return ta.getInt(index, mDefaultValue);
}

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticLayout.java

private void setTypeArray(TypedArray typedArray) {
    GradientDrawable bgShape = (GradientDrawable) view.getBackground();

    round = typedArray.getInt(R.styleable.ElasticLayout_layout_round, round);
    bgShape.setCornerRadius(round);/*from   w ww  .  j  a v  a 2s . co  m*/

    color = typedArray.getInt(R.styleable.ElasticLayout_layout_backgroundColor, color);
    bgShape.setColor(color);

    scale = typedArray.getFloat(R.styleable.ElasticLayout_layout_scale, scale);

    duration = typedArray.getInt(R.styleable.ElasticLayout_layout_duration, duration);
}

From source file:com.fortysevendeg.android.swipelistview.RefreshSwipeListView.java

/**
 * Init ListView//from ww  w  .  ja  va 2s  .  c  om
 *
 * @param attrs AttributeSet
 */
@Override
protected void init(AttributeSet attrs) {

    int swipeMode = SWIPE_MODE_BOTH;
    boolean swipeOpenOnLongPress = true;
    boolean swipeCloseAllItemsWhenMoveList = true;
    long swipeAnimationTime = 0;
    float swipeOffsetLeft = 0;
    float swipeOffsetRight = 0;

    int swipeActionLeft = SWIPE_ACTION_REVEAL;
    int swipeActionRight = SWIPE_ACTION_REVEAL;

    if (attrs != null) {
        TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView);
        swipeMode = styled.getInt(R.styleable.SwipeListView_swipeMode, SWIPE_MODE_BOTH);
        swipeActionLeft = styled.getInt(R.styleable.SwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL);
        swipeActionRight = styled.getInt(R.styleable.SwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL);
        swipeOffsetLeft = styled.getDimension(R.styleable.SwipeListView_swipeOffsetLeft, 0);
        swipeOffsetRight = styled.getDimension(R.styleable.SwipeListView_swipeOffsetRight, 0);
        swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true);
        swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0);
        swipeCloseAllItemsWhenMoveList = styled
                .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true);
        mSwipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0);
        mSwipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0);
    }

    if (mSwipeFrontView == 0 || mSwipeBackView == 0) {
        mSwipeFrontView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_FRONT_VIEW, "id",
                getContext().getPackageName());
        mSwipeBackView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_BACK_VIEW, "id",
                getContext().getPackageName());

        if (mSwipeFrontView == 0 || mSwipeBackView == 0) {
            throw new RuntimeException(String.format(
                    "You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use '%s' and '%s' identifiers",
                    SWIPE_DEFAULT_FRONT_VIEW, SWIPE_DEFAULT_BACK_VIEW));
        }
    }

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mTouchListener = new SwipeRefreshListViewTouchListener(this, mSwipeFrontView, mSwipeBackView);
    if (swipeAnimationTime > 0) {
        mTouchListener.setAnimationTime(swipeAnimationTime);
    }
    mTouchListener.setRightOffset(swipeOffsetRight);
    mTouchListener.setLeftOffset(swipeOffsetLeft);
    mTouchListener.setSwipeActionLeft(swipeActionLeft);
    mTouchListener.setSwipeActionRight(swipeActionRight);
    mTouchListener.setSwipeMode(swipeMode);
    mTouchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList);
    mTouchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress);
    setOnTouchListener(mTouchListener);
    setOnScrollListener(mTouchListener.makeScrollListener());
}