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

Commit ec04308

Browse files
authored
Revert "[Android] fix item indices and item count in a ListView (#15306)"
This reverts commit 48a7087.
1 parent 93efb39 commit ec04308

File tree

6 files changed

+8
-94
lines changed

6 files changed

+8
-94
lines changed

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue15305.xaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue15305.xaml.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,9 +1864,6 @@
18641864
<Compile Include="$(MSBuildThisFileDirectory)Issue11954.cs" />
18651865
<Compile Include="$(MSBuildThisFileDirectory)Issue13918.xaml.cs" />
18661866
<Compile Include="$(MSBuildThisFileDirectory)Issue13794.cs" />
1867-
<Compile Include="$(MSBuildThisFileDirectory)Issue15305.xaml.cs">
1868-
<DependentUpon>Issue15305.xaml</DependentUpon>
1869-
</Compile>
18701867
<Compile Include="$(MSBuildThisFileDirectory)Controls\MyCollectionView.xaml.cs">
18711868
<DependentUpon>MyCollectionView.xaml</DependentUpon>
18721869
<SubType>Code</SubType>
@@ -2425,9 +2422,6 @@
24252422
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue13918.xaml">
24262423
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
24272424
</EmbeddedResource>
2428-
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue15305.xaml">
2429-
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
2430-
</EmbeddedResource>
24312425
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Controls\MyCollectionView.xaml">
24322426
<SubType>Designer</SubType>
24332427
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>

Xamarin.Forms.Platform.Android/CellAdapter.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,13 @@ bool AActionMode.ICallback.OnPrepareActionMode(AActionMode mode, IMenu menu)
132132

133133
public void OnItemClick(AdapterView parent, AView view, int position, long id)
134134
{
135-
var listView = parent as AListView;
136-
if (listView != null)
137-
position -= listView.HeaderViewsCount;
138-
139135
if (_actionMode != null || _supportActionMode != null)
136+
{
137+
var listView = parent as AListView;
138+
if (listView != null)
139+
position -= listView.HeaderViewsCount;
140140
HandleContextMode(view, position);
141+
}
141142
else
142143
HandleItemClick(parent, view, position, id);
143144
}

Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ protected override void HandleItemClick(AdapterView parent, AView view, int posi
481481
cell = (Cell)(cellOwner as INativeElementView)?.Element;
482482
}
483483

484+
// All our ListView's have called AddHeaderView. This effectively becomes index 0, so our index 0 is index 1 to the listView.
485+
position--;
486+
484487
if (position < 0 || position >= Count)
485488
return;
486489

Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,7 @@ void UpdateFooter()
365365
}
366366

367367
if (footer == null)
368-
{
369-
if (_footerView.ChildCount == 0)
370-
{
371-
AListView nativeListView = Control;
372-
nativeListView.RemoveFooterView(_adapter.FooterView);
373-
}
374368
return;
375-
}
376369

377370
if (_footerRenderer != null)
378371
_footerRenderer.SetElement(footer);
@@ -404,14 +397,7 @@ void UpdateHeader()
404397
}
405398

406399
if (header == null)
407-
{
408-
if (_headerView.ChildCount == 0)
409-
{
410-
AListView nativeListView = Control;
411-
nativeListView.RemoveHeaderView(_adapter.HeaderView);
412-
}
413400
return;
414-
}
415401

416402
if (_headerRenderer != null)
417403
_headerRenderer.SetElement(header);

0 commit comments

Comments
 (0)