Skip to content

Commit

Permalink
Fix [Android] CollectionView EmptyView SelectionMode=Single on Android (
Browse files Browse the repository at this point in the history
#9215) Fixes #9060

* Fixed null reference when we have EmptyView and SelectionMode = signle

* Moved null check out of loop

* Moved adapter null check to the begging of the method
  • Loading branch information
yurkinh authored and PureWeen committed Aug 11, 2022
1 parent d7b3548 commit 12c17be
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public static void UpdateSelection(this RecyclerView recyclerView, SelectableIte
var mode = selectableItemsView.SelectionMode;
//TODO: on NET7 implement a ISelectableItemsViewAdapter interface on the adapter
var adapter = recyclerView.GetAdapter() as ReorderableItemsViewAdapter<ReorderableItemsView, IGroupableItemsViewSource>;
adapter?.ClearPlatformSelection();
if (adapter == null)
return;

adapter.ClearPlatformSelection();

switch (mode)
{
Expand All @@ -25,13 +28,12 @@ public static void UpdateSelection(this RecyclerView recyclerView, SelectableIte
adapter.MarkPlatformSelection(selectedItem);
return;

case SelectionMode.Multiple:
var selectedItems = selectableItemsView.SelectedItems;

foreach (var item in selectedItems)
{
adapter.MarkPlatformSelection(item);
}
case SelectionMode.Multiple:
var selectedItems = selectableItemsView.SelectedItems;
foreach (var item in selectedItems)
{
adapter.MarkPlatformSelection(item);
}
return;
}
}
Expand Down

0 comments on commit 12c17be

Please sign in to comment.