Java Code Examples for android.support.v7.widget.TintTypedArray#getResourceId()

The following examples show how to use android.support.v7.widget.TintTypedArray#getResourceId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SkinCompatProgressBarHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), attrs,
            TINT_ATTRS, defStyleAttr, 0);

    mIndeterminateDrawableResId = a.getResourceId(0, INVALID_ID);
    mProgressDrawableResId = a.getResourceId(1, INVALID_ID);

    a.recycle();
    applySkin();
}
 
Example 2
Source File: SkinCompatBackgroundHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), attrs,
            R.styleable.SkinBackgroundHelper, defStyleAttr, 0);
    try {
        if (a.hasValue(R.styleable.SkinBackgroundHelper_android_background)) {
            mBackgroundResId = a.getResourceId(
                    R.styleable.SkinBackgroundHelper_android_background, INVALID_ID);
        }
    } finally {
        a.recycle();
    }
    applySkin();
}
 
Example 3
Source File: SkinCompatAutoCompleteTextView.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public SkinCompatAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            TINT_ATTRS, defStyleAttr, 0);
    if (a.hasValue(0)) {
        mDropDownBackgroundResId = a.getResourceId(0, INVALID_ID);
    }
    a.recycle();
    applyDropDownBackgroundResource();
    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
    mTextHelper = new SkinCompatTextHelper(this);
    mTextHelper.loadFromAttributes(attrs, defStyleAttr);
}
 
Example 4
Source File: SkinCompatMultiAutoCompleteTextView.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public SkinCompatMultiAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            TINT_ATTRS, defStyleAttr, 0);
    if (a.hasValue(0)) {
        mDropDownBackgroundResId = a.getResourceId(0, INVALID_ID);
    }
    a.recycle();
    applyDropDownBackgroundResource();
    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
    mTextHelper = new SkinCompatTextHelper(this);
    mTextHelper.loadFromAttributes(attrs, defStyleAttr);
}
 
Example 5
Source File: SkinCompatTextHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    final Context context = mView.getContext();

    // First read the TextAppearance style id
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs,
            R.styleable.SkinCompatTextHelper, defStyleAttr, 0);
    final int ap = a.getResourceId(R.styleable.SkinCompatTextHelper_android_textAppearance, INVALID_ID);
    SkinLog.d(TAG, "ap = " + ap);
    a.recycle();

    if (ap != INVALID_ID) {
        a = TintTypedArray.obtainStyledAttributes(context, ap, R.styleable.SkinTextAppearance);
        if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
            mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
            SkinLog.d(TAG, "mTextColorResId = " + mTextColorResId);
        }
        if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) {
            mTextColorHintResId = a.getResourceId(
                    R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID);
            SkinLog.d(TAG, "mTextColorHintResId = " + mTextColorHintResId);
        }
        a.recycle();
    }

    // Now read the style's values
    a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.SkinTextAppearance,
            defStyleAttr, 0);
    if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
        mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        SkinLog.d(TAG, "mTextColorResId = " + mTextColorResId);
    }
    if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) {
        mTextColorHintResId = a.getResourceId(
                R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID);
        SkinLog.d(TAG, "mTextColorHintResId = " + mTextColorHintResId);
    }
    a.recycle();
    applySkin();
}
 
Example 6
Source File: SkinCompatTextHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public void onSetTextAppearance(Context context, int resId) {
    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context,
            resId, R.styleable.SkinTextAppearance);
    if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
        mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        SkinLog.d(TAG, "mTextColorResId = " + mTextColorResId);
    }
    if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) {
        mTextColorHintResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID);
        SkinLog.d(TAG, "mTextColorHintResId = " + mTextColorHintResId);
    }
    a.recycle();
    applySkin();
}
 
Example 7
Source File: SkinCompatSeekBarHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
@Override
    void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
        super.loadFromAttributes(attrs, defStyleAttr);

        TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), attrs,
                R.styleable.AppCompatSeekBar, defStyleAttr, 0);
        mThumbResId = a.getResourceId(R.styleable.AppCompatSeekBar_android_thumb, INVALID_ID);
//        final Drawable drawable = a.getDrawableIfKnown(R.styleable.AppCompatSeekBar_android_thumb);
//        if (drawable != null) {
//            mView.setThumb(drawable);
//        }

//        mTickMarkResId = a.getResourceId(R.styleable.AppCompatSeekBar_tickMark, INVALID_ID);
//        final Drawable tickMark = a.getDrawable(R.styleable.AppCompatSeekBar_tickMark);
//        setTickMark(tickMark);

