List of usage examples for android.content.res TypedArray getInt
public int getInt(@StyleableRes int index, int defValue)
From source file:com.jaredrummler.android.colorpicker.ColorPanelView.java
private void init(Context context, AttributeSet attrs) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ColorPanelView); shape = a.getInt(R.styleable.ColorPanelView_cpv_colorShape, ColorShape.CIRCLE); showOldColor = a.getBoolean(R.styleable.ColorPanelView_cpv_showOldColor, false); if (showOldColor && shape != ColorShape.CIRCLE) { throw new IllegalStateException("Color preview is only available in circle mode"); }//from www. j a v a 2 s .co m borderColor = a.getColor(R.styleable.ColorPanelView_cpv_borderColor, DEFAULT_BORDER_COLOR); a.recycle(); if (borderColor == DEFAULT_BORDER_COLOR) { // If no specific border color has been set we take the default secondary text color as border/slider color. // Thus it will adopt to theme changes automatically. final TypedValue value = new TypedValue(); TypedArray typedArray = context.obtainStyledAttributes(value.data, new int[] { android.R.attr.textColorSecondary }); borderColor = typedArray.getColor(0, borderColor); typedArray.recycle(); } borderWidthPx = DrawingUtils.dpToPx(context, 1); borderPaint = new Paint(); borderPaint.setAntiAlias(true); colorPaint = new Paint(); colorPaint.setAntiAlias(true); if (showOldColor) { originalPaint = new Paint(); } if (shape == ColorShape.CIRCLE) { Bitmap bitmap = ((BitmapDrawable) context.getResources().getDrawable(R.drawable.cpv_alpha)).getBitmap(); alphaPaint = new Paint(); alphaPaint.setAntiAlias(true); BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT); alphaPaint.setShader(shader); } }
From source file:com.rashwan.reactive_popular_movies.common.utilities.ExpandableTextView.java
private void init(AttributeSet attrs) { TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView); mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines, MAX_COLLAPSED_LINES);/*from w ww.ja va 2 s . c om*/ mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION); mExpandDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_expandDrawable); mCollapseDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_collapseDrawable); if (mExpandDrawable == null) { mExpandDrawable = getDrawable(getContext(), R.drawable.ic_expand_more_white_12dp); } if (mCollapseDrawable == null) { mCollapseDrawable = getDrawable(getContext(), R.drawable.ic_expand_less_white_12dp); } typedArray.recycle(); // enforces vertical orientation setOrientation(LinearLayout.VERTICAL); // default visibility is gone setVisibility(GONE); }
From source file:com.android.settings.SeekBarPreference.java
public SeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.ProgressBar, defStyleAttr, defStyleRes);/*from www. ja v a 2 s.c o m*/ setMax(a.getInt(com.android.internal.R.styleable.ProgressBar_max, mMax)); a.recycle(); a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.SeekBarPreference, defStyleAttr, defStyleRes); final int layoutResId = a.getResourceId(com.android.internal.R.styleable.SeekBarPreference_layout, com.android.internal.R.layout.preference_widget_seekbar); a.recycle(); setLayoutResource(layoutResId); }
From source file:com.mobileglobe.android.customdialer.common.list.ViewPagerTabs.java
public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/*from w ww . j a v a 2s . co m*/ mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mTextSize = a.getDimensionPixelSize(0, 0); mTextStyle = a.getInt(1, 0); mTextColor = a.getColorStateList(2); mTextAllCaps = a.getBoolean(3, false); mTabStrip = new ViewPagerTabStrip(context); addView(mTabStrip, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); a.recycle(); if (CompatUtils.isLollipopCompatible()) { // enable shadow casting from view bounds setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER); } }
From source file:com.android.contacts.common.list.ViewPagerTabs.java
public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//from ww w . j a v a 2 s.co m mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mTextSize = a.getDimensionPixelSize(0, 0); mTextStyle = a.getInt(1, 0); mTextColor = a.getColorStateList(2); mTextAllCaps = a.getBoolean(3, false); mTabStrip = new ViewPagerTabStrip(context); addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); a.recycle(); if (CompatUtils.isLollipopCompatible()) { // enable shadow casting from view bounds setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER); } }
From source file:com.findme.views.ExpandableTextView.java
private void init(AttributeSet attrs) { TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView); mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines, MAX_COLLAPSED_LINES);//ww w. j a v a2s. c om mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION); mAnimAlphaStart = typedArray.getFloat(R.styleable.ExpandableTextView_animAlphaStart, DEFAULT_ANIM_ALPHA_START); mExpandDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_expandDrawable); mCollapseDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_collapseDrawable); if (mExpandDrawable == null) { mExpandDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_action_expand, null); } if (mCollapseDrawable == null) { mCollapseDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_action_collapse, null); } typedArray.recycle(); }
From source file:cc.kenai.common.AnimatedSvgView.java
private void init(Context context, AttributeSet attrs) { mFillPaint = new Paint(); mFillPaint.setAntiAlias(true);//from w ww. j a v a2 s. c om mFillPaint.setStyle(Paint.Style.FILL); mMarkerLength = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, MARKER_LENGTH_DIP, getResources().getDisplayMetrics()); mTraceColors = new int[1]; mTraceColors[0] = Color.BLACK; mTraceResidueColors = new int[1]; mTraceResidueColors[0] = Color.argb(50, 0, 0, 0); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatedSvgView); mViewportWidth = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeX, 433); Log.i(TAG, "mViewportWidth=" + mViewportWidth); mRatioSizingInfo.aspectRatioWidth = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeX, 433); mViewportHeight = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeY, 433); mRatioSizingInfo.aspectRatioHeight = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeY, 433); mTraceTime = a.getInt(R.styleable.AnimatedSvgView_oakSvgTraceTime, 2000); mTraceTimePerGlyph = a.getInt(R.styleable.AnimatedSvgView_oakSvgTraceTimePerGlyph, 1000); mFillStart = a.getInt(R.styleable.AnimatedSvgView_oakSvgFillStart, 1200); mFillTime = a.getInt(R.styleable.AnimatedSvgView_oakSvgFillTime, 1000); a.recycle(); mViewport = new PointF(mViewportWidth, mViewportHeight); } loadConfig(); }
From source file:com.afwsamples.testdpc.common.preference.DpcPreferenceHelper.java
public DpcPreferenceHelper(Context context, Preference preference, AttributeSet attrs) { mContext = context;//from w w w . ja v a 2 s.co m mPreference = preference; final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DpcPreference); mMinSdkVersion = a.getInt(R.styleable.DpcPreference_minSdkVersion, 0); if (attrs == null) { // Be more lenient when creating the preference from code mMinSdkVersion = Build.VERSION_CODES.LOLLIPOP; } if (mMinSdkVersion == 0) { throw new RuntimeException("testdpc:minSdkVersion must be specified."); } // noinspection ResourceType mAdminConstraint = a.getInt(R.styleable.DpcPreference_admin, ADMIN_DEFAULT); // noinspection ResourceType mUserConstraint = a.getInt(R.styleable.DpcPreference_user, USER_DEFAULT); a.recycle(); }
From source file:com.daitu_liang.study.mytest.svg.AnimatedSvgView.java
private void init(Context context, AttributeSet attrs) { mFillPaint = new Paint(); mFillPaint.setAntiAlias(true);/*from w w w . j av a 2 s .c om*/ mFillPaint.setStyle(Paint.Style.FILL); mMarkerLength = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, MARKER_LENGTH_DIP, getResources().getDisplayMetrics()); mTraceColors = new int[1]; mTraceColors[0] = Color.BLACK; mTraceResidueColors = new int[1]; mTraceResidueColors[0] = Color.argb(50, 0, 0, 0); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatedSvgView); mViewportWidth = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeX, 433); Log.i(TAG, "mViewportWidth=" + mViewportWidth); mRatioSizingInfo.aspectRatioWidth = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeX, 433); mViewportHeight = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeY, 433); mRatioSizingInfo.aspectRatioHeight = a.getInt(R.styleable.AnimatedSvgView_oakSvgImageSizeY, 433); mTraceTime = a.getInt(R.styleable.AnimatedSvgView_oakSvgTraceTime, 2000); mTraceTimePerGlyph = a.getInt(R.styleable.AnimatedSvgView_oakSvgTraceTimePerGlyph, 1000); mFillStart = a.getInt(R.styleable.AnimatedSvgView_oakSvgFillStart, 1200); mFillTime = a.getInt(R.styleable.AnimatedSvgView_oakSvgFillTime, 1000); a.recycle(); mViewport = new PointF(mViewportWidth, mViewportHeight); } }
From source file:com.givewaygames.transition.TransitionInflater.java
private Transition createTransitionFromXml(XmlPullParser parser, AttributeSet attrs, TransitionSet transitionSet) throws XmlPullParserException, IOException { Transition transition = null;/*from ww w. jav a2 s . co m*/ // Make sure we are on a start tag. int type; int depth = parser.getDepth(); while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { boolean newTransition = false; if (type != XmlPullParser.START_TAG) { continue; } String name = parser.getName(); if ("fade".equals(name)) { TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.Fade); int fadingMode = a.getInt(R.styleable.Fade_fadingMode, Fade.IN | Fade.OUT); transition = new Fade(fadingMode); newTransition = true; } else if ("changeBounds".equals(name)) { transition = new ChangeBounds(); newTransition = true; } else if ("slide".equals(name)) { transition = new Slide(); newTransition = true; } else if ("autoTransition".equals(name)) { transition = new AutoTransition(); newTransition = true; } else if ("recolor".equals(name)) { transition = new Recolor(); newTransition = true; } else if ("transitionSet".equals(name)) { transition = new TransitionSet(); TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.TransitionSet); int ordering = a.getInt(R.styleable.TransitionSet_transitionOrdering, TransitionSet.ORDERING_TOGETHER); ((TransitionSet) transition).setOrdering(ordering); createTransitionFromXml(parser, attrs, ((TransitionSet) transition)); a.recycle(); newTransition = true; } else if ("targets".equals(name)) { if (parser.getDepth() - 1 > depth && transition != null) { // We're inside the child tag - add targets to the child getTargetIds(parser, attrs, transition); } else if (parser.getDepth() - 1 == depth && transitionSet != null) { // add targets to the set getTargetIds(parser, attrs, transitionSet); } } if (transition != null || "targets".equals(name)) { if (newTransition) { loadTransition(transition, attrs); if (transitionSet != null) { transitionSet.addTransition(transition); } } } else { throw new RuntimeException("Unknown scene name: " + parser.getName()); } } return transition; }