roubachof / Sharpnado.CollectionView

A performant list view supporting: grid, horizontal and vertical layout, drag and drop, and reveal animations.
The Unlicense
244 stars 30 forks source link

CollectionView on android in tab view and shell tabs does not clear when refreshing items bound to ItemsSource #117

Open jjelecondev opened 4 months ago

jjelecondev commented 4 months ago

Describe the bug When CollectionView is displayed the first time, a ObservableCollection.Clear() followed by adding new items to the collection results in the view correctly refreshing. If the user navigates to another page in the tab view then back, the same action will cause the new items to prepend in the list and the "cleared" items never clear. We have found a similar problem with drop no longer working when navigating away and back.

In the attached repository, we are using multiple DataTemplates with a TemplateSelector.

To Reproduce

  1. run the example on android,
  2. navigate to page 2
  3. then back to page 1
  4. swipe down to refresh.

Exceptions (if applicable) None found. Just doesn't clear old items

Screenshots (if applicable) If applicable, add screenshots to help explain your problem.

roubachof commented 4 months ago

I tried to test the sample for a couple of hours but weird stuff happens:

  1. I cannot hit any breakpoint in the collection view renderer
  2. the binding on RefreshView seems broken (spinner spin forever)

I don't know if shell is broken or semothing.... Otherwise you could still try to create new collection instead of clearing it:

Feed.Clear() => Feed = new ObservableCollection<FeedItem>();

Oh and also you are misusing the refresh UI pattern, you should only clear the collecton if the reload if successful, cause if it's not (for example connection loss) you will end up with an empty list...

jjelecondev commented 4 months ago

Thanks, I'll take a look. I agree that things are a little weird. I did spin up that project just to share the problem so there was a little cut and paste and simplification involved.


From: Jean-Marie Alfonsi @.> Sent: Wednesday, April 24, 2024 3:32 AM To: roubachof/Sharpnado.CollectionView @.> Cc: JJ Stewart @.>; Author @.> Subject: Re: [roubachof/Sharpnado.CollectionView] CollectionView on android in tab view and shell tabs does not clear when refreshing items bound to ItemsSource (Issue #117)

I tried to test the sample for a couple of hours but weird stuff happens:

  1. I cannot hit any breakpoint in the collection view renderer
  2. the binding on RefreshView seems broken (spinner spin forever)

I don't know if shell is broken or semothing.... Otherwise you could still try to create new collection instead of clearing it:

Feed.Clear() => Feed = new ObservableCollection();

Oh and also you are misusing the refresh UI pattern, you should only clear the collecton if the reload if successful, cause if it's not (for example connection loss) you will end up with an empty list...

— Reply to this email directly, view it on GitHubhttps://github.com/roubachof/Sharpnado.CollectionView/issues/117#issuecomment-2074516633, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUE7ZMZZMGMKRFI37ZCYQJDY6532FAVCNFSM6AAAAABGVFVQA2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZUGUYTMNRTGM. You are receiving this because you authored the thread.Message ID: @.***>

jjelecondev commented 4 months ago

I committed an update that may fix your debug problems. (there was a remnant of a non-existent stylesheet that appeared to be causing problems)

I also found this: If I set the property AutoDisconnectHandler="False" in the xaml, the view appears to work correctly! What is this option supposed to do? Is this going to cause a memory leak or something if I set it to false?

roubachof commented 4 months ago

AutoDisconnectHandler is a property that can prevent some memory leak, but it's maybe a bit aggressive the way it cleans some views. I say leave AutoDisconnectHandler="False" if it fixes your problem, it's totally fin,e

On Wed, Apr 24, 2024 at 4:32 PM jjelecondev @.***> wrote:

I committed an update that may fix your debug problems. (there was a remnant of a non-existent stylesheet that appeared to be causing problems)

I also found this: If I set the property AutoDisconnectHandler="False" in the xaml, the view appears to work correctly! What is this option supposed to do? Is this going to cause a memory leak or something if I set it to false?

— Reply to this email directly, view it on GitHub https://github.com/roubachof/Sharpnado.CollectionView/issues/117#issuecomment-2075095044, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAERXJ5GRKZZSGBCB4BTYUTY667APAVCNFSM6AAAAABGVFVQA2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZVGA4TKMBUGQ . You are receiving this because you commented.Message ID: @.***>

jjelecondev commented 4 months ago

Well this is good to know. I guess we can take note that android seems to have an issue on a persistent shell tab when navigating away and back when this option is set to true. I will leave it to you to decide whether it deserves a code fix. Thanks for your help.