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.commonsware.cwac.colormixer.ColorMixer.java

private void initMixer(AttributeSet attrs) {
    if (isInEditMode()) {
        return;//from   ww w.  j  a  va2  s  . c o m
    }

    LayoutInflater inflater = null;

    if (getContext() instanceof Activity) {
        inflater = ((Activity) getContext()).getLayoutInflater();
    } else {
        inflater = LayoutInflater.from(getContext());
    }

    inflater.inflate(R.layout.cwac_colormixer_main, this, true);

    swatch = findViewById(R.id.swatch);

    red = (SeekBar) findViewById(R.id.red);
    red.setMax(0xFF);
    red.setOnSeekBarChangeListener(onMix);

    green = (SeekBar) findViewById(R.id.green);
    green.setMax(0xFF);
    green.setOnSeekBarChangeListener(onMix);

    blue = (SeekBar) findViewById(R.id.blue);
    blue.setMax(0xFF);
    blue.setOnSeekBarChangeListener(onMix);

    if (attrs != null) {
        int[] styleable = R.styleable.ColorMixer;
        TypedArray a = getContext().obtainStyledAttributes(attrs, styleable, 0, 0);

        setColor(a.getInt(R.styleable.ColorMixer_cwac_colormixer_color, 0xFFA4C639));
        a.recycle();
    }
}

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

public static Context getActionBarContext(final Context context) {
    final TypedArray a = context.obtainStyledAttributes(
            new int[] { android.R.attr.actionBarTheme, android.R.attr.actionBarWidgetTheme });
    final int resId;
    try {/*  w w w . ja  v  a 2 s.c o  m*/
        resId = a.hasValue(0) ? a.getResourceId(0, 0) : a.getResourceId(1, 0);
    } finally {
        a.recycle();
    }
    if (resId == 0)
        return context;
    return new ContextThemeWrapper(context, resId);
}

From source file:com.abdlh.axelspringerhack.UI.Views.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a != null) {
        mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForegroundBild);
        a.recycle();
    }/*from   w  w w . j a va  2  s. c o  m*/
    setWillNotDraw(true);
}

From source file:co.codecrunch.musicplayerlite.uicomponent.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;//from w  ww .  j a v a2 s .c  o  m
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForeground_ui);
    a.recycle();

    setWillNotDraw(true);
}

From source file:cm.aptoidetv.pt.RecommendationBuilder.java

public Notification build() throws IOException {

    Log.d(TAG, "Building notification - " + this.toString());

    if (mNotificationManager == null) {
        mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    }/*from www  . j av a 2s . c o  m*/

    Bundle extras = new Bundle();
    if (mBackgroundUri != null) {
        Log.d(TAG, "Background - " + mBackgroundUri);
        extras.putString(Notification.EXTRA_BACKGROUND_IMAGE_URI, mBackgroundUri);
    }

    Bitmap image = Picasso.with(mContext).load(mImageUri)
            .resize(Utils.convertDpToPixel(mContext, CARD_WIDTH), Utils.convertDpToPixel(mContext, CARD_HEIGHT))
            .get();

    TypedArray typedArray = mContext.getTheme().obtainStyledAttributes(ThemePicker.getThemePicker(),
            new int[] { R.attr.brandColor });
    int brandColorResourceId = typedArray.getResourceId(0, 0);
    typedArray.recycle();

    Notification notification = new NotificationCompat.BigPictureStyle(new NotificationCompat.Builder(mContext)
            .setContentTitle(mTitle).setContentText(mDescription).setPriority(mPriority).setLocalOnly(true)
            .setOngoing(true).setColor(mContext.getResources().getColor(brandColorResourceId))
            .setCategory(Notification.CATEGORY_RECOMMENDATION).setLargeIcon(image).setSmallIcon(mSmallIcon)
            .setContentIntent(mIntent).setExtras(extras)).build();

    mNotificationManager.notify(mId, notification);
    mNotificationManager = null;
    return notification;
}

From source file:android_network.hetnet.vpn_service.AdapterAccess.java

public AdapterAccess(Context context, Cursor cursor) {
    super(context, cursor, 0);
    colID = cursor.getColumnIndex("ID");
    colVersion = cursor.getColumnIndex("version");
    colProtocol = cursor.getColumnIndex("protocol");
    colDaddr = cursor.getColumnIndex("daddr");
    colDPort = cursor.getColumnIndex("dport");
    colTime = cursor.getColumnIndex("time");
    colAllowed = cursor.getColumnIndex("allowed");
    colBlock = cursor.getColumnIndex("block");
    colSent = cursor.getColumnIndex("sent");
    colReceived = cursor.getColumnIndex("received");
    colConnections = cursor.getColumnIndex("connections");

    TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorSecondary });
    try {//  ww w .  j  ava2  s .  c  o  m
        colorText = ta.getColor(0, 0);
    } finally {
        ta.recycle();
    }

    TypedValue tv = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.colorOn, tv, true);
    colorOn = tv.data;
    context.getTheme().resolveAttribute(R.attr.colorOff, tv, true);
    colorOff = tv.data;
}

From source file:br.liveo.ui.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;//from w w  w  .ja v  a 2 s .  c  o  m
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForeground);
    a.recycle();

    setWillNotDraw(true);
}

From source file:at.linuxtage.companion.widgets.ScrimInsetsFrameLayout.java

public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr,
            R.style.Widget_Design_ScrimInsetsFrameLayout);
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
    a.recycle();
    setWillNotDraw(true); // No need to draw until the insets are adjusted
    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override//from   www .j a  va 2s  .com
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            if (null == mInsets) {
                mInsets = new Rect();
            }
            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
            setWillNotDraw(mInsets.isEmpty() || mInsetForeground == null);
            ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:ar.worq.microturistas.view.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;//from  w w  w  .  j  ava2 s. c om
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_scrimInsetForeground);
    a.recycle();
    setWillNotDraw(true);
}

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

public PathInterpolatorCompat(Resources res, Resources.Theme theme, AttributeSet attrs, XmlPullParser parser) {
    TypedArray a = TypedArrayUtils.obtainAttributes(res, theme, attrs,
            AndroidResources.STYLEABLE_PATH_INTERPOLATOR);
    parseInterpolatorFromTypeArray(a, parser);
    a.recycle();
}