Description
Create a CollectionView and bind it to an ObservableCollection filled with enough items so that the CollectionView can be scrolled. Use the UI to scroll down. Then, tap on a button that triggers the deletion of the content of the ObservableCollection and fills it with new items. Finally, programmatically scroll to the top of the CollectionView.
This is working, but triggers scary warnings.
Steps to Reproduce
await MainThread.InvokeOnMainThreadAsync(async () =>
{
//Clear and reload the content of the CollectionView by changing the content of the ObservableCollection bound to the items.
...
//Reset scroll position when filter is changed
MyCollectionView?.ScrollTo(0, position: ScrollToPosition.Start, animate: false);
});
Link to public reproduction project repository
No response
Version with bug
8.0.40 SR5
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android API 34
Did you find any workaround?
no
Relevant log output
6-13 08:27:10.872 W/RecyclerView( 8912): Cannot call this method in a scroll callback. Scroll callbacks mightbe run during a measure & layout pass where you cannot change theRecyclerView data. Any method call that might change the structureof the RecyclerView or the adapter contents should be postponed tothe next frame.
06-13 08:27:10.872 W/RecyclerView( 8912): java.lang.IllegalStateException: crc645d80431ce5f73f11.MauiRecyclerView_3{93ab91a VFED..... ......ID 0,0-1080,1679}, adapter:crc645d80431ce5f73f11.ReorderableItemsViewAdapter_2@4afb22, layout:androidx.recyclerview.widget.LinearLayoutManager@3ce958, context:crc640318137a80d29de8.MainActivity@87f00a5
06-13 08:27:10.872 W/RecyclerView( 8912): at androidx.recyclerview.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:3451)
06-13 08:27:10.872 W/RecyclerView( 8912): at androidx.recyclerview.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeChanged(RecyclerView.java:6025)
06-13 08:27:10.872 W/RecyclerView( 8912): at androidx.recyclerview.widget.RecyclerView$AdapterDataObservable.notifyItemRangeChanged(RecyclerView.java:13128)
06-13 08:27:10.872 W/RecyclerView( 8912): at androidx.recyclerview.widget.RecyclerView$AdapterDataObservable.notifyItemRangeChanged(RecyclerView.java:13118)
06-13 08:27:10.872 W/RecyclerView( 8912): at androidx.recyclerview.widget.RecyclerView$Adapter.notifyItemRangeChanged(RecyclerView.java:8067)
06-13 08:27:10.872 W/RecyclerView( 8912): at crc645d80431ce5f73f11.RecyclerViewScrollListener_2.n_onScrolled(Native Method)
06-13 08:27:10.872 W/RecyclerView( 8912): at crc645d80431ce5f73f11.RecyclerViewScrollListener_2.onScrolled(RecyclerViewScrollListener_2.java:30)
06-13 08:27:10.872 W/RecyclerView( 8912): at androidx.recyclerview.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:5642)
06-13 08:27:10.872 W/RecyclerView( 8912): at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:4700)
06-13 08:27:10.872 W/RecyclerView( 8912): at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4326)
06-13 08:27:10.872 W/RecyclerView( 8912): at androidx.recyclerview.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:2065)
06-13 08:27:10.872 W/RecyclerView( 8912): at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5743)
06-13 08:27:10.872 W/RecyclerView( 8912): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1339)
06-13 08:27:10.872 W/RecyclerView( 8912): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1348)
06-13 08:27:10.872 W/RecyclerView( 8912): at android.view.Choreographer.doCallbacks(Choreographer.java:952)
06-13 08:27:10.872 W/RecyclerView( 8912): at android.view.Choreographer.doFrame(Choreographer.java:878)
06-13 08:27:10.872 W/RecyclerView( 8912): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322)
06-13 08:27:10.872 W/RecyclerView( 8912): at android.os.Handler.handleCallback(Handler.java:958)
06-13 08:27:10.872 W/RecyclerView( 8912): at android.os.Handler.dispatchMessage(Handler.java:99)
06-13 08:27:10.872 W/RecyclerView( 8912): at android.os.Looper.loopOnce(Looper.java:205)
06-13 08:27:10.872 W/RecyclerView( 8912): at android.os.Looper.loop(Looper.java:294)
06-13 08:27:10.872 W/RecyclerView( 8912): at android.app.ActivityThread.main(ActivityThread.java:8177)
06-13 08:27:10.872 W/RecyclerView( 8912): at java.lang.reflect.Method.invoke(Native Method)
06-13 08:27:10.872 W/RecyclerView( 8912): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
06-13 08:27:10.872 W/RecyclerView( 8912): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Description
Create a CollectionView and bind it to an ObservableCollection filled with enough items so that the CollectionView can be scrolled. Use the UI to scroll down. Then, tap on a button that triggers the deletion of the content of the ObservableCollection and fills it with new items. Finally, programmatically scroll to the top of the CollectionView.
This is working, but triggers scary warnings.
Steps to Reproduce
Link to public reproduction project repository
No response
Version with bug
8.0.40 SR5
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android API 34
Did you find any workaround?
no
Relevant log output