summaryrefslogtreecommitdiff
path: root/core/java/android/widget/AdapterView.java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-08-30 18:38:14 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-08-30 18:38:14 -0700
commite30e1ff8bce5bc74555d34fc13d00c548c1ca24e (patch)
tree110f7c3efdfa8bf1a679fac6a3b7295ab590f5de /core/java/android/widget/AdapterView.java
parent22f5ee93746f37823265b8cb9b1e94e572607514 (diff)
parent7d04f2bc4e38d5d7d2b37d6dec76fb3793311341 (diff)
am 7d04f2bc: am 4c72ad75: Merge "Fix bug 2918587 Infinite loop and memory leak in AdapterView" into gingerbread
Merge commit '7d04f2bc4e38d5d7d2b37d6dec76fb3793311341' * commit '7d04f2bc4e38d5d7d2b37d6dec76fb3793311341': Fix bug 2918587 Infinite loop and memory leak in AdapterView
Diffstat (limited to 'core/java/android/widget/AdapterView.java')
-rw-r--r--core/java/android/widget/AdapterView.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java
index e20fee5b38d4..ab7542079a90 100644
--- a/core/java/android/widget/AdapterView.java
+++ b/core/java/android/widget/AdapterView.java
@@ -808,7 +808,6 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
mNextSelectedPosition = INVALID_POSITION;
mNextSelectedRowId = INVALID_ROW_ID;
mNeedSync = false;
- checkSelectionChanged();
checkFocus();
requestLayout();
@@ -819,13 +818,21 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
}
}
- private class SelectionNotifier extends Handler implements Runnable {
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ removeCallbacks(mSelectionNotifier);
+ }
+
+ private class SelectionNotifier implements Runnable {
public void run() {
if (mDataChanged) {
// Data has changed between when this SelectionNotifier
// was posted and now. We need to wait until the AdapterView
// has been synched to the new data.
- post(this);
+ if (getAdapter() != null) {
+ post(this);
+ }
} else {
fireOnSelected();
}
@@ -842,7 +849,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
if (mSelectionNotifier == null) {
mSelectionNotifier = new SelectionNotifier();
}
- mSelectionNotifier.post(mSelectionNotifier);
+ post(mSelectionNotifier);
} else {
fireOnSelected();
}