List of usage examples for android.content.res TypedArray getInteger
public int getInteger(@StyleableRes int index, int defValue)
From source file:com.frostwire.android.gui.views.KeywordTagView.java
private KeywordTagView(Context context, AttributeSet attrs, KeywordFilter keywordFilter) { super(context, attrs); if (keywordFilter == null) { TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.KeywordTagView, 0, 0); count = attributes.getInteger(R.styleable.KeywordTagView_keyword_tag_count, 0); dismissible = attributes.getBoolean(R.styleable.KeywordTagView_keyword_tag_dismissable, true); boolean inclusive = attributes.getBoolean(R.styleable.KeywordTagView_keyword_tag_inclusive, true); String keyword = attributes.getString(R.styleable.KeywordTagView_keyword_tag_keyword); keywordFilter = new KeywordFilter(inclusive, keyword != null ? keyword : "[Text]", KeywordDetector.Feature.MANUAL_ENTRY); attributes.recycle();/*from w ww.j a v a 2 s . com*/ } this.keywordFilter = keywordFilter; keywordSpan = new TextAppearanceSpan(getContext(), R.style.keywordTagText); countSpan = new TextAppearanceSpan(getContext(), R.style.keywordTagCount); layoutParams = new FlexboxLayout.LayoutParams(FlexboxLayout.LayoutParams.WRAP_CONTENT, toPx(34)); layoutParams.setMargins(0, 0, toPx(6), toPx(8)); setPadding(toPx(12), toPx(4), toPx(12), toPx(4)); setMinHeight(toPx(34)); setGravity(Gravity.CENTER_VERTICAL); setCompoundDrawablePadding(toPx(6)); }
From source file:com.github.preferencefragment.preference.MyPreference.java
@Override protected Object onGetDefaultValue(TypedArray a, int index) { // This preference type's value type is Integer, so we read the default // value from the attributes as an Integer. return a.getInteger(index, 0); }
From source file:it.scoppelletti.mobilepower.preference.ColorPreference.java
/** * Restituisce il valore di default impostato via XML. * /* w w w .j a v a 2 s . co m*/ * @param attrs Attributi impostati. * @param index Indice del valore di default. * @return Valore di default. */ @Override protected Object onGetDefaultValue(TypedArray attrs, int index) { return attrs.getInteger(index, Color.WHITE); }
From source file:com.brookmanholmes.bma.wizard.ui.StepPagerStrip.java
public StepPagerStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); gravity = a.getInteger(0, gravity); a.recycle();//from www .ja v a2s .co m Resources res = getResources(); tabWidth = res.getDimensionPixelSize(R.dimen.step_pager_tab_width); tabHeight = res.getDimensionPixelSize(R.dimen.step_pager_tab_height); indicatorSpacing = res.getDimensionPixelSize(R.dimen.step_pager_tab_spacing); radius = 14; nonCurrentRadius = 10; nextTabPaint = new Paint(); nextTabPaint.setColor(ContextCompat.getColor(getContext(), R.color.step_pager_next_tab_color)); selectedTabPaint = new Paint(); selectedTabPaint.setColor(ContextCompat.getColor(getContext(), R.color.colorAccent)); prevTabPaint = new Paint(); prevTabPaint.setColor(ContextCompat.getColor(getContext(), R.color.colorPrimaryLight)); }
From source file:com.gigamole.millspinners.lib.CirclesWaveSpinner.java
public CirclesWaveSpinner(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CirclesWaveSpinner); try {//from w w w .j a v a 2s. c o m this.speed = typedArray.getInteger(R.styleable.CirclesWaveSpinner_speed, 3000) / 2; this.halfSpeed = this.speed / 2; final int colorsId = typedArray.getResourceId(R.styleable.CirclesWaveSpinner_colors, 0); if (colorsId != 0) { this.colors = getResources().getIntArray(colorsId); } else { this.colors = getResources().getIntArray(R.array.wave_colors); } } finally { typedArray.recycle(); } }
From source file:paulscode.android.mupen64plusae.preference.SeekBarPreference.java
@Override protected Object onGetDefaultValue(TypedArray a, int index) { return a.getInteger(index, DEFAULT_VALUE); }
From source file:id.co.datascrip.dtswarehousesystem.custom.StepPagerStrip.java
public StepPagerStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mGravity = a.getInteger(0, mGravity); a.recycle();/*from w w w .ja va 2s. c om*/ final Resources res = getResources(); mTabWidth = res.getDimensionPixelSize(R.dimen.step_pager_tab_width); mTabHeight = res.getDimensionPixelSize(R.dimen.step_pager_tab_height); mTabSpacing = res.getDimensionPixelSize(R.dimen.step_pager_tab_spacing); mPrevTabPaint = new Paint(); mPrevTabPaint.setColor(ContextCompat.getColor(context, R.color.step_pager_previous_tab_color)); mSelectedTabPaint = new Paint(); mSelectedTabPaint.setColor(ContextCompat.getColor(context, R.color.step_pager_selected_tab_color)); mSelectedLastTabPaint = new Paint(); mSelectedLastTabPaint.setColor(ContextCompat.getColor(context, R.color.step_pager_selected_last_tab_color)); mNextTabPaint = new Paint(); mNextTabPaint.setColor(ContextCompat.getColor(context, R.color.step_pager_next_tab_color)); }
From source file:org.mozilla.focus.widget.AnimatedProgressBar.java
private void init(@NonNull Context context, @Nullable AttributeSet attrs) { tempRect = new Rect(); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatedProgressBar); final int duration = a.getInteger(R.styleable.AnimatedProgressBar_shiftDuration, 1000); final int resID = a.getResourceId(R.styleable.AnimatedProgressBar_shiftInterpolator, 0); final boolean wrap = a.getBoolean(R.styleable.AnimatedProgressBar_wrapShiftDrawable, false); mPrimaryAnimator = ValueAnimator.ofInt(getProgress(), getMax()); mPrimaryAnimator.setInterpolator(new LinearInterpolator()); mPrimaryAnimator.setDuration(PROGRESS_DURATION); mPrimaryAnimator.addUpdateListener(mListener); mClosingAnimator.setDuration(CLOSING_DURATION); mClosingAnimator.setInterpolator(new LinearInterpolator()); mClosingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w ww . java2 s. com*/ public void onAnimationUpdate(ValueAnimator valueAnimator) { final float region = (float) valueAnimator.getAnimatedValue(); if (mClipRegion != region) { mClipRegion = region; invalidate(); } } }); mClosingAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mClipRegion = 0f; } @Override public void onAnimationEnd(Animator animator) { setVisibilityImmediately(GONE); } @Override public void onAnimationCancel(Animator animator) { mClipRegion = 0f; } @Override public void onAnimationRepeat(Animator animator) { } }); setProgressDrawable(buildWrapDrawable(getProgressDrawable(), wrap, duration, resID)); a.recycle(); }
From source file:com.github.snowdream.android.widget.NotFoundWebView.java
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" }) private void init(Context context, AttributeSet attrs, int defStyle) { if (context == null) { return;/*from w w w .j av a 2 s . c o m*/ } // enable JavaScript WebSettings settings = this.getSettings(); settings.setJavaScriptEnabled(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); settings.setLoadWithOverviewMode(true); settings.setDefaultZoom(ZoomDensity.FAR); //settings.setUseWideViewPort(true); //webView.setInitialScale(1); // init attrs TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustomWebView); try { int type = a.getInteger(R.styleable.CustomWebView_type, 0); switch (type) { case 0: script = context.getString(R.string.html_notfound); break; case 1: script = context.getString(R.string.html_qq_narrow); break; case 2: script = context.getString(R.string.html_qq_narrow); break; case 3: script = context.getString(R.string.html_qq_wide); break; case 4: script = context.getString(R.string.html_yibo); break; default: script = a.getString(R.styleable.CustomWebView_script); break; } } finally { a.recycle(); } }
From source file:paulscode.android.mupen64plusae.preference.PathPreference.java
/** * Constructor/*ww w. j a v a 2s. c o m*/ * * @param context The {@link Context} that this PathPreference is being used in. * @param attrs A collection of attributes, as found associated with a tag in an XML document. */ public PathPreference(Context context, AttributeSet attrs) { super(context, attrs); mUseDefaultSummary = TextUtils.isEmpty(getSummary()); // Get the selection mode from the XML file, if provided TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PathPreference); mSelectionMode = a.getInteger(R.styleable.PathPreference_selectionMode, SELECTION_MODE_ANY); a.recycle(); setOnPreferenceChangeListener(null); }