Example usage for android.content.res TypedArray getResourceId

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

Introduction

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

Prototype

@AnyRes
public int getResourceId(@StyleableRes int index, int defValue) 

Source Link

Document

Retrieves the resource identifier for the attribute at index.

Usage

From source file:com.edgar.banner.BannerPagerView.java

private void init(AttributeSet attrs, int defStyle) {
    Context context = getContext();
    Resources resource = context.getResources();
    LayoutInflater.from(getContext()).inflate(R.layout.banner_layout, this, true);
    mViewPage = (LoopViewPager) findViewById(R.id.carouse_viewpager);
    setBannerScroller(new BannerScroller(getContext()));
    mViewPage.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mViewPage.setOnPageChangeListener(mCarousePageListener);
    mBannerPageAdapter = new DefaultBannerPageViewAdapter();
    mIndicatorParams.gravity = Gravity.BOTTOM;
    mPointPadding = resource.getDimensionPixelOffset(R.dimen.point_margin);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BannerPagerView, defStyle, 0);
    int N = a.getIndexCount();
    for (int i = 0; i < N; i++) {
        int attr = a.getIndex(i);
        if (attr == R.styleable.BannerPagerView_bannerAnimation) {
            int transformerType = a.getInt(attr, 0);
            setBannerPageTransformer(true, TransformerType.convert(transformerType));
        } else if (attr == R.styleable.BannerPagerView_enableAutoPlayer) {
            setEnableAutoPlay(a.getBoolean(attr, false));
        } else if (attr == R.styleable.BannerPagerView_indicatorStyle) {
            mIndicatorStyle = a.getInt(attr, IndicatorStyle.CIRCLE_INDICATOR);
        } else if (attr == R.styleable.BannerPagerView_indicatorLayout) {
            int resId = a.getResourceId(attr, 0);
            if (resId != 0) {
                View indicatorView = LayoutInflater.from(context).inflate(resId, this, false);
                if (!(indicatorView instanceof BannerIndicator)) {
                    throw new IllegalArgumentException("Your indicator must implements BannerIndicator.");
                }/*w  w w  . j  a v  a  2  s  .  c o  m*/
                mIndicatorView = indicatorView;
                mBannerIndicator = (BannerIndicator) indicatorView;
                addView(mIndicatorView);
            }
        } else if (attr == R.styleable.BannerPagerView_unSelectDrawable) {
            mUnSelectedDrawable = a.getDrawable(attr);
        } else if (attr == R.styleable.BannerPagerView_selectedDrawable) {
            mSelectedDrawable = a.getDrawable(attr);
        } else if (attr == R.styleable.BannerPagerView_indicatorGravity) {
            mIndicatorGravity = a.getInt(attr, Gravity.CENTER);
        } else if (attr == R.styleable.BannerPagerView_pointPadding) {
            mPointPadding = a.getDimensionPixelOffset(attr, mPointPadding);
        } else if (attr == R.styleable.BannerPagerView_indicatorBackground) {
            mIndicatorBackground = a.getDrawable(attr);
        }
    }

    if (mUnSelectedDrawable == null) {
        mUnSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_normal_background);
    }
    if (mSelectedDrawable == null) {
        mSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_selected_background);
    }
    if (mIndicatorBackground == null) {
        mIndicatorBackground = new ColorDrawable(resource.getColor(R.color.indicator_background));
    }
    if (mBannerIndicator == null) {
        setIndicatorStyle(mIndicatorStyle);
    }

    a.recycle();
}

From source file:com.example.testing.myapplication.module.pageSliding.PagerSlidingTabStrip.java

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

    setFillViewport(true);/*from  ww  w . j a  v a  2s  .  c o  m*/
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    tabsContainer.setGravity(Gravity.START);

    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    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);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, 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);

    a.recycle();

    // get custom attrs

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

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    //underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    //dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    //underlineHeight =
    //        a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
    mTabTextColor = a.getColorStateList(R.styleable.PagerSlidingTabStrip_pstsTabTextColor);

    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:android.support.designox.widget.TextInputLayout.java

public TextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10
    super(context, attrs);

    ThemeUtils.checkAppCompatTheme(context);

    setOrientation(VERTICAL);/*w  ww .j  av  a  2s.  com*/
    setWillNotDraw(false);
    setAddStatesFromChildren(true);

    mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
    mCollapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator());
    mCollapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextInputLayout, defStyleAttr,
            R.style.Widget_Design_TextInputLayout);
    mHintEnabled = a.getBoolean(R.styleable.TextInputLayout_hintEnabled, true);
    setHint(a.getText(R.styleable.TextInputLayout_android_hint));
    mHintAnimationEnabled = a.getBoolean(R.styleable.TextInputLayout_hintAnimationEnabled, true);

    if (a.hasValue(R.styleable.TextInputLayout_android_textColorHint)) {
        mDefaultTextColor = mFocusedTextColor = a
                .getColorStateList(R.styleable.TextInputLayout_android_textColorHint);
    }

    final int hintAppearance = a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, -1);
    if (hintAppearance != -1) {
        setHintTextAppearance(a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, 0));
    }

    mErrorTextAppearance = a.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, 0);
    final boolean errorEnabled = a.getBoolean(R.styleable.TextInputLayout_errorEnabled, false);

    final boolean counterEnabled = a.getBoolean(R.styleable.TextInputLayout_counterEnabled, false);
    setCounterMaxLength(a.getInt(R.styleable.TextInputLayout_counterMaxLength, INVALID_MAX_LENGTH));
    mCounterTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterTextAppearance, 0);
    mCounterOverflowTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterOverflowTextAppearance,
            0);
    a.recycle();

    setErrorEnabled(errorEnabled);
    setCounterEnabled(counterEnabled);

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        // Make sure we're important for accessibility if we haven't been explicitly not
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate());
}

From source file:com.googlecode.eyesfree.example.bargraph.BarGraphView.java

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

    // Load styled attributes.
    final int defStyleRes = (isInEditMode() ? 0 : R.style.BarGraph);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BarGraph, defStyle, defStyleRes);

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

        switch (attr) {
        case R.styleable.BarGraph_barMargin:
            mBarMargin = a.getDimension(attr, mBarMargin);
            break;
        case R.styleable.BarGraph_barMinWidth:
            mBarMinHeight = a.getDimension(attr, mBarMinHeight);
            break;
        case R.styleable.BarGraph_barMinHeight:
            mBarMinWidth = a.getDimension(attr, mBarMinWidth);
            break;
        case R.styleable.BarGraph_title:
            setTitle(a.getText(attr));/*  w  ww. j av  a 2s .  co m*/
            break;
        case R.styleable.BarGraph_titleSize:
            mTitleSize = a.getDimension(attr, mTitleSize);
            break;
        case R.styleable.BarGraph_values:
            if (!isInEditMode()) {
                setData(context.getResources().getIntArray(a.getResourceId(attr, 0)));
            }
            break;
        }
    }

    a.recycle();

    if (isInEditMode()) {
        // Special considerations for edit mode.
        mBarGraphAccessHelper = null;
        setData(new int[] { 1, 1, 2, 3, 5, 8 });
        setSelection(3);
    } else {
        // Set up accessibility helper class.
        mBarGraphAccessHelper = new BarGraphAccessHelper(this);
        ViewCompat.setAccessibilityDelegate(this, mBarGraphAccessHelper);
    }
}

From source file:cn.mailchat.view.PagerSlidingTabStrip.java

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

    setFillViewport(true);/*from w  ww.j  a  v  a  2  s  .c  o  m*/
    setWillNotDraw(false);

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

    DisplayMetrics dm = getResources().getDisplayMetrics();

    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);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get custom attrs

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

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
    selectedTabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsSelectedTabTextColor,
            selectedTabTextColor);
    tabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_android_textColor, tabTextColor);
    tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_android_textSize, tabTextSize);

    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:com.appstu.sattafestival.swipe_list.SwipeListView.java

