Skip to content

Commit

Permalink
Commit before branching to test Sharpnado.CollectionView to attempt C…
Browse files Browse the repository at this point in the history
…ollectionView performance increase
  • Loading branch information
ReticentRobot committed Aug 31, 2023
1 parent cf88545 commit abcbf37
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 29 deletions.
7 changes: 5 additions & 2 deletions Disc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
<ApplicationId>com.reticentrobot.disc</ApplicationId>
<TrimMode>link</TrimMode>
<NoWarn>1701;1702</NoWarn>
<RunAOTCompilation>True</RunAOTCompilation>
<RunAOTCompilation>False</RunAOTCompilation>
<JavaMaximumHeapSize>2G</JavaMaximumHeapSize>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-maccatalyst|AnyCPU'">
Expand All @@ -61,7 +62,8 @@
<TrimMode>link</TrimMode>
<PublishTrimmed>True</PublishTrimmed>
<NoWarn>1701;1702</NoWarn>
<RunAOTCompilation>True</RunAOTCompilation>
<RunAOTCompilation>False</RunAOTCompilation>
<JavaMaximumHeapSize>2G</JavaMaximumHeapSize>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -118,6 +120,7 @@
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="110.2.0" />
<PackageReference Include="Sentry.Maui" Version="3.36.0" />
<PackageReference Include="Sharpnado.CollectionView.Maui" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 5 additions & 1 deletion MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CommunityToolkit.Maui;
using Disc.Services;
using Disc.Views;
using Sharpnado.CollectionView;
using System.Diagnostics;

namespace Disc;
Expand Down Expand Up @@ -38,7 +39,10 @@ public static MauiApp CreateMauiApp()
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
;
// Initialize SharpnadoCollectionVIew
.UseSharpnadoCollectionView(loggerEnable: false);
;

// TODO: Add light mode support, for now - setting app to always load in dark mode
// Application.Current.UserAppTheme = AppTheme.Dark;

Expand Down
5 changes: 3 additions & 2 deletions Platforms/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.reticentrobot.disc" android:versionCode="1" android:versionName=".01">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="Disc"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="33" />
</manifest>
2 changes: 1 addition & 1 deletion Platforms/Android/env.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MONO_GC_PARAMS=nursery-size=128m
MONO_GC_PARAMS=nursery-size=256m
6 changes: 0 additions & 6 deletions ViewModels/PostsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ public partial class PostsViewModel : BaseViewModel
// constructor to initialize objects
public PostsViewModel(IServiceProvider serviceProvider)
{
Debug.WriteLine("Setting _restService to restService");
_restService = serviceProvider.GetRequiredService<RestService>();

var client = _restService.client;
Debug.WriteLine("Client Value in constructor: " + client);

Posts = new ObservableCollection<Post>();
}

Expand All @@ -71,8 +67,6 @@ public async Task LoadPosts()

var request = new RestRequest(url);
var TotalPostsBeforePull = Posts.Count; //Total number of posts before pulling new posts

Debug.WriteLine("Client Value in LoadPosts: " + client); ;
var content = await _restService.client.GetAsync(request);

//set json options
Expand Down
42 changes: 25 additions & 17 deletions Views/HomePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
Order="Primary"
IconImageSource="icon_three_dots_darkmode.png" />
</ContentPage.ToolbarItems>

