Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Use bitwise ops on caching strategy in ListViewAdapter.cs (#1149)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingces95 authored and rmarinho committed Sep 19, 2017
1 parent 0092456 commit 78b8be1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public override AView GetView(int position, AView convertView, ViewGroup parent)
else
layout = new ConditionalFocusLayout(_context) { Orientation = Orientation.Vertical };

if (cachingStrategy == ListViewCachingStrategy.RecycleElement && convertView != null)
if (((cachingStrategy & ListViewCachingStrategy.RecycleElement) != 0) && convertView != null)
{
var boxedCell = convertView as INativeElementView;
if (boxedCell == null)
Expand Down Expand Up @@ -321,7 +321,8 @@ public override bool IsEnabled(int position)
return leftOver > 0;
}

if (((IListViewController)list).CachingStrategy == ListViewCachingStrategy.RecycleElement)
var strategy = ((IListViewController)list).CachingStrategy;
if ((strategy & ListViewCachingStrategy.RecycleElement) != 0)
{
if (_enabledCheckCell == null)
_enabledCheckCell = GetCellForPosition(position);
Expand Down Expand Up @@ -375,7 +376,7 @@ protected override void HandleItemClick(AdapterView parent, AView view, int posi
{
Cell cell = null;

if (Controller.CachingStrategy == ListViewCachingStrategy.RecycleElement)
if ((Controller.CachingStrategy & ListViewCachingStrategy.RecycleElement) != 0)
{
AView cellOwner = view;
var layout = cellOwner as ConditionalFocusLayout;
Expand Down Expand Up @@ -461,7 +462,8 @@ List<Cell> GetCellsFromPosition(int position, int take)
if (global == position || cells.Count > 0)
{
//Always create a new cell if we are using the RecycleElement strategy
var headerCell = _listView.CachingStrategy == ListViewCachingStrategy.RecycleElement ? GetNewGroupHeaderCell(group) : group.HeaderContent;
var recycleElement = (_listView.CachingStrategy & ListViewCachingStrategy.RecycleElement) != 0;
var headerCell = recycleElement ? GetNewGroupHeaderCell(group) : group.HeaderContent;
cells.Add(headerCell);

if (cells.Count == take)
Expand Down

0 comments on commit 78b8be1

Please sign in to comment.