Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cbbc2800 authored by Rajeev Kumar's avatar Rajeev Kumar
Browse files

Cleanups in XmlParserUtils.

1. Get rid of redundant toString call from getData method.
2. Recycle TypedArray.

Test: make RunSettingsRoboTests -j40
Change-Id: Id7e9e442aaf449d46131fa4f3d5a7f0457069159
parent 82ee7cf1
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -17,11 +17,11 @@

package com.android.settings.search;

import android.annotation.Nullable;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;

import com.android.settings.R;

/**
@@ -87,17 +87,18 @@ public class XmlParserUtils {
                R.styleable.Preference_android_fragment);
    }

    @Nullable
    private static String getData(Context context, AttributeSet set, int[] attrs, int resId) {
        final TypedArray ta = context.obtainStyledAttributes(set, attrs);
        String data = ta.getString(resId);
        ta.recycle();
        return (data != null) ? data.toString() : null;
        return data;
    }

    private static String getDataEntries(Context context, AttributeSet set, int[] attrs, int resId) {
        final TypedArray sa = context.obtainStyledAttributes(set, attrs);
        final TypedValue tv = sa.peekValue(resId);

        sa.recycle();
        String[] data = null;
        if (tv != null && tv.type == TypedValue.TYPE_REFERENCE) {
            if (tv.resourceId != 0) {