summaryrefslogtreecommitdiff
path: root/core/java/android/widget/SimpleAdapter.java
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2010-01-04 14:52:38 -0800
committerRomain Guy <romainguy@android.com>2010-01-04 14:52:38 -0800
commitc8ca2a3a07300349e2733e05255f01a677647f24 (patch)
treee7768dcdc8ee514a31f7a46f24bf63e9f3214463 /core/java/android/widget/SimpleAdapter.java
parent3bf657a22bc46f06a9b73d2c5d256f48205849d6 (diff)
Plug memory leak in Simple*Adapter, due to the misuse of a WeakHashMap.
This removes an optimization but the benefit is not worth the memory leak. Bug: #2353474.
Diffstat (limited to 'core/java/android/widget/SimpleAdapter.java')
-rw-r--r--core/java/android/widget/SimpleAdapter.java18
1 files changed, 3 insertions, 15 deletions
diff --git a/core/java/android/widget/SimpleAdapter.java b/core/java/android/widget/SimpleAdapter.java
index 9dd4d151df1a..479965add4c4 100644
--- a/core/java/android/widget/SimpleAdapter.java
+++ b/core/java/android/widget/SimpleAdapter.java
@@ -25,7 +25,6 @@ import android.net.Uri;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.WeakHashMap;
/**
* An easy adapter to map static data to views defined in an XML file. You can specify the data
@@ -58,7 +57,6 @@ public class SimpleAdapter extends BaseAdapter implements Filterable {
private int mResource;
private int mDropDownResource;
private LayoutInflater mInflater;
- private final WeakHashMap<View, View[]> mHolders = new WeakHashMap<View, View[]>();
private SimpleFilter mFilter;
private ArrayList<Map<String, ?>> mUnfilteredData;
@@ -121,16 +119,6 @@ public class SimpleAdapter extends BaseAdapter implements Filterable {
View v;
if (convertView == null) {
v = mInflater.inflate(resource, parent, false);
-
- final int[] to = mTo;
- final int count = to.length;
- final View[] holder = new View[count];
-
- for (int i = 0; i < count; i++) {
- holder[i] = v.findViewById(to[i]);
- }
-
- mHolders.put(v, holder);
} else {
v = convertView;
}
@@ -162,13 +150,12 @@ public class SimpleAdapter extends BaseAdapter implements Filterable {
}
final ViewBinder binder = mViewBinder;
- final View[] holder = mHolders.get(view);
final String[] from = mFrom;
final int[] to = mTo;
final int count = to.length;
for (int i = 0; i < count; i++) {
- final View v = holder[i];
+ final View v = view.findViewById(to[i]);
if (v != null) {
final Object data = dataSet.get(from[i]);
String text = data == null ? "" : data.toString();
@@ -187,7 +174,8 @@ public class SimpleAdapter extends BaseAdapter implements Filterable {
((Checkable) v).setChecked((Boolean) data);
} else {
throw new IllegalStateException(v.getClass().getName() +
- " should be bound to a Boolean, not a " + data.getClass());
+ " should be bound to a Boolean, not a " +
+ (data == null ? "<unknown type>" : data.getClass()));
}
} else if (v instanceof TextView) {
// Note: keep the instanceof TextView check at the bottom of these