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

Commit

Permalink
Revert "[Android] fix item indices and item count in a ListView (#15306
Browse files Browse the repository at this point in the history
…)" (#15473)

This reverts commit 48a7087.
  • Loading branch information
jfversluis committed Jul 14, 2022
1 parent 93efb39 commit 04ace58
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 94 deletions.

This file was deleted.

This file was deleted.

Expand Up @@ -1864,9 +1864,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue11954.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13918.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13794.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue15305.xaml.cs">
<DependentUpon>Issue15305.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Controls\MyCollectionView.xaml.cs">
<DependentUpon>MyCollectionView.xaml</DependentUpon>
<SubType>Code</SubType>
Expand Down Expand Up @@ -2425,9 +2422,6 @@
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue13918.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue15305.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Controls\MyCollectionView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
Expand Down
9 changes: 5 additions & 4 deletions Xamarin.Forms.Platform.Android/CellAdapter.cs
Expand Up @@ -132,12 +132,13 @@ bool AActionMode.ICallback.OnPrepareActionMode(AActionMode mode, IMenu menu)

public void OnItemClick(AdapterView parent, AView view, int position, long id)
{
var listView = parent as AListView;
if (listView != null)
position -= listView.HeaderViewsCount;

if (_actionMode != null || _supportActionMode != null)
{
var listView = parent as AListView;
if (listView != null)
position -= listView.HeaderViewsCount;
HandleContextMode(view, position);
}
else
HandleItemClick(parent, view, position, id);
}
Expand Down
3 changes: 3 additions & 0 deletions Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs
Expand Up @@ -481,6 +481,9 @@ protected override void HandleItemClick(AdapterView parent, AView view, int posi
cell = (Cell)(cellOwner as INativeElementView)?.Element;
}

// All our ListView's have called AddHeaderView. This effectively becomes index 0, so our index 0 is index 1 to the listView.
position--;

if (position < 0 || position >= Count)
return;

Expand Down
14 changes: 0 additions & 14 deletions Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs
Expand Up @@ -365,14 +365,7 @@ void UpdateFooter()
}

if (footer == null)
{
if (_footerView.ChildCount == 0)
{
AListView nativeListView = Control;
nativeListView.RemoveFooterView(_adapter.FooterView);
}
return;
}

if (_footerRenderer != null)
_footerRenderer.SetElement(footer);
Expand Down Expand Up @@ -404,14 +397,7 @@ void UpdateHeader()
}

if (header == null)
{
if (_headerView.ChildCount == 0)
{
AListView nativeListView = Control;
nativeListView.RemoveHeaderView(_adapter.HeaderView);
}
return;
}

if (_headerRenderer != null)
_headerRenderer.SetElement(header);
Expand Down

0 comments on commit 04ace58

Please sign in to comment.