Cleanups in XmlParserUtils.
1. Get rid of redundant toString call from getData method. 2. Recycle TypedArray. Test: make RunSettingsRoboTests -j40 Change-Id: Id7e9e442aaf449d46131fa4f3d5a7f0457069159
This commit is contained in:
@@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
package com.android.settings.search;
|
package com.android.settings.search;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,17 +87,18 @@ public class XmlParserUtils {
|
|||||||
R.styleable.Preference_android_fragment);
|
R.styleable.Preference_android_fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private static String getData(Context context, AttributeSet set, int[] attrs, int resId) {
|
private static String getData(Context context, AttributeSet set, int[] attrs, int resId) {
|
||||||
final TypedArray ta = context.obtainStyledAttributes(set, attrs);
|
final TypedArray ta = context.obtainStyledAttributes(set, attrs);
|
||||||
String data = ta.getString(resId);
|
String data = ta.getString(resId);
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
return (data != null) ? data.toString() : null;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getDataEntries(Context context, AttributeSet set, int[] attrs, int resId) {
|
private static String getDataEntries(Context context, AttributeSet set, int[] attrs, int resId) {
|
||||||
final TypedArray sa = context.obtainStyledAttributes(set, attrs);
|
final TypedArray sa = context.obtainStyledAttributes(set, attrs);
|
||||||
final TypedValue tv = sa.peekValue(resId);
|
final TypedValue tv = sa.peekValue(resId);
|
||||||
|
sa.recycle();
|
||||||
String[] data = null;
|
String[] data = null;
|
||||||
if (tv != null && tv.type == TypedValue.TYPE_REFERENCE) {
|
if (tv != null && tv.type == TypedValue.TYPE_REFERENCE) {
|
||||||
if (tv.resourceId != 0) {
|
if (tv.resourceId != 0) {
|
||||||
|
Reference in New Issue
Block a user