/**
 * Init ListView//from  www  .j a  v a 2s  . c  om
 * 
 * @param attrs
 *            AttributeSet
 */
private 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 swipeDrawableChecked = 0;
    int swipeDrawableUnchecked = 0;

    int swipeActionLeft = SWIPE_ACTION_REVEAL;
    int swipeActionRight = SWIPE_ACTION_REVEAL;

    if (attrs != null) {
        TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView);
        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);
        swipeDrawableChecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableChecked, 0);
        swipeDrawableUnchecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableUnchecked, 0);
        swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0);
        swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0);
        styled.recycle();
    }

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

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

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    touchListener = new SwipeListViewTouchListener(this, swipeFrontView, swipeBackView);
    if (swipeAnimationTime > 0) {
        touchListener.setAnimationTime(swipeAnimationTime);
    }
    touchListener.setRightOffset(swipeOffsetRight);
    touchListener.setLeftOffset(swipeOffsetLeft);
    touchListener.setSwipeActionLeft(swipeActionLeft);
    touchListener.setSwipeActionRight(swipeActionRight);
    touchListener.setSwipeMode(SWIPE_MODE_RIGHT);
    touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList);
    touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress);
    touchListener.setSwipeDrawableChecked(swipeDrawableChecked);
    touchListener.setSwipeDrawableUnchecked(swipeDrawableUnchecked);
    setOnTouchListener(touchListener);
    setOnScrollListener(touchListener.makeScrollListener());
}

From source file:com.roselism.bottomsheet.BottomSheet.java

@SuppressWarnings("WeakerAccess")
BottomSheet(Context context, int theme) {
    super(context, theme);

    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.BottomSheet, R.attr.bottomSheetStyle,
            0);/* w w w.  j  a va 2  s.  co m*/
    mHasContent = builder.hasContent;
    try {
        more = a.getDrawable(R.styleable.BottomSheet_bs_moreDrawable);
        close = a.getDrawable(R.styleable.BottomSheet_bs_closeDrawable);
        moreText = a.getString(R.styleable.BottomSheet_bs_moreText);
        collapseListIcons = a.getBoolean(R.styleable.BottomSheet_bs_collapseListIcons, true);
        mHeaderLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_headerLayout,
                mHasContent ? R.layout.bs_header_center : R.layout.bs_header);

        if (theme == R.style.BottomSheet_DialogHorizontalContent) {
            mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout,
                    mHasContent ? R.layout.bs_list_entry_hor_two : R.layout.bs_list_entry_hor_one);
        } else if (theme == R.style.BottomSheet_Dialog) {
            mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout,
                    R.layout.bs_list_entry_normal);
        } else {
            mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout,
                    R.layout.bs_list_entry_normal);
        }

        mGridItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_gridItemLayout, R.layout.bs_grid_entry);

    } finally {
        a.recycle();
    }

    // https://github.com/jgilfelt/SystemBarTint/blob/master/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        helper = new TranslucentHelper(this, context);
    }
}

From source file:com.roselism.bottomsheet.BottomSheet.java

@SuppressWarnings("WeakerAccess")
BottomSheet(Context context, int theme, Builder builder) {
    super(context, theme);

    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.BottomSheet, R.attr.bottomSheetStyle,
            0);//ww  w  .  j  a  v a2 s. c  o  m
    mHasContent = builder.hasContent;
    try {
        more = a.getDrawable(R.styleable.BottomSheet_bs_moreDrawable);
        close = a.getDrawable(R.styleable.BottomSheet_bs_closeDrawable);
        moreText = a.getString(R.styleable.BottomSheet_bs_moreText);
        collapseListIcons = a.getBoolean(R.styleable.BottomSheet_bs_collapseListIcons, true);
        mHeaderLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_headerLayout,
                mHasContent ? R.layout.bs_header_center : R.layout.bs_header);

        if (theme == R.style.BottomSheet_DialogHorizontalContent) {
            mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout,
                    mHasContent ? R.layout.bs_list_entry_hor_two : R.layout.bs_list_entry_hor_one);
        } else if (theme == R.style.BottomSheet_Dialog) {
            mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout,
                    R.layout.bs_list_entry_normal);
        } else {
            mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout,
                    R.layout.bs_list_entry_normal);
        }

        mGridItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_gridItemLayout, R.layout.bs_grid_entry);

    } finally {
        a.recycle();
    }

    // https://github.com/jgilfelt/SystemBarTint/blob/master/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        helper = new TranslucentHelper(this, context);
    }
}

