Search in sources :

Example 21 with TypedArray

use of android.content.res.TypedArray in project SimplifyReader by chentao0707.

the class PLAMultiColumnListView method init.

private void init(AttributeSet attrs) {
    getWindowVisibleDisplayFrame(mFrameRect);
    if (attrs == null) {
        //default column number is 2.
        mColumnNumber = DEFAULT_COLUMN_NUMBER;
    } else {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.PLAMultiColumnListView);
        int landColNumber = a.getInteger(R.styleable.PLAMultiColumnListView_plaLandscapeColumnNumber, -1);
        int defColNumber = a.getInteger(R.styleable.PLAMultiColumnListView_plaColumnNumber, -1);
        if (mFrameRect.width() > mFrameRect.height() && landColNumber != -1) {
            mColumnNumber = landColNumber;
        } else if (defColNumber != -1) {
            mColumnNumber = defColNumber;
        } else {
            mColumnNumber = DEFAULT_COLUMN_NUMBER;
        }
        mColumnPaddingLeft = a.getDimensionPixelSize(R.styleable.PLAMultiColumnListView_plaColumnPaddingLeft, 0);
        mColumnPaddingRight = a.getDimensionPixelSize(R.styleable.PLAMultiColumnListView_plaColumnPaddingRight, 0);
        a.recycle();
    }
    mColumns = new Column[mColumnNumber];
    for (int i = 0; i < mColumnNumber; ++i) mColumns[i] = new Column(i);
    mFixedColumn = new FixedColumn();
}
Also used : TypedArray(android.content.res.TypedArray)

Example 22 with TypedArray

use of android.content.res.TypedArray in project ActionBar-PullToRefresh by chrisbanes.

the class AbcDefaultHeaderTransformer method getActionBarSize.

@Override
protected int getActionBarSize(Context context) {
    // Super handles ICS+ anyway...
    if (Build.VERSION.SDK_INT >= super.getMinimumApiLevel()) {
        return super.getActionBarSize(context);
    }
    int[] attrs = { R.attr.actionBarSize };
    TypedArray values = context.obtainStyledAttributes(attrs);
    try {
        return values.getDimensionPixelSize(0, 0);
    } finally {
        values.recycle();
    }
}
Also used : TypedArray(android.content.res.TypedArray)

Example 23 with TypedArray

use of android.content.res.TypedArray in project ActionBar-PullToRefresh by chrisbanes.

the class DefaultHeaderTransformer method getActionBarBackground.

protected Drawable getActionBarBackground(Context context) {
    int[] android_styleable_ActionBar = { android.R.attr.background };
    // Now get the action bar style values...
    TypedArray abStyle = obtainStyledAttrsFromThemeAttr(context, android.R.attr.actionBarStyle, android_styleable_ActionBar);
    try {
        // background is the first attr in the array above so it's index is 0.
        return abStyle.getDrawable(0);
    } finally {
        abStyle.recycle();
    }
}
Also used : TypedArray(android.content.res.TypedArray)

Example 24 with TypedArray

use of android.content.res.TypedArray in project ActionBar-PullToRefresh by chrisbanes.

the class DefaultHeaderTransformer method setupViewsFromStyles.

