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:cnc.cad.rxjavatestapp.AvatarImageBehavior.java

public AvatarImageBehavior(Context context, AttributeSet attrs) {
    mContext = context;//w w  w  .ja  va 2  s . co m

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AvatarImageBehavior);
        mCustomFinalHeight = a.getDimension(R.styleable.AvatarImageBehavior_finalHeight, 0);
        a.recycle();
    }
}

From source file:com.abewy.android.apps.contacts.widget.BezelImageView.java

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

    // Attribute initialization
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, 0);

    setBorderDrawable(a.getDrawable(R.styleable.BezelImageView_borderDrawable));

    a.recycle();
}

From source file:be.ugent.zeus.hydra.views.ButtonBarLayout.java

public ButtonBarLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    final boolean allowStackingDefault = ConfigurationHelper
            .getScreenHeightDp(getResources()) >= ALLOW_STACKING_MIN_HEIGHT_DP;
    final TypedArray ta = context.obtainStyledAttributes(attrs,
            android.support.v7.appcompat.R.styleable.ButtonBarLayout);
    mAllowStacking = allowStackingDefault;
    ta.recycle();
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static int getThemeColor(Context context, int themeResourceId) {
    final Context appContext = context.getApplicationContext();
    final Resources res = appContext.getResources();
    final TypedArray a = appContext.obtainStyledAttributes(null,
            new int[] { android.R.attr.colorActivatedHighlight }, 0, themeResourceId);
    try {//from   w w w .  j a  v  a 2  s. c  om
        return a.getColor(0, res.getColor(R.color.material_light_blue));
    } finally {
        a.recycle();
    }
}

From source file:arun.com.chromer.browsing.customtabs.dynamictoolbar.AppColorExtractorJob.java

private int getThemedColor(@Nullable Resources resources, int attributeId, @NonNull String packageName)
        throws PackageManager.NameNotFoundException {
    if (resources == null || attributeId == 0)
        return -1;
    // Create dummy theme
    final Resources.Theme tempTheme = resources.newTheme();
    // Need the theme id to apply the theme, so let's get it.
    int themeId = getPackageManager().getPackageInfo(packageName, GET_META_DATA).applicationInfo.theme;
    // Apply the theme
    tempTheme.applyStyle(themeId, false);
    // Attempt to get styled values now
    final TypedArray array = tempTheme.obtainStyledAttributes(new int[] { attributeId });
    // Styled color
    int color = array.getColor(0, NO_COLOR);
    array.recycle();
    if (color == ContextCompat.getColor(this, R.color.md_grey_100)
            || color == ContextCompat.getColor(this, R.color.md_grey_900)) {
        color = NO_COLOR;//from w  ww. j  ava 2s .  c o m
    }
    return color;
}

From source file:android.support.v7.app.ActionBarActivityDelegate.java

void onCreate(Bundle savedInstanceState) {
    TypedArray a = mActivity.obtainStyledAttributes(R.styleable.ActionBarWindow);

    if (!a.hasValue(R.styleable.ActionBarWindow_windowActionBar)) {
        a.recycle();
        throw new IllegalStateException(
                "You need to use a Theme.AppCompat theme (or descendant) with this activity.");
    }//from  w w w.  j  a  v a2s. com

    mHasActionBar = a.getBoolean(R.styleable.ActionBarWindow_windowActionBar, false);
    mOverlayActionBar = a.getBoolean(R.styleable.ActionBarWindow_windowActionBarOverlay, false);
    a.recycle();
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void overrideNormalActivityCloseAnimation(final Activity activity) {
    final TypedArray a = activity.obtainStyledAttributes(null, ANIM_CLOSE_STYLE_ATTRS, 0,
            android.R.style.Animation_Activity);
    final int activityCloseEnterAnimation = a.getResourceId(0, 0);
    final int activityCloseExitAnimation = a.getResourceId(1, 0);
    a.recycle();
    activity.overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static int getTitleTextAppearance(final Context context) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.titleTextStyle },
            android.R.attr.actionBarStyle, android.R.style.Widget_Holo_ActionBar);
    final int textAppearance = a.getResourceId(0, android.R.style.TextAppearance_Holo);
    a.recycle();
    return textAppearance;
}

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

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

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

    a.getValue(R.styleable.SherlockTheme_windowMinWidthMajor, mMinWidthMajor);
    a.getValue(R.styleable.SherlockTheme_windowMinWidthMinor, mMinWidthMinor);

    a.recycle();
}

From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java

private static Animator createAnimatorFromXml(Context context, Resources res, Theme theme, XmlPullParser parser,
        AttributeSet attrs, AnimatorSet parent, int sequenceOrdering, float pixelSize)
        throws XmlPullParserException, IOException {
    Animator anim = null;//from   www. j  a v  a2 s. c om
    ArrayList<Animator> childAnims = null;

    // 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) {

        if (type != XmlPullParser.START_TAG) {
            continue;
        }

        String name = parser.getName();
        boolean gotValues = false;

        if (name.equals("objectAnimator")) {
            anim = loadObjectAnimator(context, res, theme, attrs, pixelSize, parser);
        } else if (name.equals("animator")) {
            anim = loadAnimator(context, res, theme, attrs, null, pixelSize, parser);
        } else if (name.equals("set")) {
            anim = new AnimatorSet();
            TypedArray a = TypedArrayUtils.obtainAttributes(res, theme, attrs,
                    AndroidResources.STYLEABLE_ANIMATOR_SET);

            int ordering = TypedArrayUtils.getNamedInt(a, parser, "ordering",
                    AndroidResources.STYLEABLE_ANIMATOR_SET_ORDERING, TOGETHER);

            createAnimatorFromXml(context, res, theme, parser, attrs, (AnimatorSet) anim, ordering, pixelSize);
            a.recycle();
        } else if (name.equals("propertyValuesHolder")) {
            PropertyValuesHolder[] values = loadValues(context, res, theme, parser, Xml.asAttributeSet(parser));
            if (values != null && anim != null && (anim instanceof ValueAnimator)) {
                ((ValueAnimator) anim).setValues(values);
            }
            gotValues = true;
        } else {
            throw new RuntimeException("Unknown animator name: " + parser.getName());
        }

        if (parent != null && !gotValues) {
            if (childAnims == null) {
                childAnims = new ArrayList<Animator>();
            }
            childAnims.add(anim);
        }
    }
    if (parent != null && childAnims != null) {
        Animator[] animsArray = new Animator[childAnims.size()];
        int index = 0;
        for (Animator a : childAnims) {
            animsArray[index++] = a;
        }
        if (sequenceOrdering == TOGETHER) {
            parent.playTogether(animsArray);
        } else {
            parent.playSequentially(animsArray);
        }
    }
    return anim;
}