Example usage for android.content.res TypedArray hasValue

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

Introduction

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

Prototype

public boolean hasValue(@StyleableRes int index) 

Source Link

Document

Determines whether there is an attribute at index.

Usage

From source file:android.support.design.widget.AppBarLayout.java

public AppBarLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    setOrientation(VERTICAL);/*from  ww w .j av a  2s. c om*/

    ThemeUtils.checkAppCompatTheme(context);

    if (Build.VERSION.SDK_INT >= 21) {
        // Use the bounds view outline provider so that we cast a shadow, even without a
        // background
        ViewUtilsLollipop.setBoundsViewOutlineProvider(this);

        // If we're running on API 21+, we should reset any state list animator from our
        // default style
        ViewUtilsLollipop.setStateListAnimatorFromAttrs(this, attrs, 0, R.style.Widget_Design_AppBarLayout);
    }

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppBarLayout, 0,
            R.style.Widget_Design_AppBarLayout);
    ViewCompat.setBackground(this, a.getDrawable(R.styleable.AppBarLayout_android_background));
    if (a.hasValue(R.styleable.AppBarLayout_expanded)) {
        setExpanded(a.getBoolean(R.styleable.AppBarLayout_expanded, false), false, false);
    }
    if (Build.VERSION.SDK_INT >= 21 && a.hasValue(R.styleable.AppBarLayout_elevation)) {
        ViewUtilsLollipop.setDefaultAppBarLayoutStateListAnimator(this,
                a.getDimensionPixelSize(R.styleable.AppBarLayout_elevation, 0));
    }
    a.recycle();

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            return onWindowInsetChanged(insets);
        }
    });
}

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

/**
 * Called from the constructor to process tint values for this view.
 *
 * @param context    The context passed to constructor.
 * @param typedArray TypedArray obtained for styleable attributes specific for this view.
 *//*from   w ww .  j  a v  a2s .co m*/
@SuppressWarnings("All")
private void processTintValues(Context context, TypedArray typedArray) {
    this.ensureTintInfo();

    // Get tint colors.
    if (typedArray.hasValue(R.styleable.Ui_Widget_ProgressBar_uiProgressTint)) {
        mTintInfo.progressTintList = typedArray
                .getColorStateList(R.styleable.Ui_Widget_ProgressBar_uiProgressTint);
    }
    if (typedArray.hasValue(R.styleable.Ui_Widget_ProgressBar_uiIndeterminateTint)) {
        mTintInfo.indeterminateTintList = typedArray
                .getColorStateList(R.styleable.Ui_Widget_ProgressBar_uiIndeterminateTint);
    }
    if (typedArray.hasValue(R.styleable.Ui_Widget_ProgressBar_uiProgressBackgroundTint)) {
        mTintInfo.backgroundTintList = typedArray
                .getColorStateList(R.styleable.Ui_Widget_ProgressBar_uiProgressBackgroundTint);
    }

    // Get tint modes.
    mTintInfo.progressTintMode = TintManager.parseTintMode(
            typedArray.getInt(R.styleable.Ui_Widget_ProgressBar_uiProgressTintMode, 0), PorterDuff.Mode.SRC_IN);
    mTintInfo.indeterminateTintMode = TintManager.parseTintMode(
            typedArray.getInt(R.styleable.Ui_Widget_ProgressBar_uiIndeterminateTintMode, 0),
            PorterDuff.Mode.SRC_IN);
    mTintInfo.backgroundTintMode = TintManager.parseTintMode(
            typedArray.getInt(R.styleable.Ui_Widget_ProgressBar_uiProgressBackgroundTintMode, 0),
            PorterDuff.Mode.SRC_IN);

    // If there is no tint mode specified within style/xml do not tint at all.
    if (mTintInfo.backgroundTintMode == null) {
        mTintInfo.backgroundTintList = null;
    }
    if (mTintInfo.progressTintMode == null) {
        mTintInfo.progressTintList = null;
    }
    if (mTintInfo.indeterminateTintMode == null) {
        mTintInfo.indeterminateTintList = null;
    }

    mTintInfo.hasBackgroundTintList = mTintInfo.backgroundTintList != null;
    mTintInfo.hasBackgroundTinMode = mTintInfo.backgroundTintMode != null;
    mTintInfo.hasProgressTintList = mTintInfo.progressTintList != null;
    mTintInfo.hasProgressTintMode = mTintInfo.progressTintMode != null;
    mTintInfo.hasIndeterminateTintList = mTintInfo.indeterminateTintList != null;
    mTintInfo.hasIndeterminateTintMode = mTintInfo.indeterminateTintMode != null;
}

From source file:com.mome.main.business.widget.pulltorefresh.PullToRefreshBase.java

