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