Skip to content

Commit 5d0665a

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 5757161 + 7d636df commit 5d0665a

File tree

5 files changed

+55
-11
lines changed

5 files changed

+55
-11
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="AuroraControls.TestApp.GridImagePage">
5+
<Grid>
6+
<Grid.RowDefinitions>
7+
<RowDefinition Height="auto" />
8+
<RowDefinition Height="*" />
9+
<RowDefinition Height="auto" />
10+
</Grid.RowDefinitions>
11+
<Grid.ColumnDefinitions>
12+
<ColumnDefinition Width="auto" />
13+
<ColumnDefinition Width="*" />
14+
<ColumnDefinition Width="auto" />
15+
</Grid.ColumnDefinitions>
16+
<Image x:Name="img" Grid.Row="0" Grid.Column="0" Aspect="Center" BackgroundColor="Fuchsia" />
17+
<ImageButton x:Name="imgBtn" Grid.Row="2" Grid.Column="2" Aspect="Center" BackgroundColor="Chartreuse" />
18+
</Grid>
19+
</ContentPage>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.Maui.Controls;
2+
3+
namespace AuroraControls.TestApp;
4+
5+
public partial class GridImagePage : ContentPage
6+
{
7+
public GridImagePage()
8+
{
9+
InitializeComponent();
10+
11+
img.SetSvgIcon("dollar_sign.svg", 74);
12+
imgBtn.SetSvgIcon("dollar_sign.svg", 74);
13+
}
14+
}

AuroraControls.TestApp/MainPage.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public MainPage(ILogger<TestRxViewModel> logger)
104104
Children =
105105
{
106106
new Button { BackgroundColor = Colors.Fuchsia, }
107-
.SetSvgIcon("splatoon.svg", 40, colorOverride: Colors.White),
107+
.SetSvgIcon("dollar_sign.svg", 75, colorOverride: Colors.White),
108108

109109
new Button { Text = "View Image Processing", }
110110
.BindClicked(async () => await this.Navigation.PushAsync(new ImageProcessing()))
@@ -173,6 +173,10 @@ await this.Navigation.PushAsync(new StepIndicatorTestPage())),
173173
.BindClicked(async () =>
174174
await this.Navigation.PushAsync(new ConfettiViewTestPage())),
175175

176+
new Button { Text = "Grid Image Page", }
177+
.BindClicked(async () =>
178+
await this.Navigation.PushAsync(new GridImagePage())),
179+
176180
new ToggleBox
177181
{
178182
ToggledBackgroundColor = Colors.Fuchsia,
Lines changed: 3 additions & 0 deletions
Loading

AuroraControlsMaui/Platforms/Android/NoCacheFileImageSourceService.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Threading;
44
using System.Threading.Tasks;
55
using Android.Content;
6+
using Android.Graphics;
67
using Android.Graphics.Drawables;
78
using Android.Widget;
89
using Bumptech.Glide;
@@ -11,12 +12,13 @@
1112
using Microsoft.Extensions.Logging;
1213
using Microsoft.Maui.Controls.PlatformConfiguration;
1314
using Microsoft.Maui.Platform;
15+
using Path = System.IO.Path;
1416

1517
namespace AuroraControls;
1618

1719
internal partial class NoCacheFileImageSourceService
1820
{
19-
public override Task<IImageSourceServiceResult?> LoadDrawableAsync(IImageSource imageSource, ImageView imageView,
21+
public override async Task<IImageSourceServiceResult?> LoadDrawableAsync(IImageSource imageSource, ImageView imageView,
2022
CancellationToken cancellationToken = default)
2123
{
2224
var fileImageSource = (INoCacheFileImageSource)imageSource;
@@ -33,14 +35,15 @@ internal partial class NoCacheFileImageSourceService
3335
if (id > 0)
3436
{
3537
imageView.SetImageResource(id);
36-
return Task.FromResult<IImageSourceServiceResult?>(new ImageSourceServiceLoadResult());
38+
return new ImageSourceServiceLoadResult();
3739
}
3840
}
3941

40-
using var pathDrawable = Drawable.CreateFromPath(file);
42+
using var pathBitmap = await BitmapFactory.DecodeFileAsync(file);
43+
using var pathDrawable = new BitmapDrawable(Platform.AppContext.Resources, pathBitmap);
4144
imageView.SetImageDrawable(pathDrawable);
4245

43-
return Task.FromResult<IImageSourceServiceResult?>(new ImageSourceServiceLoadResult());
46+
return new ImageSourceServiceLoadResult();
4447
}
4548
catch (Exception ex)
4649
{
@@ -49,10 +52,10 @@ internal partial class NoCacheFileImageSourceService
4952
}
5053
}
5154

52-
return Task.FromResult<IImageSourceServiceResult?>(null);
55+
return null;
5356
}
5457

55-
public override Task<IImageSourceServiceResult<Drawable>?> GetDrawableAsync(IImageSource imageSource, Context context,
58+
public override async Task<IImageSourceServiceResult<Drawable>?> GetDrawableAsync(IImageSource imageSource, Context context,
5659
CancellationToken cancellationToken = default)
5760
{
5861
var fileImageSource = (INoCacheFileImageSource)imageSource;
@@ -70,13 +73,14 @@ internal partial class NoCacheFileImageSourceService
7073
var d = context?.GetDrawable(id);
7174
if (d is not null)
7275
{
73-
return Task.FromResult<IImageSourceServiceResult<Drawable>?>(new ImageSourceServiceResult(d));
76+
return new ImageSourceServiceResult(d);
7477
}
7578
}
7679
}
7780

78-
var pathDrawable = Drawable.CreateFromPath(file);
79-
return Task.FromResult<IImageSourceServiceResult<Drawable>?>(new ImageSourceServiceResult(pathDrawable));
81+
var pathBitmap = await BitmapFactory.DecodeFileAsync(file);
82+
var pathDrawable = new BitmapDrawable(Platform.AppContext.Resources, pathBitmap);
83+
return new ImageSourceServiceResult(pathDrawable);
8084
}
8185
catch (Exception ex)
8286
{
@@ -85,7 +89,7 @@ internal partial class NoCacheFileImageSourceService
8589
}
8690
}
8791

88-
return Task.FromResult<IImageSourceServiceResult<Drawable>?>(null);
92+
return null;
8993
}
9094
}
9195

0 commit comments

Comments
 (0)