@SuppressWarnings("deprecation")
private void init(Context context, AttributeSet attrs) {
    switch (getPullToRefreshScrollDirection()) {
    case HORIZONTAL:
        setOrientation(LinearLayout.HORIZONTAL);
        break;//  w w  w. j a v a  2 s.c  om
    case VERTICAL:
    default:
        setOrientation(LinearLayout.VERTICAL);
        break;
    }

    setGravity(Gravity.CENTER);

    ViewConfiguration config = ViewConfiguration.get(context);
    mTouchSlop = config.getScaledTouchSlop();

    // Styleables from XML
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PullToRefresh);

    if (a.hasValue(R.styleable.PullToRefresh_ptrMode)) {
        mMode = Mode.mapIntToValue(a.getInteger(R.styleable.PullToRefresh_ptrMode, 0));
    }

    if (a.hasValue(R.styleable.PullToRefresh_ptrAnimationStyle)) {
        mLoadingAnimationStyle = AnimationStyle
                .mapIntToValue(a.getInteger(R.styleable.PullToRefresh_ptrAnimationStyle, 0));
    }

    // Refreshable View
    // By passing the attrs, we can add ListView/GridView params via XML
    mRefreshableView = createRefreshableView(context, attrs);
    addRefreshableView(context, mRefreshableView);

    // We need to create now layouts now
    mHeaderLayout = createLoadingLayout(context, Mode.PULL_FROM_START, a);
    mFooterLayout = createLoadingLayout(context, Mode.PULL_FROM_END, a);

    /**
     * Styleables from XML
     */
    if (a.hasValue(R.styleable.PullToRefresh_ptrRefreshableViewBackground)) {
        Drawable background = a.getDrawable(R.styleable.PullToRefresh_ptrRefreshableViewBackground);
        if (null != background) {
            mRefreshableView.setBackgroundDrawable(background);
        }
    } else if (a.hasValue(R.styleable.PullToRefresh_ptrAdapterViewBackground)) {
        Utils.warnDeprecation("ptrAdapterViewBackground", "ptrRefreshableViewBackground");
        Drawable background = a.getDrawable(R.styleable.PullToRefresh_ptrAdapterViewBackground);
        if (null != background) {
            mRefreshableView.setBackgroundDrawable(background);
        }
    }

    if (a.hasValue(R.styleable.PullToRefresh_ptrOverScroll)) {
        mOverScrollEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrOverScroll, true);
    }

    if (a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) {
        mScrollingWhileRefreshingEnabled = a
                .getBoolean(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled, false);
    }

    // Let the derivative classes have a go at handling attributes, then
    // recycle them...
    handleStyledAttributes(a);
    a.recycle();

    // Finally update the UI for the modes
    updateUIForMode();
}

From source file:com.nshmura.recyclertablayout.RecyclerTabLayout.java

public RecyclerTabLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setWillNotDraw(false);//from   w ww .j a v  a 2 s .c o m

    mIndicatorPaint = new Paint();
    mLinearLayoutManager = new LinearLayoutManager(getContext());
    mLinearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    setLayoutManager(mLinearLayoutManager);
    setItemAnimator(null);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.rtl_RecyclerTabLayout, defStyle,
            R.style.rtl_RecyclerTabLayout);
    setIndicatorColor(a.getColor(R.styleable.rtl_RecyclerTabLayout_rtl_tabIndicatorColor, 0));
    setIndicatorHeight(a.getDimensionPixelSize(R.styleable.rtl_RecyclerTabLayout_rtl_tabIndicatorHeight, 0));

    mTabTextAppearance = a.getResourceId(R.styleable.rtl_RecyclerTabLayout_rtl_tabTextAppearance,
            R.style.rtl_RecyclerTabLayout_Tab);

    mTabPaddingStart = mTabPaddingTop = mTabPaddingEnd = mTabPaddingBottom = a
            .getDimensionPixelSize(R.styleable.rtl_RecyclerTabLayout_rtl_tabPadding, 0);
    mTabPaddingStart = a.getDimensionPixelSize(R.styleable.rtl_RecyclerTabLayout_rtl_tabPaddingStart,
            mTabPaddingStart);
    mTabPaddingTop = a.getDimensionPixelSize(R.styleable.rtl_RecyclerTabLayout_rtl_tabPaddingTop,
            mTabPaddingTop);
    mTabPaddingEnd = a.getDimensionPixelSize(R.styleable.rtl_RecyclerTabLayout_rtl_tabPaddingEnd,
            mTabPaddingEnd);
    mTabPaddingBottom = a.getDimensionPixelSize(R.styleable.rtl_RecyclerTabLayout_rtl_tabPaddingBottom,
            mTabPaddingBottom);

    if (a.hasValue(R.styleable.rtl_RecyclerTabLayout_rtl_tabSelectedTextColor)) {
        mTabSelectedTextColor = a.getColor(R.styleable.rtl_RecyclerTabLayout_rtl_tabSelectedTextColor, 0);
        mTabSelectedTextColorSet = true;
    }

    mTabMinWidth = a.getDimensionPixelSize(R.styleable.rtl_RecyclerTabLayout_rtl_tabMinWidth, 0);
    mTabMaxWidth = a.getDimensionPixelSize(R.styleable.rtl_RecyclerTabLayout_rtl_tabMaxWidth, 0);
    mTabBackgroundResId = a.getResourceId(R.styleable.rtl_RecyclerTabLayout_rtl_tabBackground, 0);
    a.recycle();

    mPositionThreshold = DEFAULT_POSITION_THRESHOLD;
}

