Skip to content

Commit 9185419

Browse files
committed
added .net 9 support
1 parent 901f858 commit 9185419

File tree

4 files changed

+33
-18
lines changed

4 files changed

+33
-18
lines changed

MPowerKit.VirtualizeListView/Layouts/VirtualizeItemsLayoutManger.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -594,13 +594,11 @@ protected virtual void UpdateItemsLayout(int fromPosition, bool shouldAdjustScro
594594
#endif
595595
}
596596

597-
598-
599597
protected virtual void DetachCell(VirtualizeListViewItem item)
600598
{
601599
if (!item.IsAttached || item.Cell is null) return;
602600

603-
Adapter!.OnCellRecycled(item.Cell!, item.AdapterItem, item.Position);
601+
Adapter!.OnCellRecycled(item.Cell!, item.AdapterItem!, item.Position);
604602

605603
CacheCell(item);
606604
}
@@ -614,7 +612,7 @@ protected virtual void CacheCell(VirtualizeListViewItem item)
614612
cell.TranslationX = CachedItemsCoords;
615613
cell.TranslationY = CachedItemsCoords;
616614

617-
CachedCells.Add((item.Template, cell));
615+
CachedCells.Add((item.Template!, cell));
618616
item.Cell = null;
619617
}
620618

@@ -626,7 +624,7 @@ protected virtual void ReuseCell(VirtualizeListViewItem item, bool createNewIfNo
626624
return;
627625
}
628626

629-
var freeCell = CachedCells.LastOrDefault(i => (i.Template as IDataTemplateController).Id == (item.Template as IDataTemplateController).Id);
627+
var freeCell = CachedCells.LastOrDefault(i => (i.Template as IDataTemplateController).Id == (item.Template as IDataTemplateController)!.Id);
630628
if (freeCell != default)
631629
{
632630
CachedCells.Remove(freeCell);
@@ -642,7 +640,7 @@ protected virtual void ReuseCell(VirtualizeListViewItem item, bool createNewIfNo
642640
else
643641
{
644642
var freeItem = LaidOutItems.FirstOrDefault(i =>
645-
(i.Template as IDataTemplateController).Id == (item.Template as IDataTemplateController).Id
643+
(i.Template as IDataTemplateController)!.Id == (item.Template as IDataTemplateController)!.Id
646644
&& !i.IsAttached && !i.IsOnScreen && i.Cell is not null);
647645
if (freeItem is not null)
648646
{
@@ -652,12 +650,12 @@ protected virtual void ReuseCell(VirtualizeListViewItem item, bool createNewIfNo
652650
}
653651
else if (createNewIfNoCached)
654652
{
655-
item.Cell = Adapter!.OnCreateCell(item.Template, item.Position);
653+
item.Cell = Adapter!.OnCreateCell(item.Template!, item.Position);
656654
this.Add(item.Cell);
657655
}
658656
}
659657

660-
Adapter!.OnBindCell(item.Cell!, item.AdapterItem, item.Position);
658+
Adapter!.OnBindCell(item.Cell!, item.AdapterItem!, item.Position);
661659

662660
ArrangeItem(LaidOutItems, item, availableSpace);
663661
}
@@ -788,7 +786,12 @@ protected virtual Size GetDesiredLayoutSize(double widthConstraint, double heigh
788786
protected abstract bool AdjustScrollIfNeeded(IReadOnlyList<VirtualizeListViewItem> items, VirtualizeListViewItem item, Rect prevBoundsOfItem);
789787

790788
#region ILayoutManager
791-
public virtual Size Measure(double widthConstraint, double heightConstraint)
789+
Size ILayoutManager.Measure(double widthConstraint, double heightConstraint)
790+
{
791+
return LayoutManagerMeasure(widthConstraint, heightConstraint);
792+
}
793+
794+
public virtual Size LayoutManagerMeasure(double widthConstraint, double heightConstraint)
792795
{
793796
var items = CollectionsMarshal.AsSpan((this as IBindableLayout).Children as List<IView>);
794797
var length = items.Length;

MPowerKit.VirtualizeListView/MPowerKit.VirtualizeListView.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
5-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.22621.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst;net9.0;net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.22621.0;net9.0-windows10.0.26100.0</TargetFrameworks>
66

77
<UseMaui>true</UseMaui>
88
<SingleProject>true</SingleProject>
99
<ImplicitUsings>enable</ImplicitUsings>
1010
<Nullable>enable</Nullable>
11-
<MauiVersion>8.0.3</MauiVersion>
1211

1312
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
1413
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
@@ -20,7 +19,7 @@
2019

2120
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
2221
<Title>MPowerKit.VirtualizeListView</Title>
23-
<Version>2.3.2</Version>
22+
<Version>2.4.0</Version>
2423
<Authors>MPowerKit,Alex Dobrynin</Authors>
2524
<Description>MAUI Virtualize ListView with smooth scrolling and without platform-specific code</Description>
2625
<Copyright>MPowerKit</Copyright>

MPowerKit.VirtualizeListView/VirtualizeListViewItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public VirtualizeListViewItem(VirtualizeItemsLayoutManger layoutManager)
1616
public int Position { get; set; } = -1;
1717
public virtual bool IsOnScreen => IntersectsWithScrollVisibleRect();
1818
public bool IsAttached => Cell?.Attached ?? false;
19-
public DataTemplate Template { get; set; }
20-
public AdapterItem AdapterItem { get; set; }
19+
public DataTemplate? Template { get; set; }
20+
public AdapterItem? AdapterItem { get; set; }
2121
public CellHolder? Cell
2222
{
2323
get => _cell;

Sample/Sample.csproj

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
5-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.22621.0</TargetFrameworks>
4+
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.22621.0</TargetFrameworks>
66
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
77
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
88

@@ -19,7 +19,6 @@
1919
<SingleProject>true</SingleProject>
2020
<ImplicitUsings>enable</ImplicitUsings>
2121
<Nullable>enable</Nullable>
22-
<!--<MauiVersion>8.0.90-ci.*</MauiVersion>-->
2322

2423
<!-- Display name -->
2524
<ApplicationTitle>Sample</ApplicationTitle>
@@ -38,6 +37,20 @@
3837
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
3938
</PropertyGroup>
4039

40+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net9.0-android|AnyCPU'">
41+
<RuntimeIdentifiers>android-arm;android-arm64;android-x86;android-x64</RuntimeIdentifiers>
42+
<JavaMaximumHeapSize>3G</JavaMaximumHeapSize>
43+
<AndroidDexTool>d8</AndroidDexTool>
44+
<AndroidUseAapt2>true</AndroidUseAapt2>
45+
</PropertyGroup>
46+
47+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net9.0-android|AnyCPU'">
48+
<RuntimeIdentifiers>android-arm;android-arm64;android-x86;android-x64</RuntimeIdentifiers>
49+
<DebugSymbols>False</DebugSymbols>
50+
<JavaMaximumHeapSize>2G</JavaMaximumHeapSize>
51+
<AndroidLinkTool>r8</AndroidLinkTool>
52+
</PropertyGroup>
53+
4154
<ItemGroup>
4255
<!-- App Icon -->
4356
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

0 commit comments

Comments
 (0)