summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
authorkingces95 <kingces95@users.noreply.github.com>2017-10-04 06:47:21 -0400
committerKangho Hur <kangho.hur@samsung.com>2017-10-23 13:33:59 +0900
commit8330619c143fff044032f40b702a823f16643a26 (patch)
tree8d0fb70eee07ffb5572a516c0ed6bc285bb2dba9 /Xamarin.Forms.Platform.Android
parent21b57d811b75440c4cc954074f95c981e30f3ad0 (diff)
downloadxamarin-forms-8330619c143fff044032f40b702a823f16643a26.tar.gz
xamarin-forms-8330619c143fff044032f40b702a823f16643a26.tar.bz2
xamarin-forms-8330619c143fff044032f40b702a823f16643a26.zip
Revert "Prototypical Cell Cache for IsEnabled testing; UITest" (#1156)
This reverts commit _52487.
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs78
1 files changed, 12 insertions, 66 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs b/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs
index e3dd01ba..bf678236 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs
@@ -9,7 +9,6 @@ using Android.Widget;
using AView = Android.Views.View;
using AListView = Android.Widget.ListView;
using Xamarin.Forms.Internals;
-using System.Collections;
namespace Xamarin.Forms.Platform.Android
{
@@ -33,7 +32,7 @@ namespace Xamarin.Forms.Platform.Android
// To prevent a conflict in the event that a ListView supports both templates and non-templates, we will start the DataTemplate key at 2.
int _listCount = -1; // -1 we need to get count from the list
- Dictionary<object, Cell> _prototypicalCellByTypeOrDataTemplate;
+ Cell _enabledCheckCell;
bool _fromNative;
AView _lastSelected;
@@ -47,7 +46,6 @@ namespace Xamarin.Forms.Platform.Android
_context = context;
_realListView = realListView;
_listView = listView;
- _prototypicalCellByTypeOrDataTemplate = new Dictionary<object, Cell>();
if (listView.SelectedItem != null)
SelectItem(listView.SelectedItem);
@@ -311,68 +309,6 @@ namespace Xamarin.Forms.Platform.Android
return layout;
}
- internal void InvalidatePrototypicalCellCache()
- {
- _prototypicalCellByTypeOrDataTemplate.Clear();
- }
-
- internal ITemplatedItemsList<Cell> GetTemplatedItemsListForPath(int indexPath)
- {
- var templatedItems = TemplatedItemsView.TemplatedItems;
- if (_listView.IsGroupingEnabled)
- templatedItems = (ITemplatedItemsList<Cell>)((IList)templatedItems)[indexPath];
-
- return templatedItems;
- }
-
- internal DataTemplate GetDataTemplateForPath(int indexPath)
- {
- var templatedItemsList = GetTemplatedItemsListForPath(indexPath);
- var item = templatedItemsList.ListProxy[indexPath];
- return templatedItemsList.SelectDataTemplate(item);
- }
-
- internal Type GetItemTypeForPath(int indexPath)
- {
- var templatedItemsList = GetTemplatedItemsListForPath(indexPath);
- var item = templatedItemsList.ListProxy[indexPath];
- return item.GetType();
- }
-
- internal Cell GetCellForPath(int indexPath)
- {
- var templatedItemsList = GetTemplatedItemsListForPath(indexPath);
- var cell = templatedItemsList[indexPath];
- return cell;
- }
-
- internal Cell GetPrototypicalCell(int indexPath)
- {
- var itemTypeOrDataTemplate = default(object);
-
- var cachingStrategy = _listView.CachingStrategy;
- if (cachingStrategy == ListViewCachingStrategy.RecycleElement)
- itemTypeOrDataTemplate = GetDataTemplateForPath(indexPath);
-
- else if (cachingStrategy == ListViewCachingStrategy.RecycleElementAndDataTemplate)
- itemTypeOrDataTemplate = GetItemTypeForPath(indexPath);
-
- else // ListViewCachingStrategy.RetainElement
- return GetCellForPosition(indexPath);
-
- Cell protoCell;
- if (!_prototypicalCellByTypeOrDataTemplate.TryGetValue(itemTypeOrDataTemplate, out protoCell))
- {
- // cache prototypical cell by item type; Items of the same Type share
- // the same DataTemplate (this is enforced by RecycleElementAndDataTemplate)
- protoCell = GetCellForPosition(indexPath);
- _prototypicalCellByTypeOrDataTemplate[itemTypeOrDataTemplate] = protoCell;
- }
-
- var templatedItems = GetTemplatedItemsListForPath(indexPath);
- return templatedItems.UpdateContent(protoCell, indexPath);
- }
-
public override bool IsEnabled(int position)
{
ListView list = _listView;
@@ -385,7 +321,17 @@ namespace Xamarin.Forms.Platform.Android
return leftOver > 0;
}
- Cell item = GetPrototypicalCell(position);
+ var strategy = ((IListViewController)list).CachingStrategy;
+ if ((strategy & ListViewCachingStrategy.RecycleElement) != 0)
+ {
+ if (_enabledCheckCell == null)
+ _enabledCheckCell = GetCellForPosition(position);
+ else
+ templatedItemsView.TemplatedItems.UpdateContent(_enabledCheckCell, position);
+ return _enabledCheckCell.IsEnabled;
+ }
+
+ Cell item = GetCellForPosition(position);
return item.IsEnabled;
}