From source file:ticwear.design.widget.CollapsingToolbarLayout.java

public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mCollapsingTextHelper = new CollapsingTextHelper(this);
    mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr,
            R.style.Widget_Ticwear_CollapsingToolbar);

    mCollapsingTextHelper//w  ww .j a v a2  s  .c  o  m
            .setExpandedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_tic_expandedTitleGravity,
                    GravityCompat.START | Gravity.BOTTOM));
    mCollapsingTextHelper
            .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_tic_collapsedTitleGravity,
                    GravityCompat.START | Gravity.CENTER_VERTICAL));

    mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a
            .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMargin, 0);

    if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginStart)) {
        mExpandedMarginStart = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginStart, 0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginEnd)) {
        mExpandedMarginEnd = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginEnd, 0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginTop)) {
        mExpandedMarginTop = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginTop, 0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginBottom)) {
        mExpandedMarginBottom = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginBottom, 0);
    }

    mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_tic_titleEnabled, true);
    setTitle(a.getText(R.styleable.CollapsingToolbarLayout_android_title));

    // First load the default text appearances
    mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Ticwear_CollapsingToolbar_Expanded);
    mCollapsingTextHelper.setCollapsedTextAppearance(R.style.TextAppearance_Ticwear_TitleBar_Title);

    // Now overlay any custom text appearances
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_expandedTitleTextAppearance)) {
        mCollapsingTextHelper.setExpandedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_tic_expandedTitleTextAppearance, 0));
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_collapsedTitleTextAppearance)) {
        mCollapsingTextHelper.setCollapsedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_tic_collapsedTitleTextAppearance, 0));
    }

    setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_tic_contentScrim));
    setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_tic_statusBarScrim));

    mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_tic_toolbarId, -1);

    a.recycle();

    setWillNotDraw(false);

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            if (isShown()) {
                mLastInsets = insets;
                requestLayout();
                return insets.consumeSystemWindowInsets();
            } else {
                return insets;
            }
        }
    });
}

From source file:aierjun.com.aierjunlibrary.widget.tablayout.PagerSlidingTabStrip.java

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

    setFillViewport(true);//ww  w .j  a v  a  2  s  .c om
    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 system attrs (android:textSize and android:textColor)
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

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

    tabBackgroundDrawable = createColorStateListDrawable(Color.TRANSPARENT,
            getResources().getColor(android.R.color.transparent));

    a.recycle();
    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);
    if (a.hasValue(R.styleable.PagerSlidingTabStrip_pstsTabBackground))
        tabBackgroundDrawable = a.getDrawable(R.styleable.PagerSlidingTabStrip_pstsTabBackground);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
    tabchecktextcolor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTabCheckTextColor, tabchecktextcolor);

    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.CollapsingToolbarLayout.java

public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    ThemeUtils.checkAppCompatTheme(context);

    mCollapsingTextHelper = new CollapsingTextHelper(this);
    mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr,
            R.style.Widget_Design_CollapsingToolbar);

    mCollapsingTextHelper.setExpandedTextGravity(a.getInt(
            R.styleable.CollapsingToolbarLayout_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM));
    mCollapsingTextHelper/*from  ww w .  j  a  v a2 s.  com*/
            .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity,
                    GravityCompat.START | Gravity.CENTER_VERTICAL));

    mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a
            .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0);

    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) {
        mExpandedMarginStart = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) {
        mExpandedMarginEnd = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd,
                0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) {
        mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop,
                0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) {
        mExpandedMarginBottom = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0);
    }

    mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_titleEnabled, true);
    setTitle(a.getText(R.styleable.CollapsingToolbarLayout_title));

    // First load the default text appearances
    mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Design_CollapsingToolbar_Expanded);
    mCollapsingTextHelper.setCollapsedTextAppearance(R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);

    // Now overlay any custom text appearances
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) {
        mCollapsingTextHelper.setExpandedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0));
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) {
        mCollapsingTextHelper.setCollapsedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0));
    }

    setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim));
    setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_statusBarScrim));

    mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_toolbarId, -1);

    a.recycle();

    setWillNotDraw(false);

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4ox.view.OnApplyWindowInsetsListener() {
                @Override
                public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                    return setWindowInsets(insets);
                }
            });
}

