Skip to content

Commit dbf7aad

Browse files
jsuarezruizGitHub Actions Autoformattermattleibowjfversluis
authored
[Android] Fix gif animation initial state (#14295)
* Fix gifs initial animation state on Android * Device tests * Auto-format source code * Updated sample * Updated device tests * Refactor code * Update src/Core/src/Handlers/Image/ImageHandler.Android.cs Co-authored-by: Matthew Leibowitz <[email protected]> * Remove unnecessary change * Fix build errors * Merge branch 'main' into fix-7019 * Fix merge mistake --------- Co-authored-by: GitHub Actions Autoformatter <[email protected]> Co-authored-by: Javier Suárez <[email protected]> Co-authored-by: Matthew Leibowitz <[email protected]> Co-authored-by: Gerald Versluis <[email protected]>
1 parent e01cee8 commit dbf7aad

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/Controls/samples/Controls.Sample/Pages/Controls/ImagePage.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@
4848
</FontImageSource>
4949
</Image.Source>
5050
</Image>
51+
<Label
52+
Text="Animating a gif"
53+
Style="{StaticResource Headline}"/>
54+
<Switch
55+
x:Name="IsAnimationPlayingSwitch"
56+
IsToggled="True"/>
57+
<Image
58+
Source="animated_heart.gif"
59+
WidthRequest="200"
60+
IsAnimationPlaying="{Binding Source={x:Reference IsAnimationPlayingSwitch},Path=IsToggled}" />
5161
<Label
5262
Text="Stream Source"
5363
Style="{StaticResource Headline}"/>

src/Core/src/Handlers/Image/ImageHandler.Android.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ public static void MapIsAnimationPlaying(IImageHandler handler, IImage image) =>
4848
public static void MapSource(IImageHandler handler, IImage image) =>
4949
MapSourceAsync(handler, image).FireAndForget(handler);
5050

51-
public static Task MapSourceAsync(IImageHandler handler, IImage image) =>
52-
handler.SourceLoader.UpdateImageSourceAsync();
51+
public static Task MapSourceAsync(IImageHandler handler, IImage image)
52+
{
53+
return handler
54+
.SourceLoader
55+
.UpdateImageSourceAsync()
56+
.ContinueWith((action) => handler.UpdateValue(nameof(IImage.IsAnimationPlaying)));
57+
}
5358

5459
public override void PlatformArrange(Graphics.Rect frame)
5560
{

src/Core/tests/DeviceTests/Handlers/Image/ImageHandlerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ await InvokeOnMainThreadAsync(async () =>
111111
}
112112

113113
[Theory(
114-
#if __IOS__ || __ANDROID__
115-
Skip = "Animated GIFs are not yet supported on iOS. Test failing on ANDROID"
114+
#if __ANDROID_23__ || __IOS__
115+
Skip = "Animated GIFs are not yet supported."
116116
#endif
117117
)]
118118
[InlineData("animated_heart.gif", true)]

0 commit comments

Comments
 (0)