<CollectionView
x:Name="PostsCollection"
ItemsSource="{Binding Posts}"
ItemsSource="{Binding Posts, Mode=OneTime}"
BackgroundColor="{AppThemeBinding Light=AntiqueWhite, Dark=#1C1D20}"
RemainingItemsThreshold="5"
RemainingItemsThresholdReached="OnCollectionViewRemainingItemsThresholdReached"
Expand All @@ -42,10 +42,11 @@
<DataTemplate x:Name="CompactView" x:DataType="models:Post">
<Grid x:Name="PostsGrid"
RowSpacing="0"
ColumnSpacing="0">
ColumnSpacing="0"
>
<Grid.RowDefinitions>
<RowDefinition Height="7" />
<RowDefinition Height="Auto" />
<RowDefinition Height="40" />
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="25" />
Expand Down Expand Up @@ -78,7 +79,7 @@
WidthRequest="55"
>
<Image
Source="{Binding Link.Image.ImageUrl, StringFormat='https://discuit.net{0}'}"
Source="{Binding Link.Image.ImageUrl, StringFormat='https://discuit.net{0}', Mode=OneTime}"
Aspect="AspectFill"
HeightRequest="60"
WidthRequest="60"
Expand All @@ -90,15 +91,15 @@
<!-- Define a TapGestureRecognizer and handle its Tapped event -->
<TapGestureRecognizer
Tapped="OnTapGestureRecognizerTapped"
CommandParameter="{Binding Link.LinkUrl}"/>
CommandParameter="{Binding Link.LinkUrl, Mode=OneTime}"/>
</Image.GestureRecognizers>
</Image>
</Border>
<Label
Grid.Column="2"
Grid.Row="1"
FontSize="14"
Text="{Binding Title}"
Text="{Binding Title, Mode=OneTime}"
LineBreakMode="WordWrap"
MaxLines="2"
FontAttributes="None"
Expand All @@ -112,9 +113,11 @@
Padding="0">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding CommunityName}" FontSize="11" TextColor="{Binding CommunityName, Converter={StaticResource communityNameColor}}" />
<!--<Span Text="{Binding CommunityName}" FontSize="11" TextColor="{Binding CommunityName, Converter={StaticResource communityNameColor}}" />-->
<Span Text="{Binding CommunityName, Mode=OneTime}" FontSize="11" />
<Span Text="" TextColor="Grey" FontSize="11" />
<Span Text="{Binding Username}" FontSize="11" TextColor="{Binding Username, Converter={StaticResource usernameColor}}" />
<!--<Span Text="{Binding Username}" FontSize="11" TextColor="{Binding Username, Converter={StaticResource usernameColor}}" />-->
<Span Text="{Binding Username, Mode=OneTime}" FontSize="11" />
</FormattedString>
</Label.FormattedText>
</Label>
Expand All @@ -126,9 +129,10 @@
Padding="0">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding CreatedAt, Converter={StaticResource createdAt}}" FontSize="11" />
<!--<Span Text="{Binding CreatedAt, Converter={StaticResource createdAt}}" FontSize="11" />-->
<Span Text="{Binding CreatedAt, Mode=OneTime}" FontSize="11" />
<Span Text="" TextColor="Grey" FontSize="11" />
<Span Text="{Binding Link.Hostname}" FontSize="11" />
<Span Text="{Binding Link.Hostname, Mode=OneTime}" FontSize="11" />
</FormattedString>
</Label.FormattedText>
</Label>
Expand All @@ -148,7 +152,8 @@
</MultiBinding>
</Label.Text>
</Label>
<Image
<!--Source="{Binding Type, Converter={StaticResource typeToImage}}"-->
<!--<Image
Source="{Binding Type, Converter={StaticResource typeToImage}}"
Grid.Row="2"
Grid.RowSpan="2"
Expand All @@ -158,12 +163,12 @@
Aspect="AspectFill"
HeightRequest="20"
WidthRequest="20"
Margin="10,0,20,40" >
Margin="10,-30,20,20" >
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="White" />
</Image.Behaviors>
</Image>
<ImageButton
</Image>-->
<!--<ImageButton
Grid.Row="5"
Grid.RowSpan="2"
Grid.Column="4"
Expand All @@ -173,13 +178,14 @@
Aspect="AspectFill"
HeightRequest="20"
WidthRequest="20"
Margin="20,0,20,40"
Margin="20,10,20,10"
Clicked="OnChevronClicked"
>
<ImageButton.Behaviors>
<toolkit:IconTintColorBehavior TintColor="White" />
</ImageButton.Behaviors>
</ImageButton>
<Image
IsVisible="False"
Grid.Row="5"
Expand Down Expand Up @@ -239,7 +245,9 @@
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="White" />
</Image.Behaviors>
</Image>
</Image>-->


</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
Expand Down

0 comments on commit abcbf37

Please sign in to comment.