Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Android and iOS adapters to handle null items sources #4536

Merged
merged 2 commits into from Nov 29, 2018

Conversation

@hartez
Copy link
Member

commented Nov 26, 2018

Description of Change

The CollectionView on Android and iOS throws an exception if no ItemsSource is set before the renderers kick in. This change allows both platforms to handle a null ItemsSource.

Issues Resolved

API Changes

None

Platforms Affected

  • iOS
  • Android

Behavioral/Visual Changes

None

Before/After Screenshots

Not applicable

Testing Procedure

In Control Gallery, navigate to CollectionViewGallery -> EmptyView Galleries -> EmptyView (null ItemsSource). Navigation should be successful and the application should not crash.

PR Checklist

  • Has automated tests
  • Rebased on top of the target branch at time of PR
  • Changes adhere to coding standard

@samhouts samhouts added the e/2 🕑 label Nov 27, 2018

@@ -9,6 +9,11 @@ internal static class ItemsSourceFactory
{
public static IItemsViewSource Create(IEnumerable itemsSource, RecyclerView.Adapter adapter)
{
if (itemsSource == null)
{
return new EmptySource();

This comment has been minimized.

Copy link
@StephaneDelcroix

StephaneDelcroix Nov 27, 2018

Member

you probably could return a shared instance, and avoid instantiation

@samhouts samhouts added this to In Review in v3.6.0 Nov 27, 2018

@samhouts samhouts added this to Ready for Review (PRs) in Sprint 145 Nov 27, 2018

@samhouts samhouts requested a review from mattleibow Nov 29, 2018

{
public int Count => 0;

public object this[int index] => throw new IndexOutOfRangeException("IItemsViewSource is empty");

This comment has been minimized.

Copy link
@mattleibow

mattleibow Nov 29, 2018

Contributor
Suggested change
public object this[int index] => throw new IndexOutOfRangeException("IItemsViewSource is empty");
public object this[int index] => throw new IndexOutOfRangeException("EmptySource is empty.");
{
public int Count => 0;

public object this[int index] => throw new IndexOutOfRangeException("IItemsViewSource is empty");

This comment has been minimized.

Copy link
@mattleibow

mattleibow Nov 29, 2018

Contributor
Suggested change
public object this[int index] => throw new IndexOutOfRangeException("IItemsViewSource is empty");
public object this[int index] => throw new IndexOutOfRangeException("EmptySource is empty.");

This comment has been minimized.

Copy link
@rmarinho

rmarinho Nov 29, 2018

Member

If it's a EmptySource that's what one would expect no ?

This comment has been minimized.

Copy link
@StephaneDelcroix

StephaneDelcroix Nov 29, 2018

Member

y, it's expected to get an exception.

@rmarinho rmarinho merged commit e6af1a5 into master Nov 29, 2018

8 of 10 checks passed

VSTS: Android API19 Validation Legacy Renderers UITests Finished
Details
VSTS: iOS11 Validation UITests Finished
Details
VSTS: Android API19 Validation Fast Renderers UITests Finished
Details
VSTS: Android API23 Validation Fast Renderers UITests Finished
Details
VSTS: Android API23 Validation Legacy Renderers UITests Finished
Details
VSTS: Android API25 Validation Fast Renderers UITests Finished
Details
VSTS: Android API25 Validation Legacy Renderers UITests Finished
Details
VSTS: iOS10 Validation UITests Finished
Details
Xamarin Forms #PR-4536 - (2241450) succeeded
Details
license/cla All CLA requirements met.
Details

v3.6.0 automation moved this from In Review to Done Nov 29, 2018

Sprint 145 automation moved this from Ready for Review (PRs) to Done Nov 29, 2018

@samhouts samhouts added this to the 4.0.0 milestone Dec 4, 2018

@hartez hartez deleted the fix-gh4366 branch Dec 5, 2018

@samhouts samhouts removed this from Done in v3.6.0 Jan 3, 2019

@samhouts samhouts modified the milestones: 4.0.0, 3.5.0 Jan 10, 2019

@samhouts samhouts added this to Done in v3.5.0 Jan 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.