Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
This commit is contained in:
Родитель
1201314424
Коммит
59a8d4d7ea
|
@ -49,6 +49,7 @@ using Android.Support.V4.Content;
|
|||
[assembly: ExportRenderer(typeof(ShellGestures.TouchTestView), typeof(ShellGesturesTouchTestViewRenderer))]
|
||||
[assembly: ExportRenderer(typeof(Issue7249Switch), typeof(Issue7249SwitchRenderer))]
|
||||
[assembly: ExportRenderer(typeof(Issue9360.Issue9360NavigationPage), typeof(Issue9360NavigationPageRenderer))]
|
||||
[assembly: ExportRenderer(typeof(Issue8801.PopupStackLayout), typeof(CustomStackLayoutRenderer))]
|
||||
|
||||
#if PRE_APPLICATION_CLASS
|
||||
#elif FORMS_APPLICATION_ACTIVITY
|
||||
|
@ -57,6 +58,24 @@ using Android.Support.V4.Content;
|
|||
#endif
|
||||
namespace Xamarin.Forms.ControlGallery.Android
|
||||
{
|
||||
public class CustomStackLayoutRenderer : VisualElementRenderer<StackLayout>
|
||||
{
|
||||
public CustomStackLayoutRenderer(Context context) : base(context)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void AddView(global::Android.Views.View child)
|
||||
{
|
||||
if (child is global::Android.Widget.Button head && (head.Text == "Show" || head.Text == "Hide"))
|
||||
{
|
||||
base.AddView(child);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class Issue9360NavigationPageRenderer : Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer
|
||||
{
|
||||
public Issue9360NavigationPageRenderer(Context context) : base(context)
|
||||
|
|
|
@ -0,0 +1,312 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
|
||||
#if UITEST
|
||||
using Xamarin.UITest;
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Forms.Core.UITests;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 8801, "[Android] Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference",
|
||||
PlatformAffected.Android, navigationBehavior: NavigationBehavior.SetApplicationRoot)]
|
||||
public class Issue8801 : TestContentPage
|
||||
{
|
||||
View[] _elements = null;
|
||||
protected override void Init()
|
||||
{
|
||||
_elements = new View[]
|
||||
{
|
||||
new Button() { Text = "Edit", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start },
|
||||
new Button() { Text = "Save" , HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start},
|
||||
new Button() { Text = "Cancel", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start },
|
||||
new Label() { Text = "Some Label", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start },
|
||||
new Label() { Text = "Success", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start },
|
||||
};
|
||||
|
||||
var layout = new PopupStackLayout()
|
||||
{
|
||||
};
|
||||
|
||||
foreach (View element in _elements)
|
||||
layout.Children.Add(element);
|
||||
|
||||
var grid = new Grid()
|
||||
{
|
||||
Children = {
|
||||
layout
|
||||
}
|
||||
};
|
||||
|
||||
grid.AddChild(new Label() { Text = "Success" }, 0, 0);
|
||||
grid.AddChild(layout, 0, 1);
|
||||
|
||||
Content = grid;
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
foreach (var button in _elements.OfType<Button>())
|
||||
{
|
||||
button.Text += "changed";
|
||||
}
|
||||
|
||||
foreach (var label in _elements.OfType<Label>())
|
||||
{
|
||||
if (label.Text != "Success")
|
||||
label.Text += "changed";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface IViewPositionService
|
||||
{
|
||||
Point GetRelativePosition(VisualElement subView, VisualElement parent);
|
||||
}
|
||||
|
||||
public class PopupStackLayout : StackLayout, INotifyPropertyChanged
|
||||
{
|
||||
private static readonly Guid PageRootGridId = Guid.NewGuid();
|
||||
private readonly Guid ShowButtonId = Guid.NewGuid();
|
||||
private readonly IViewPositionService viewPositionService;
|
||||
private readonly StackLayout popupStack;
|
||||
private ContentPage rootPage;
|
||||
private Button showButton;
|
||||
|
||||
public PopupStackLayout()
|
||||
{
|
||||
this.viewPositionService = DependencyService.Get<IViewPositionService>();
|
||||
this.BackgroundColor = Color.Red;
|
||||
|
||||
showButton = new Button()
|
||||
{
|
||||
Text = "Show",
|
||||
AutomationId = ShowButtonId.ToString(),
|
||||
Command = new Command(ImageButtonCommandAsync)
|
||||
};
|
||||
|
||||
popupStack = new StackLayout()
|
||||
{
|
||||
BindingContext = this.BindingContext,
|
||||
AutomationId = Guid.NewGuid().ToString(),
|
||||
BackgroundColor = Color.Blue,
|
||||
IsVisible = false,
|
||||
Margin = this.Margin,
|
||||
HorizontalOptions = LayoutOptions.Start,
|
||||
VerticalOptions = LayoutOptions.Start,
|
||||
Orientation = this.Orientation,
|
||||
WidthRequest = Device.RuntimePlatform == Device.UWP ? 20 : 50,
|
||||
};
|
||||
|
||||
this.SetBinding(HeightRequestProperty, new Binding(nameof(Height), BindingMode.OneWay, source: showButton));
|
||||
this.SetBinding(WidthRequestProperty, new Binding(nameof(Width), BindingMode.OneWay, source: showButton));
|
||||
|
||||
this.Children.Insert(0, showButton);
|
||||
}
|
||||
|
||||
|
||||
private bool isOpen = false;
|
||||
public bool IsOpen
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.isOpen;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.isOpen)
|
||||
{
|
||||
this.isOpen = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CloseAsync()
|
||||
{
|
||||
if (popupStack.IsVisible)
|
||||
{
|
||||
await popupStack.FadeTo(0, 100, Easing.Linear);
|
||||
popupStack.IsVisible = false;
|
||||
IsOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
|
||||
{
|
||||
var sizeRequest = base.OnMeasure(widthConstraint, heightConstraint);
|
||||
|
||||
PositionStack();
|
||||
|
||||
return sizeRequest;
|
||||
|
||||
}
|
||||
|
||||
protected override void OnChildAdded(Element child)
|
||||
{
|
||||
if (child != showButton && child is Button button)
|
||||
{
|
||||
if (Device.RuntimePlatform == Device.Android)
|
||||
{
|
||||
button.Clicked -= PopupStackLayout_Clicked;
|
||||
button.Clicked += PopupStackLayout_Clicked;
|
||||
}
|
||||
|
||||
popupStack.Children.Add((View)child);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnChildAdded(child);
|
||||
}
|
||||
}
|
||||
|
||||
private async void PopupStackLayout_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
await popupStack.FadeTo(0, 50, Easing.Linear);
|
||||
popupStack.IsVisible = false;
|
||||
|
||||
popupStack.IsVisible = true;
|
||||
await popupStack.FadeTo(1, 50, Easing.Linear);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override void LayoutChildren(double x, double y, double width, double height)
|
||||
{
|
||||
if (rootPage == null)
|
||||
{
|
||||
var page = Navigation.NavigationStack.LastOrDefault();
|
||||
rootPage = GetRootPage(page);
|
||||
}
|
||||
|
||||
if (rootPage != null)
|
||||
|
||||
{
|
||||
if (rootPage.Content.AutomationId != PageRootGridId.ToString())
|
||||
{
|
||||
var rootGrid = new Grid() { AutomationId = PageRootGridId.ToString() };
|
||||
var content = rootPage.Content;
|
||||
rootPage.Content = null;
|
||||
rootGrid.Children.Add(content);
|
||||
content.Parent = rootGrid;
|
||||
|
||||
rootGrid.Children.Add(popupStack);
|
||||
popupStack.Parent = rootGrid;
|
||||
rootPage.Content = rootGrid;
|
||||
rootGrid.Parent = rootPage;
|
||||
|
||||
rootGrid.RaiseChild(popupStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
var rootGrid = rootPage.Content as Grid;
|
||||
popupStack.Layout(new Rectangle(x, y, popupStack.WidthRequest, height));
|
||||
rootGrid.Children.Add(popupStack);
|
||||
popupStack.Parent = rootGrid;
|
||||
rootGrid.RaiseChild(popupStack);
|
||||
}
|
||||
}
|
||||
|
||||
base.LayoutChildren(x, y, width, height);
|
||||
}
|
||||
|
||||
private async void ImageButtonCommandAsync()
|
||||
{
|
||||
if (popupStack.IsVisible)
|
||||
{
|
||||
showButton.Text = "Show";
|
||||
await CloseAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
// ((Grid)popupStack.Parent).Children[0].IsVisible = false;
|
||||
showButton.Text = "Hide";
|
||||
PositionStack();
|
||||
popupStack.Opacity = 0;
|
||||
popupStack.IsVisible = true;
|
||||
IsOpen = true;
|
||||
await popupStack.FadeTo(1, 100, Easing.Linear);
|
||||
}
|
||||
}
|
||||
|
||||
private void PositionStack()
|
||||
{
|
||||
if (rootPage == null)
|
||||
{
|
||||
var page = Navigation.NavigationStack.LastOrDefault();
|
||||
if (page == null)
|
||||
{
|
||||
page = Application.Current.MainPage;
|
||||
}
|
||||
|
||||
rootPage = GetRootPage(page);
|
||||
}
|
||||
|
||||
if (rootPage != null)
|
||||
{
|
||||
var newPos = viewPositionService.GetRelativePosition(this, rootPage);
|
||||
popupStack.TranslateTo(newPos.X - popupStack.WidthRequest, newPos.Y, 1, null);
|
||||
}
|
||||
}
|
||||
|
||||
private ContentPage GetRootPage(Page page)
|
||||
{
|
||||
if (page is MasterDetailPage mdPage)
|
||||
{
|
||||
return GetRootPage(mdPage.Detail);
|
||||
}
|
||||
else if (page is NavigationPage navPage)
|
||||
{
|
||||
return GetRootPage(navPage.CurrentPage);
|
||||
}
|
||||
else if (page is TabbedPage tabPage)
|
||||
{
|
||||
return GetRootPage(tabPage.CurrentPage);
|
||||
}
|
||||
else if (page is CarouselPage carouselPage)
|
||||
{
|
||||
return GetRootPage(carouselPage.CurrentPage);
|
||||
}
|
||||
if (page is ContentPage cPage)
|
||||
{
|
||||
return cPage;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public new event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if UITEST && __ANDROID__
|
||||
[Test]
|
||||
public void NotAddingElementsNativelyDoesntCrashAndroid()
|
||||
{
|
||||
RunningApp.WaitForElement("Success");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)CollectionViewGroupTypeIssue.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue8801.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue9428.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue9419.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue8262.cs" />
|
||||
|
|
|
@ -248,7 +248,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
bool UpdateTextAndImage()
|
||||
{
|
||||
if (_disposed || _renderer == null || _element == null)
|
||||
if (_disposed || _renderer == null || _element == null || View?.LayoutParameters == null)
|
||||
return false;
|
||||
|
||||
AppCompatButton view = View;
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
|
|||
{
|
||||
((IElementController)Button).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, hasFocus);
|
||||
}
|
||||
|
||||
|
||||
SizeRequest IVisualElementRenderer.GetDesiredSize(int widthConstraint, int heightConstraint)
|
||||
{
|
||||
if (_isDisposed)
|
||||
|
@ -91,15 +91,17 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
|
|||
}
|
||||
|
||||
var hint = Control.Hint;
|
||||
bool setHint = Control.LayoutParameters != null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(hint))
|
||||
if (!string.IsNullOrWhiteSpace(hint) && setHint)
|
||||
{
|
||||
Control.Hint = string.Empty;
|
||||
}
|
||||
|
||||
var result = _buttonLayoutManager.GetDesiredSize(widthConstraint, heightConstraint);
|
||||
|
||||
Control.Hint = hint;
|
||||
if(setHint)
|
||||
Control.Hint = hint;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -243,6 +245,12 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
|
|||
|
||||
protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if(Control?.LayoutParameters == null)
|
||||
{
|
||||
ElementPropertyChanged?.Invoke(this, e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PropertyName == Button.TextColorProperty.PropertyName)
|
||||
{
|
||||
UpdateTextColor();
|
||||
|
|
|
@ -224,6 +224,12 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
|
|||
{
|
||||
ElementPropertyChanged?.Invoke(this, e);
|
||||
|
||||
if (Control?.LayoutParameters == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (e.PropertyName == Frame.HasShadowProperty.PropertyName)
|
||||
UpdateShadow();
|
||||
else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
|
||||
|
|
|
@ -9,53 +9,53 @@ using AViewCompat = Android.Support.V4.View.ViewCompat;
|
|||
|
||||
namespace Xamarin.Forms.Platform.Android.FastRenderers
|
||||
{
|
||||
public static class ImageElementManager
|
||||
{
|
||||
public static void Init(IVisualElementRenderer renderer)
|
||||
{
|
||||
renderer.ElementPropertyChanged += OnElementPropertyChanged;
|
||||
renderer.ElementChanged += OnElementChanged;
|
||||
public static class ImageElementManager
|
||||
{
|
||||
public static void Init(IVisualElementRenderer renderer)
|
||||
{
|
||||
renderer.ElementPropertyChanged += OnElementPropertyChanged;
|
||||
renderer.ElementChanged += OnElementChanged;
|
||||
|
||||
if (renderer is ILayoutChanges layoutChanges)
|
||||
layoutChanges.LayoutChange += OnLayoutChange;
|
||||
}
|
||||
if (renderer is ILayoutChanges layoutChanges)
|
||||
layoutChanges.LayoutChange += OnLayoutChange;
|
||||
}
|
||||
|
||||
static void OnLayoutChange(object sender, global::Android.Views.View.LayoutChangeEventArgs e)
|
||||
{
|
||||
if (sender is IVisualElementRenderer renderer && renderer.View is ImageView imageView)
|
||||
AViewCompat.SetClipBounds(imageView, imageView.GetScaleType() == AScaleType.CenterCrop ? new ARect(0, 0, e.Right - e.Left, e.Bottom - e.Top) : null);
|
||||
}
|
||||
static void OnLayoutChange(object sender, global::Android.Views.View.LayoutChangeEventArgs e)
|
||||
{
|
||||
if (sender is IVisualElementRenderer renderer && renderer.View is ImageView imageView)
|
||||
AViewCompat.SetClipBounds(imageView, imageView.GetScaleType() == AScaleType.CenterCrop ? new ARect(0, 0, e.Right - e.Left, e.Bottom - e.Top) : null);
|
||||
}
|
||||
|
||||
public static void Dispose(IVisualElementRenderer renderer)
|
||||
{
|
||||
renderer.ElementPropertyChanged -= OnElementPropertyChanged;
|
||||
renderer.ElementChanged -= OnElementChanged;
|
||||
if (renderer is ILayoutChanges layoutChanges)
|
||||
layoutChanges.LayoutChange -= OnLayoutChange;
|
||||
public static void Dispose(IVisualElementRenderer renderer)
|
||||
{
|
||||
renderer.ElementPropertyChanged -= OnElementPropertyChanged;
|
||||
renderer.ElementChanged -= OnElementChanged;
|
||||
if (renderer is ILayoutChanges layoutChanges)
|
||||
layoutChanges.LayoutChange -= OnLayoutChange;
|
||||
|
||||
if (renderer is IImageRendererController imageRenderer)
|
||||
imageRenderer.SetFormsAnimationDrawable(null);
|
||||
if (renderer is IImageRendererController imageRenderer)
|
||||
imageRenderer.SetFormsAnimationDrawable(null);
|
||||
|
||||
if (renderer.View is ImageView imageView)
|
||||
{
|
||||
imageView.SetImageDrawable(null);
|
||||
imageView.Reset();
|
||||
}
|
||||
}
|
||||
if (renderer.View is ImageView imageView)
|
||||
{
|
||||
imageView.SetImageDrawable(null);
|
||||
imageView.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
async static void OnElementChanged(object sender, VisualElementChangedEventArgs e)
|
||||
{
|
||||
var renderer = (sender as IVisualElementRenderer);
|
||||
var view = renderer.View as ImageView;
|
||||
var newImageElementManager = e.NewElement as IImageElement;
|
||||
var oldImageElementManager = e.OldElement as IImageElement;
|
||||
var rendererController = renderer as IImageRendererController;
|
||||
async static void OnElementChanged(object sender, VisualElementChangedEventArgs e)
|
||||
{
|
||||
var renderer = (sender as IVisualElementRenderer);
|
||||
var view = renderer.View as ImageView;
|
||||
var newImageElementManager = e.NewElement as IImageElement;
|
||||
var oldImageElementManager = e.OldElement as IImageElement;
|
||||
var rendererController = renderer as IImageRendererController;
|
||||
|
||||
if (rendererController.IsDisposed)
|
||||
return;
|
||||
|
||||
await TryUpdateBitmap(rendererController, view, newImageElementManager, oldImageElementManager);
|
||||
|
||||
|
||||
if (rendererController.IsDisposed)
|
||||
return;
|
||||
|
||||
|
@ -64,25 +64,31 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
|
|||
if (rendererController.IsDisposed)
|
||||
return;
|
||||
|
||||
ElevationHelper.SetElevation(view, renderer.Element);
|
||||
}
|
||||
ElevationHelper.SetElevation(view, renderer.Element);
|
||||
}
|
||||
|
||||
async static void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
async static void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
var renderer = (sender as IVisualElementRenderer);
|
||||
var ImageElementManager = (IImageElement)renderer.Element;
|
||||
var imageController = (IImageController)renderer.Element;
|
||||
|
||||
if (e.IsOneOf(Image.SourceProperty, Button.ImageSourceProperty))
|
||||
{
|
||||
await TryUpdateBitmap(renderer as IImageRendererController, (ImageView)renderer.View, (IImageElement)renderer.Element).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
else if (e.Is(Image.AspectProperty))
|
||||
{
|
||||
UpdateAspect(renderer as IImageRendererController, (ImageView)renderer.View, (IImageElement)renderer.Element);
|
||||
}
|
||||
else if (e.Is(Image.IsAnimationPlayingProperty))
|
||||
if (renderer?.View?.LayoutParameters == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.IsOneOf(Image.SourceProperty, Button.ImageSourceProperty))
|
||||
{
|
||||
await TryUpdateBitmap(renderer as IImageRendererController, (ImageView)renderer.View, (IImageElement)renderer.Element).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
else if (e.Is(Image.AspectProperty))
|
||||
{
|
||||
UpdateAspect(renderer as IImageRendererController, (ImageView)renderer.View, (IImageElement)renderer.Element);
|
||||
}
|
||||
else if (e.Is(Image.IsAnimationPlayingProperty))
|
||||
await StartStopAnimation(renderer, imageController, ImageElementManager).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
@ -112,12 +118,12 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
|
|||
}
|
||||
|
||||
|
||||
async static Task TryUpdateBitmap(IImageRendererController rendererController, ImageView Control, IImageElement newImage, IImageElement previous = null)
|
||||
{
|
||||
if (newImage == null || rendererController.IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
async static Task TryUpdateBitmap(IImageRendererController rendererController, ImageView Control, IImageElement newImage, IImageElement previous = null)
|
||||
{
|
||||
if (newImage == null || rendererController.IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Control.Drawable is FormsAnimationDrawable currentAnimation)
|
||||
{
|
||||
|
@ -129,23 +135,23 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
|
|||
rendererController.SetFormsAnimationDrawable(null);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await Control.UpdateBitmap(newImage, previous).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(nameof(ImageElementManager), "Error loading image: {0}", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (newImage is IImageController imageController)
|
||||
imageController.SetIsLoading(false);
|
||||
}
|
||||
try
|
||||
{
|
||||
await Control.UpdateBitmap(newImage, previous).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(nameof(ImageElementManager), "Error loading image: {0}", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (newImage is IImageController imageController)
|
||||
imageController.SetIsLoading(false);
|
||||
}
|
||||
|
||||
if (rendererController.IsDisposed)
|
||||
return;
|
||||
|
||||
|
||||
if (Control.Drawable is FormsAnimationDrawable updatedAnimation)
|
||||
{
|
||||
rendererController.SetFormsAnimationDrawable(updatedAnimation);
|
||||
|
@ -162,14 +168,14 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
|
|||
}
|
||||
|
||||
static void UpdateAspect(IImageRendererController rendererController, ImageView Control, IImageElement newImage, IImageElement previous = null)
|
||||
{
|
||||
if (newImage == null || rendererController.IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
{
|
||||
if (newImage == null || rendererController.IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImageView.ScaleType type = newImage.Aspect.ToScaleType();
|
||||
Control.SetScaleType(type);
|
||||
}
|
||||
}
|
||||
ImageView.ScaleType type = newImage.Aspect.ToScaleType();
|
||||
Control.SetScaleType(type);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -117,14 +117,16 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
|
|||
|
||||
//We need to clear the Hint or else it will interfere with the sizing of the Label
|
||||
var hint = Control.Hint;
|
||||
if (!string.IsNullOrEmpty(hint))
|
||||
bool setHint = Control.LayoutParameters != null;
|
||||
if (!string.IsNullOrEmpty(hint) && setHint)
|
||||
Control.Hint = string.Empty;
|
||||
|
||||
Measure(widthConstraint, heightConstraint);
|
||||
var result = new SizeRequest(new Size(MeasuredWidth, MeasuredHeight), new Size());
|
||||
|
||||
//Set Hint back after sizing
|
||||
Control.Hint = hint;
|
||||
if(setHint)
|
||||
Control.Hint = hint;
|
||||
|
||||
result.Minimum = new Size(Math.Min(Context.ToPixels(10), result.Request.Width), result.Request.Height);
|
||||
|
||||
|
@ -270,6 +272,9 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
|
|||
{
|
||||
ElementPropertyChanged?.Invoke(this, e);
|
||||
|
||||
if (Control?.LayoutParameters == null)
|
||||
return;
|
||||
|
||||
if (e.PropertyName == Label.HorizontalTextAlignmentProperty.PropertyName || e.PropertyName == Label.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateGravity();
|
||||
else if (e.PropertyName == Label.TextColorProperty.PropertyName ||
|
||||
|
|
|
@ -89,9 +89,9 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Xamarin.Forms.Controls.Issu
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Forms.ControlGallery.WindowsUniversal", "Xamarin.Forms.ControlGallery.WindowsUniversal\Xamarin.Forms.ControlGallery.WindowsUniversal.csproj", "{AC257966-9368-478A-9DF4-F0D28E320FE3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Forms.Platform.UAP", "Xamarin.Forms.Platform.UAP\Xamarin.Forms.Platform.UAP.csproj", "{00D8D049-FFAA-4759-8FC9-1ECA30777F72}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Forms.Platform.UAP", "Xamarin.Forms.Platform.UAP\Xamarin.Forms.Platform.UAP.csproj", "{00D8D049-FFAA-4759-8FC9-1ECA30777F72}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Forms.Maps.UWP", "Xamarin.Forms.Maps.UWP\Xamarin.Forms.Maps.UWP.csproj", "{04D89A60-78EF-4A32-AE17-87E47E0233A5}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Forms.Maps.UWP", "Xamarin.Forms.Maps.UWP\Xamarin.Forms.Maps.UWP.csproj", "{04D89A60-78EF-4A32-AE17-87E47E0233A5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Forms.Core.Windows.UITests", "Xamarin.Forms.Core.Windows.UITests\Xamarin.Forms.Core.Windows.UITests.csproj", "{0A39A74B-6F7A-4D41-84F2-B0CCDCE899DF}"
|
||||
EndProject
|
||||
|
@ -191,12 +191,13 @@ Global
|
|||
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{0a39a74b-6f7a-4d41-84f2-b0ccdce899df}*SharedItemsImports = 4
|
||||
Xamarin.Forms.Core.UITests.Shared\Xamarin.Forms.Core.UITests.projitems*{0a39a74b-6f7a-4d41-84f2-b0ccdce899df}*SharedItemsImports = 4
|
||||
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{0f0db9cc-ea65-429c-9363-38624bf8f49c}*SharedItemsImports = 13
|
||||
Xamarin.Flex\Xamarin.Flex.projitems*{57b8b73d-c3b5-4c42-869e-7b2f17d354ac}*SharedItemsImports = 5
|
||||
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{9db0cabb-24cc-4538-88ec-6e0a0fe40248}*SharedItemsImports = 4
|
||||
Xamarin.Forms.Core.UITests.Shared\Xamarin.Forms.Core.UITests.projitems*{9db0cabb-24cc-4538-88ec-6e0a0fe40248}*SharedItemsImports = 4
|
||||
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{a34ebe01-25bf-4e69-a2dc-2288dc625541}*SharedItemsImports = 4
|
||||
Xamarin.Forms.Core.UITests.Shared\Xamarin.Forms.Core.UITests.projitems*{a34ebe01-25bf-4e69-a2dc-2288dc625541}*SharedItemsImports = 4
|
||||
Xamarin.Flex\Xamarin.Flex.projitems*{a6703c7d-d362-452a-a7a5-73771194d38c}*SharedItemsImports = 13
|
||||
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{cb9c96ce-125c-4a68-b6a1-c3ff1fbf93e1}*SharedItemsImports = 4
|
||||
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{cb9c96ce-125c-4a68-b6a1-c3ff1fbf93e1}*SharedItemsImports = 5
|
||||
Xamarin.Forms.Core.UITests.Shared\Xamarin.Forms.Core.UITests.projitems*{e175485b-3c8c-47d7-8dd5-f7fed627eb25}*SharedItemsImports = 13
|
||||
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{eadd8100-b3ae-4a31-92c4-267a64a1c6eb}*SharedItemsImports = 4
|
||||
Xamarin.Forms.Core.UITests.Shared\Xamarin.Forms.Core.UITests.projitems*{eadd8100-b3ae-4a31-92c4-267a64a1c6eb}*SharedItemsImports = 4
|
||||
|
|
Загрузка…
Ссылка в новой задаче