private void setupViewsFromStyles(Activity activity, View headerView) {
    final TypedArray styleAttrs = obtainStyledAttrsFromThemeAttr(activity, R.attr.ptrHeaderStyle, R.styleable.PullToRefreshHeader);
    // Retrieve the Action Bar size from the app theme or the Action Bar's style
    if (mContentLayout != null) {
        final int height = styleAttrs.getDimensionPixelSize(R.styleable.PullToRefreshHeader_ptrHeaderHeight, getActionBarSize(activity));
        mContentLayout.getLayoutParams().height = height;
        mContentLayout.requestLayout();
    }
    // Retrieve the Action Bar background from the app theme or the Action Bar's style (see #93)
    Drawable bg = styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrHeaderBackground) ? styleAttrs.getDrawable(R.styleable.PullToRefreshHeader_ptrHeaderBackground) : getActionBarBackground(activity);
    if (bg != null) {
        mHeaderTextView.setBackgroundDrawable(bg);
        // If we have an opaque background we can remove the background from the content layout
        if (mContentLayout != null && bg.getOpacity() == PixelFormat.OPAQUE) {
            mContentLayout.setBackgroundResource(0);
        }
    }
    // Retrieve the Action Bar Title Style from the app theme or the Action Bar's style
    Context abContext = headerView.getContext();
    final int titleTextStyle = styleAttrs.getResourceId(R.styleable.PullToRefreshHeader_ptrHeaderTitleTextAppearance, getActionBarTitleStyle(abContext));
    if (titleTextStyle != 0) {
        mHeaderTextView.setTextAppearance(abContext, titleTextStyle);
    }
    // Retrieve the Progress Bar Color the style
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrProgressBarColor)) {
        mProgressDrawableColor = styleAttrs.getColor(R.styleable.PullToRefreshHeader_ptrProgressBarColor, mProgressDrawableColor);
    }
    mProgressBarStyle = styleAttrs.getInt(R.styleable.PullToRefreshHeader_ptrProgressBarStyle, PROGRESS_BAR_STYLE_OUTSIDE);
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrProgressBarHeight)) {
        mProgressBarHeight = styleAttrs.getDimensionPixelSize(R.styleable.PullToRefreshHeader_ptrProgressBarHeight, mProgressBarHeight);
    }
    // Retrieve the text strings from the style (if they're set)
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrPullText)) {
        mPullRefreshLabel = styleAttrs.getString(R.styleable.PullToRefreshHeader_ptrPullText);
    }
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrRefreshingText)) {
        mRefreshingLabel = styleAttrs.getString(R.styleable.PullToRefreshHeader_ptrRefreshingText);
    }
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrReleaseText)) {
        mReleaseLabel = styleAttrs.getString(R.styleable.PullToRefreshHeader_ptrReleaseText);
    }
    //SmoothProgressBar Style
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrSmoothProgressBarStyle)) {
        int spbStyleRes = styleAttrs.getResourceId(R.styleable.PullToRefreshHeader_ptrSmoothProgressBarStyle, 0);
        if (spbStyleRes != 0)
            mHeaderProgressBar.applyStyle(spbStyleRes);
    }
    styleAttrs.recycle();
}
Also used : Context(android.content.Context) TypedArray(android.content.res.TypedArray) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Drawable(android.graphics.drawable.Drawable) ClipDrawable(android.graphics.drawable.ClipDrawable)

Example 25 with TypedArray

use of android.content.res.TypedArray in project ActionBar-PullToRefresh by chrisbanes.

the class DefaultHeaderTransformer method getActionBarSize.

protected int getActionBarSize(Context context) {
    int[] attrs = { android.R.attr.actionBarSize };
    TypedArray values = context.getTheme().obtainStyledAttributes(attrs);
    try {
        return values.getDimensionPixelSize(0, 0);
    } finally {
        values.recycle();
    }
}
Also used : TypedArray(android.content.res.TypedArray)

Aggregations

TypedArray (android.content.res.TypedArray)1991 Paint (android.graphics.Paint)190 TypedValue (android.util.TypedValue)185 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)162 Resources (android.content.res.Resources)118 View (android.view.View)116 Drawable (android.graphics.drawable.Drawable)114 XmlResourceParser (android.content.res.XmlResourceParser)80 Context (android.content.Context)78 ColorStateList (android.content.res.ColorStateList)78 AttributeSet (android.util.AttributeSet)78 IOException (java.io.IOException)77 SuppressLint (android.annotation.SuppressLint)66 TextPaint (android.text.TextPaint)63 TextView (android.widget.TextView)62 ViewGroup (android.view.ViewGroup)59 Bundle (android.os.Bundle)48 LayoutInflater (android.view.LayoutInflater)42 Point (android.graphics.Point)41 ImageView (android.widget.ImageView)40