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

Revert "[Android] fix item indices and item count in a ListView" #15473

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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