From source file:br.liveo.navigationliveo.NavigationLiveo.java

private void configureFindView() {
    mList = (ListView) findViewById(R.id.list);
    mList.setOnItemClickListener(new DrawerItemClickListener());

    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);

    mDrawerToggle = new ActionBarDrawerToggleCompat(this, mDrawerLayout, mToolbar);
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    mTitleFooter = (TextView) this.findViewById(R.id.titleFooter);
    mIconFooter = (ImageView) this.findViewById(R.id.iconFooter);

    mTitleSecondFooter = (TextView) this.findViewById(R.id.titleSecondFooter);
    mIconSecondFooter = (ImageView) this.findViewById(R.id.iconSecondFooter);

    mFooterDrawer = (RelativeLayout) this.findViewById(R.id.footerDrawer);
    mFooterSecondDrawer = (RelativeLayout) this.findViewById(R.id.footerSecondDrawer);
    mRelativeDrawer = (ScrimInsetsFrameLayout) this.findViewById(R.id.relativeDrawer);

    this.setSupportActionBar(mToolbar);

    ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }/*w  w  w.ja  v  a2s  .c  o  m*/

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        try {
            if (!mRemoveHeader || !mCustomHeader) {
                Resources.Theme theme = this.getTheme();
                TypedArray typedArray = theme.obtainStyledAttributes(new int[] { android.R.attr.colorPrimary });
                mDrawerLayout.setStatusBarBackground(typedArray.getResourceId(0, 0));
            }
        } catch (Exception e) {
            e.getMessage();
        }

        this.setElevationToolBar(mElevationToolBar);
    }
}

From source file:com.hb.hkm.slidinglayer.SlidLayer.java

/**
 * Constructor for the sliding layer.<br>
 * By default this panel will//from   w ww  .j a  va 2s  .co m
 * <ol>
 * <li>{@link #setStickTo(int)} with param {@link #STICK_TO_RIGHT}</li>
 * <li>Use no shadow drawable. (i.e. with size of 0)</li>
 * <li>Close when the panel is tapped</li>
 * <li>Open when the offset is tapped, but will have an offset of 0</li>
 * </ol>
 *
 * @param context  a reference to an existing context
 * @param attrs    attribute set constructed from attributes set in android .xml file
 * @param defStyle style res id
 */
public SlidLayer(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Style
    final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidLayer);

    // Set the side of the screen
    setStickTo(ta.getInt(R.styleable.SlidLayer_stickTo, STICK_TO_RIGHT));

    // Sets the shadow drawable
    int shadowRes = ta.getResourceId(R.styleable.SlidLayer_shadowDrawable, INVALID_VALUE);
    if (shadowRes != INVALID_VALUE) {
        setShadowDrawable(shadowRes);
    }

    // Sets the shadow size
    mShadowSize = (int) ta.getDimension(R.styleable.SlidLayer_shadowSize, 0);

    // Sets the ability to open or close the layer by tapping in any empty space
    changeStateOnTap = ta.getBoolean(R.styleable.SlidLayer_changeStateOnTap, true);

    // How much of the view sticks out when closed
    mOffsetDistance = ta.getDimensionPixelOffset(R.styleable.SlidLayer_offsetDistance, 0);

    // Sets the size of the preview summary, if any
    mPreviewOffsetDistance = ta.getDimensionPixelOffset(R.styleable.SlidLayer_previewOffsetDistance,
            INVALID_VALUE);

    // If showing offset is greater than preview mode offset dimension, exception is thrown
    checkPreviewModeConsistency();

    ta.recycle();

    init();
}