* commit '8dcc0e7dfb05a50ca306942037015244060862b8': Fix monkey bugs in ListView
This commit is contained in:
@@ -674,11 +674,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
private int mLastAccessibilityScrollEventFromIndex;
|
||||
private int mLastAccessibilityScrollEventToIndex;
|
||||
|
||||
/**
|
||||
* Track if we are currently attached to a window.
|
||||
*/
|
||||
boolean mIsAttached;
|
||||
|
||||
/**
|
||||
* Track the item count from the last time we handled a data change.
|
||||
*/
|
||||
@@ -1908,7 +1903,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
|
||||
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
|
||||
if (gainFocus && mSelectedPosition < 0 && !isInTouchMode()) {
|
||||
if (!mIsAttached && mAdapter != null) {
|
||||
if (!isAttachedToWindow() && mAdapter != null) {
|
||||
// Data may have changed while we were detached and it's valid
|
||||
// to change focus while detached. Refresh so we don't die.
|
||||
mDataChanged = true;
|
||||
@@ -2719,7 +2714,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
mOldItemCount = mItemCount;
|
||||
mItemCount = mAdapter.getCount();
|
||||
}
|
||||
mIsAttached = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2774,7 +2768,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
removeCallbacks(mTouchModeReset);
|
||||
mTouchModeReset.run();
|
||||
}
|
||||
mIsAttached = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3401,7 +3394,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
mPositionScroller.stop();
|
||||
}
|
||||
|
||||
if (!mIsAttached) {
|
||||
if (!isAttachedToWindow()) {
|
||||
// Something isn't right.
|
||||
// Since we rely on being attached to get data set change notifications,
|
||||
// don't risk doing anything where we might try to resync and find things
|
||||
@@ -3640,7 +3633,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
mTouchMode = TOUCH_MODE_REST;
|
||||
child.setPressed(false);
|
||||
setPressed(false);
|
||||
if (!mDataChanged) {
|
||||
if (!mDataChanged && isAttachedToWindow()) {
|
||||
performClick.run();
|
||||
}
|
||||
}
|
||||
@@ -3915,7 +3908,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
mPositionScroller.stop();
|
||||
}
|
||||
|
||||
if (!mIsAttached) {
|
||||
if (!isAttachedToWindow()) {
|
||||
// Something isn't right.
|
||||
// Since we rely on being attached to get data set change notifications,
|
||||
// don't risk doing anything where we might try to resync and find things
|
||||
|
||||
@@ -210,7 +210,7 @@ class FastScroller {
|
||||
private final Runnable mDeferStartDrag = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mList.mIsAttached) {
|
||||
if (mList.isAttachedToWindow()) {
|
||||
beginDrag();
|
||||
|
||||
final float pos = getPosFromMotionEvent(mInitialTouchY);
|
||||
|
||||
@@ -2126,7 +2126,7 @@ public class ListView extends AbsListView {
|
||||
}
|
||||
|
||||
private boolean commonKey(int keyCode, int count, KeyEvent event) {
|
||||
if (mAdapter == null || !mIsAttached) {
|
||||
if (mAdapter == null || !isAttachedToWindow()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user