Skip to content

Commit 4c38fe3

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Protect against bogus input for ListViews" into jb-dev
2 parents a1723d1 + 28048d0 commit 4c38fe3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

core/java/android/widget/AbsListView.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,6 +3351,14 @@ public boolean onTouchEvent(MotionEvent ev) {
33513351
mPositionScroller.stop();
33523352
}
33533353

3354+
if (!mIsAttached) {
3355+
// Something isn't right.
3356+
// Since we rely on being attached to get data set change notifications,
3357+
// don't risk doing anything where we might try to resync and find things
3358+
// in a bogus state.
3359+
return false;
3360+
}
3361+
33543362
if (mFastScroller != null) {
33553363
boolean intercepted = mFastScroller.onTouchEvent(ev);
33563364
if (intercepted) {
@@ -3846,6 +3854,14 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
38463854
mPositionScroller.stop();
38473855
}
38483856

3857+
if (!mIsAttached) {
3858+
// Something isn't right.
3859+
// Since we rely on being attached to get data set change notifications,
3860+
// don't risk doing anything where we might try to resync and find things
3861+
// in a bogus state.
3862+
return false;
3863+
}
3864+
38493865
if (mFastScroller != null) {
38503866
boolean intercepted = mFastScroller.onInterceptTouchEvent(ev);
38513867
if (intercepted) {

core/java/com/android/internal/view/menu/ListMenuPresenter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public void initForMenu(Context context, MenuBuilder menu) {
8888
}
8989
}
9090
mMenu = menu;
91+
if (mAdapter != null) {
92+
mAdapter.notifyDataSetChanged();
93+
}
9194
}
9295

9396
@Override

0 commit comments

Comments
 (0)