mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-11 20:15:03 -05:00
Work around a bug in ListView
This commit is contained in:
parent
94b5758eea
commit
aff9bec92b
@ -1,6 +1,7 @@
|
|||||||
package com.fsck.k9.view;
|
package com.fsck.k9.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
@ -28,6 +29,31 @@ public class K9PullToRefreshListView extends PullToRefreshListView {
|
|||||||
*/
|
*/
|
||||||
layoutChildren();
|
layoutChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatchDraw(Canvas canvas) {
|
||||||
|
if (getAdapter() != null) {
|
||||||
|
int count = getChildCount();
|
||||||
|
int itemCount = getAdapter().getCount();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 2013-03-18 - cketti
|
||||||
|
*
|
||||||
|
* Work around a bug in ListView (?) that leads to a crash deep inside the
|
||||||
|
* framework code.
|
||||||
|
* I didn't track down the exact cause of this. My best guess is that we change
|
||||||
|
* the data (remove items) while the ListView isn't visible. Probably because
|
||||||
|
* the view is hidden, layoutChildren() is never called and when this method
|
||||||
|
* runs the layout contains more item views than the adapter contains elements
|
||||||
|
* and bad things(tm) happen.
|
||||||
|
*/
|
||||||
|
if (itemCount < count) {
|
||||||
|
layoutChildren();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.dispatchDraw(canvas);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user