From source file:ticwear.design.widget.AppBarLayout.java

public AppBarLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    setOrientation(VERTICAL);/*from   w  w  w. j  a  va 2 s . c o m*/

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppBarLayout, 0,
            R.style.Widget_Ticwear_AppBarLayout);
    mTargetElevation = a.getDimensionPixelSize(R.styleable.AppBarLayout_android_elevation, 0);
    setBackgroundDrawable(a.getDrawable(R.styleable.AppBarLayout_android_background));
    if (a.hasValue(R.styleable.AppBarLayout_tic_expanded)) {
        setExpanded(a.getBoolean(R.styleable.AppBarLayout_tic_expanded, false));
    }
    a.recycle();

    // Use the bounds view outline provider so that we cast a shadow, even without a background
    setOutlineProvider(ViewOutlineProvider.BOUNDS);

    mListeners = new ArrayList<>();

    ViewCompat.setElevation(this, mTargetElevation);

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            if (isShown()) {
                setWindowInsets(insets);
                return insets.consumeSystemWindowInsets();
            } else {
                return insets;
            }
        }
    });
}

From source file:com.handmark.pulltorefresh.library.internal.LoadingLayout.java

public LoadingLayout(final Context context, final Mode mode, final TypedArray attrs) {
    super(context);
    final ViewGroup header = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header,
            this);
    mMode = mode;/*from   w w w  . j  ava 2 s .c  o  m*/
    mHeaderText = (TextView) header.findViewById(R.id.pull_to_refresh_text);
    mSubHeaderText = (TextView) header.findViewById(R.id.pull_to_refresh_sub_text);
    mHeaderProgress = (ProgressBar) header.findViewById(R.id.pull_to_refresh_progress);
    mHeaderArrow = (ImageView) header.findViewById(R.id.pull_to_refresh_arrow);
    mRotateAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.pull_to_refresh_rotate);
    audioManager = (AudioManager) context.getSystemService(Activity.AUDIO_SERVICE);
    mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    mContext = context;

    switch (mode) {
    case PULL_UP_TO_REFRESH:
        // Load in labels
        mPullLabel = context.getString(R.string.pull_to_refresh_from_bottom_pull_label);
        mRefreshingLabel = context.getString(R.string.pull_to_refresh_from_bottom_refreshing_label);
        mReleaseLabel = context.getString(R.string.pull_to_refresh_from_bottom_release_label);
        rotateArrow();
        break;

    case PULL_DOWN_TO_REFRESH:
    default:
        // Load in labels
        mPullLabel = context.getString(R.string.pull_to_refresh_pull_label);
        mRefreshingLabel = context.getString(R.string.pull_to_refresh_refreshing_label);
        mReleaseLabel = context.getString(R.string.pull_to_refresh_release_label);
        break;
    }

    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextColor)) {
        final ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderTextColor);
        setTextColor(null != colors ? colors : ColorStateList.valueOf(0xFF000000));
    }
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderSubTextColor)) {
        final ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderSubTextColor);
        setSubTextColor(null != colors ? colors : ColorStateList.valueOf(0xFF000000));
    }
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) {
        final Drawable background = attrs.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground);
        if (null != background) {
            setBackgroundDrawable(background);
        }
    }

    reset();
}

From source file:com.commonsware.cwac.crossport.design.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);//  ww  w  .j a  va2s .c  o m
    setWillNotDraw(false);
    setAddStatesFromChildren(true);

    mInputFrame = new FrameLayout(context);
    mInputFrame.setAddStatesFromChildren(true);
    addView(mInputFrame);

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

    mHintExpanded = mCollapsingTextHelper.getExpansionFraction() == 1f;

    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);

    mPasswordToggleEnabled = a.getBoolean(R.styleable.TextInputLayout_passwordToggleEnabled, false);
    mPasswordToggleDrawable = a.getDrawable(R.styleable.TextInputLayout_passwordToggleDrawable);
    mPasswordToggleContentDesc = a.getText(R.styleable.TextInputLayout_passwordToggleContentDescription);
    if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTint)) {
        mHasPasswordToggleTintList = true;
        mPasswordToggleTintList = a.getColorStateList(R.styleable.TextInputLayout_passwordToggleTint);
    }
    if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTintMode)) {
        mHasPasswordToggleTintMode = true;
        mPasswordToggleTintMode = ViewUtils
                .parseTintMode(a.getInt(R.styleable.TextInputLayout_passwordToggleTintMode, -1), null);
    }

    a.recycle();

    setErrorEnabled(errorEnabled);
    setCounterEnabled(counterEnabled);
    applyPasswordToggleTint();

    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());
}