//        if (a.hasValue(R.styleable.AppCompatSeekBar_tickMarkTintMode)) {
//            mTickMarkTintMode = DrawableUtils.parseTintMode(a.getInt(
//                    R.styleable.AppCompatSeekBar_tickMarkTintMode, -1), mTickMarkTintMode);
//            mHasTickMarkTintMode = true;
//        }

//        if (a.hasValue(R.styleable.AppCompatSeekBar_tickMarkTint)) {
//            mTickMarkTintList = a.getColorStateList(R.styleable.AppCompatSeekBar_tickMarkTint);
//            mHasTickMarkTint = true;
//        }

        a.recycle();

//        applyTickMarkTint();
        applySkin();
    }
 
Example 8
Source File: SkinCompatToolbar.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public SkinCompatToolbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);

    TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            R.styleable.Toolbar, defStyleAttr, 0);
    mNavigationIconResId = a.getResourceId(R.styleable.Toolbar_navigationIcon, INVALID_ID);

    int titleAp = a.getResourceId(R.styleable.Toolbar_titleTextAppearance, INVALID_ID);
    int subtitleAp = a.getResourceId(R.styleable.Toolbar_subtitleTextAppearance, INVALID_ID);
    a.recycle();
    if (titleAp != INVALID_ID) {
        a = TintTypedArray.obtainStyledAttributes(context, titleAp, R.styleable.SkinTextAppearance);
        mTitleTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        a.recycle();
    }
    if (subtitleAp != INVALID_ID) {
        a = TintTypedArray.obtainStyledAttributes(context, subtitleAp, R.styleable.SkinTextAppearance);
        mSubtitleTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        a.recycle();
    }
    a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            R.styleable.Toolbar, defStyleAttr, 0);
    if (a.hasValue(R.styleable.Toolbar_titleTextColor)) {
        mTitleTextColorResId = a.getResourceId(R.styleable.Toolbar_titleTextColor, INVALID_ID);
    }
    if (a.hasValue(R.styleable.Toolbar_subtitleTextColor)) {
        mSubtitleTextColorResId = a.getResourceId(R.styleable.Toolbar_subtitleTextColor, INVALID_ID);
    }
    a.recycle();
    applyTitleTextColor();
    applySubtitleTextColor();
    applyNavigationIcon();
}
 
Example 9
Source File: SkinCompatCheckedTextView.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public SkinCompatCheckedTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
    mTextHelper = new SkinCompatTextHelper(this);
    mTextHelper.loadFromAttributes(attrs, defStyleAttr);

    TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            TINT_ATTRS, defStyleAttr, 0);
    mCheckMarkResId = a.getResourceId(0, INVALID_ID);
    a.recycle();
    applyCheckMark();
}
 
Example 10
Source File: SkinCompatImageHelper.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    TintTypedArray a = null;
    try {
        a = TintTypedArray.obtainStyledAttributes(mView.getContext(), attrs,
                R.styleable.SkinCompatImageView, defStyleAttr, 0);

        mSrcResId = a.getResourceId(R.styleable.SkinCompatImageView_android_src, -1);
    } finally {
        if (a != null) {
            a.recycle();
        }
    }
    applySkin();
}
 
Example 11
Source File: SkinCompatSpinner.java    From AndroidSkinAnimator with MIT License 4 votes vote down vote up
public SkinCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode, Resources.Theme popupTheme) {
    super(context, attrs, defStyleAttr, mode, popupTheme);
    TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs,
            R.styleable.Spinner, defStyleAttr, 0);

    if (getPopupContext() != null) {
        if (mode == MODE_THEME) {
            if (Build.VERSION.SDK_INT >= 11) {
                // If we're running on API v11+ we will try and read android:spinnerMode
                TypedArray aa = null;
                try {
                    aa = context.obtainStyledAttributes(attrs, ATTRS_ANDROID_SPINNERMODE,
                            defStyleAttr, 0);
                    if (aa.hasValue(0)) {
                        mode = aa.getInt(0, MODE_DIALOG);
                    }
                } catch (Exception e) {
                    Log.i(TAG, "Could not read android:spinnerMode", e);
                } finally {
                    if (aa != null) {
                        aa.recycle();
                    }
                }
            } else {
                // Else, we use a default mode of dropdown
                mode = MODE_DROPDOWN;
            }
        }

        if (mode == MODE_DROPDOWN) {
            final TintTypedArray pa = TintTypedArray.obtainStyledAttributes(
                    getPopupContext(), attrs, R.styleable.Spinner, defStyleAttr, 0);
            mPopupBackgroundResId = pa.getResourceId(R.styleable.Spinner_android_popupBackground, INVALID_ID);
            pa.recycle();
        }
    }
    a.recycle();

    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
}