You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.
FreeFlowContainer#notifyDataSetChanged() calls requestLayout() and redraw with backed adapter (computeLayout() and mLayout.prepareLayout()) in onMeasure().
But when requestLayout() is called while scrolling, onTouchEvent() is called before onMeasure() and it causes crash by IndexOutOfBoundsException in adapter implementation.
Note that ListView effectively avoids this problem by call layoutChildren() before applying scroll to view.
For workaround extend FreeFlowContainer and call onMeasure() when moveViewport(boolean) is called.
@SuppressLint("WrongCall") // for call onMeasure() directly instead of measure()
@Override
protected void moveViewport(boolean isInFlingMode) {
if (dataSetChanged) {
// XXX: Workaround for onTouchEvent() could be called between notifyDataSetChanged() and layout update in onMeasure()
// and passing invalid index to adapter. This enforces layout update before applying scroll.
// Refer: https://github.com/Comcast/FreeFlow/issues/85
onMeasure(getWidth() | MeasureSpec.EXACTLY, getHeight() | MeasureSpec.EXACTLY);
}
super.moveViewport(isInFlingMode);
}
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
FreeFlowContainer#notifyDataSetChanged()
calls requestLayout() and redraw with backed adapter (computeLayout() and mLayout.prepareLayout()) in onMeasure().FreeFlow/FreeFlow/src/com/comcast/freeflow/core/FreeFlowContainer.java
Line 276 in 96ebb0c
FreeFlow/FreeFlow/src/com/comcast/freeflow/core/FreeFlowContainer.java
Line 255 in 96ebb0c
But when requestLayout() is called while scrolling, onTouchEvent() is called before onMeasure() and it causes crash by IndexOutOfBoundsException in adapter implementation.
Note that ListView effectively avoids this problem by call layoutChildren() before applying scroll to view.
https://github.com/android/platform_frameworks_base/blob/android-5.1.1_r4/core/java/android/widget/AdapterView.java#L809
https://github.com/android/platform_frameworks_base/blob/android-5.1.1_r4/core/java/android/widget/AbsListView.java#L3763
https://github.com/android/platform_frameworks_base/blob/android-5.1.1_r4/core/java/android/widget/ListView.java#L1561
The text was updated successfully, but these errors were encountered: