зеркало из https://github.com/DeGsoft/maui-linux.git
add support for view cells
This commit is contained in:
Родитель
4ba2f0999e
Коммит
31eada25bd
|
@ -1,4 +1,5 @@
|
|||
using Xamarin.Forms.CustomAttributes;
|
||||
using System.Collections.Generic;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
#if UITEST
|
||||
|
@ -59,6 +60,24 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
}
|
||||
}
|
||||
|
||||
public class CellViewPage : ContentPage
|
||||
{
|
||||
public CellViewPage()
|
||||
{
|
||||
var list = new List<int>();
|
||||
for (var i = 0; i < 50; i++)
|
||||
list.Add(i);
|
||||
|
||||
var listView = new ListView
|
||||
{
|
||||
ItemsSource = list,
|
||||
ItemTemplate = new DataTemplate(() => new ImageCell { ImageSource = "cartman" })
|
||||
};
|
||||
|
||||
Content = listView;
|
||||
}
|
||||
}
|
||||
|
||||
public class LandingPage : ContentPage
|
||||
{
|
||||
public LandingPage()
|
||||
|
@ -96,6 +115,14 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
};
|
||||
stackLayout.Children.Add(button3);
|
||||
|
||||
var button4 = new Button
|
||||
{
|
||||
Text = "Test cell views",
|
||||
Command = new Command(() => { Navigation.PushAsync(new CellViewPage()); }),
|
||||
HorizontalOptions = LayoutOptions.Center
|
||||
};
|
||||
stackLayout.Children.Add(button4);
|
||||
|
||||
scrollView.Content = stackLayout;
|
||||
Content = scrollView;
|
||||
}
|
||||
|
|
|
@ -193,7 +193,6 @@ namespace Xamarin.Forms.Platform.Android
|
|||
_imageView.SetImageResource(global::Android.Resource.Color.Transparent);
|
||||
|
||||
Bitmap bitmap = null;
|
||||
|
||||
IImageSourceHandler handler;
|
||||
|
||||
if (source != null && (handler = Registrar.Registered.GetHandler<IImageSourceHandler>(source.GetType())) != null)
|
||||
|
@ -211,9 +210,12 @@ namespace Xamarin.Forms.Platform.Android
|
|||
}
|
||||
}
|
||||
|
||||
_imageView.SetImageBitmap(bitmap);
|
||||
if (bitmap != null)
|
||||
bitmap.Dispose();
|
||||
if (bitmap == null && source is FileImageSource)
|
||||
_imageView.SetImageResource(ResourceManager.GetDrawableByName(((FileImageSource)source).File));
|
||||
else
|
||||
_imageView.SetImageBitmap(bitmap);
|
||||
|
||||
bitmap?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,10 +68,6 @@ namespace Xamarin.Forms.Platform.Android
|
|||
if (Device.IsInvokeRequired)
|
||||
throw new InvalidOperationException("Image Bitmap must not be updated from background thread");
|
||||
|
||||
Bitmap bitmap = null;
|
||||
|
||||
ImageSource source = Element.Source;
|
||||
|
||||
if (previous != null && Equals(previous.Source, Element.Source))
|
||||
return;
|
||||
|
||||
|
@ -82,27 +78,22 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
Control.SetImageResource(global::Android.Resource.Color.Transparent);
|
||||
|
||||
if (source != null)
|
||||
{
|
||||
IImageSourceHandler handler;
|
||||
if ((handler = Registrar.Registered.GetHandler<IImageSourceHandler>(source.GetType())) != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
bitmap = await handler.LoadImageAsync(source, Context);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Log.Warning("Xamarin.Forms.Platform.Android.ImageRenderer", "Error updating bitmap: {0}", ex);
|
||||
}
|
||||
}
|
||||
ImageSource source = Element.Source;
|
||||
Bitmap bitmap = null;
|
||||
IImageSourceHandler handler;
|
||||
|
||||
if (bitmap == null && source is FileImageSource)
|
||||
if (source != null && (handler = Registrar.Registered.GetHandler<IImageSourceHandler>(source.GetType())) != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Control.SetImageResource(ResourceManager.GetDrawableByName(((FileImageSource)Element.Source).File));
|
||||
bitmap = await handler.LoadImageAsync(source, Context);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Log.Warning("Xamarin.Forms.Platform.Android.ImageRenderer", "Error updating bitmap: {0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +105,9 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
if (!_isDisposed)
|
||||
{
|
||||
if (bitmap != null)
|
||||
if (bitmap == null && source is FileImageSource)
|
||||
Control.SetImageResource(ResourceManager.GetDrawableByName(((FileImageSource)source).File));
|
||||
else
|
||||
Control.SetImageBitmap(bitmap);
|
||||
|
||||
bitmap?.Dispose();
|
||||
|
|
Загрузка…
Ссылка в новой задаче