Example usage for android.content.res TypedArray recycle

List of usage examples for android.content.res TypedArray recycle

Introduction

In this page you can find the example usage for android.content.res TypedArray recycle.

Prototype

public void recycle() 

Source Link

Document

Recycles the TypedArray, to be re-used by a later caller.

Usage

From source file:com.jaspersoft.android.jaspermobile.activities.profile.ServerProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final TypedArray styledAttributes = getTheme()
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    mActionBarSize = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }//from   w  w  w. j  a v a2s . c o m

    invalidateOptionsMenu();

    if (profileId != 0 && savedInstanceState == null) {
        getSupportLoaderManager().initLoader(LOAD_PROFILE, null, this);
    }
}

From source file:cl.monsoon.s1next.widget.BezelImageView.java

private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    // attribute initialization
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView,
            defStyleAttr, defStyleRes);//from   ww w.  j  ava 2  s . c o  m

    mMaskDrawable = typedArray.getDrawable(R.styleable.BezelImageView_maskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }

    mBorderDrawable = typedArray.getDrawable(R.styleable.BezelImageView_borderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    typedArray.recycle();

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // always want a cache allocated
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
}

From source file:cn.com.hgh.view.SlideSwitch.java

public SlideSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    listener = null;//  w ww . ja  v a  2s . co m
    paint = new Paint();
    paint.setAntiAlias(true);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.slideswitch);
    color_theme = a.getColor(R.styleable.slideswitch_themeColor, DEFAULT_COLOR_THEME);
    isOpen = a.getBoolean(R.styleable.slideswitch_isOpen, false);
    shape = a.getInt(R.styleable.slideswitch_shape1, SHAPE_RECT);
    a.recycle();

}

From source file:android.support.v7.preference.PreferenceGroupAdapter.java

@Override
public PreferenceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final PreferenceLayout pl = mPreferenceLayouts.get(viewType);
    final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    TypedArray a = parent.getContext().obtainStyledAttributes(null, R.styleable.BackgroundStyle);
    Drawable background = a.getDrawable(R.styleable.BackgroundStyle_android_selectableItemBackground);
    if (background == null) {
        background = parent.getContext().getResources()
                .getDrawable(android.R.drawable.list_selector_background);
    }//from w  ww.  j a v a2s .  c  o m
    a.recycle();

    final View view = inflater.inflate(pl.resId, parent, false);
    if (view.getBackground() == null) {
        ViewCompat.setBackground(view, background);
    }

    final ViewGroup widgetFrame = (ViewGroup) view.findViewById(android.R.id.widget_frame);
    if (widgetFrame != null) {
        if (pl.widgetResId != 0) {
            inflater.inflate(pl.widgetResId, widgetFrame);
        } else {
            widgetFrame.setVisibility(View.GONE);
        }
    }

    return new PreferenceViewHolder(view);
}

From source file:android.support.v7.preference.ListPreference.java

public ListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPreference, defStyleAttr, defStyleRes);

    mEntries = TypedArrayUtils.getTextArray(a, R.styleable.ListPreference_entries,
            R.styleable.ListPreference_android_entries);

    mEntryValues = TypedArrayUtils.getTextArray(a, R.styleable.ListPreference_entryValues,
            R.styleable.ListPreference_android_entryValues);

    a.recycle();

    /* Retrieve the Preference summary attribute since it's private
     * in the Preference class.//w w  w.  j a v a 2  s. c o  m
     */
    a = context.obtainStyledAttributes(attrs, R.styleable.Preference, defStyleAttr, defStyleRes);

    mSummary = TypedArrayUtils.getString(a, R.styleable.Preference_summary,
            R.styleable.Preference_android_summary);

    a.recycle();
}

From source file:cn.tan.lib.widget.DrawShadowFrameLayout.java

public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawShadowFrameLayout, 0, 0);

    mShadowDrawable = a.getDrawable(R.styleable.DrawShadowFrameLayout_shadowDrawable);
    if (mShadowDrawable != null) {
        mShadowDrawable.setCallback(this);
        if (mShadowDrawable instanceof NinePatchDrawable) {
            mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable;
        }//from  www  . j a  v a  2  s  .com
    }

    mShadowVisible = a.getBoolean(R.styleable.DrawShadowFrameLayout_shadowVisible, true);
    setWillNotDraw(!mShadowVisible || mShadowDrawable == null);

    a.recycle();
}

From source file:com.actionbarsherlock.internal.widget.IcsLinearLayout.java

public IcsLinearLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/LinearLayout);

    setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider));
    mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE);
    mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding,
            0);//from w  w w  .  ja  v a2 s.  c om

    a.recycle();
}

From source file:android.support.v7.preference.MultiSelectListPreference.java

public MultiSelectListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiSelectListPreference,
            defStyleAttr, defStyleRes);//from  ww  w.  j  av a  2 s.  c  o m

    mEntries = TypedArrayUtils.getTextArray(a, R.styleable.MultiSelectListPreference_entries,
            R.styleable.MultiSelectListPreference_android_entries);

    mEntryValues = TypedArrayUtils.getTextArray(a, R.styleable.MultiSelectListPreference_entryValues,
            R.styleable.MultiSelectListPreference_android_entryValues);

    a.recycle();
}

From source file:ar.com.xpasta.Controls.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);/*from   ww  w .  ja v  a2s.  c  o  m*/
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null)
        locale = getResources().getConfiguration().locale;
}

From source file:cc.solart.turbo.TurboRecyclerView.java

public TurboRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TurboRecyclerView);
    int max = ta.getInteger(R.styleable.TurboRecyclerView_maxDragDistance, DRAG_MAX_DISTANCE);
    mTotalDragDistance = convertDpToPixel(context, max);
    mLoadEnabled = ta.getBoolean(R.styleable.TurboRecyclerView_enableLoad, false);
    ta.recycle();
}