Property.Preload();
// Do nothing. Just call for load static values.
var temporalCachedImagePropertyKeyList = cachedImagePropertyKeyList;
+ var temporalCachedNUIImageViewPropertyKeyList = cachedNUIImageViewPropertyKeyList;
}
private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
NpatchImageVisualProperty.Border,
NpatchImageVisualProperty.BorderOnly,
};
+
+ // Collection of image-sensitive properties, and need to update C# side cache value.
+ private static readonly List<int> cachedNUIImageViewPropertyKeyList = new List<int> {
+ ImageVisualProperty.URL,
+ ImageVisualProperty.DesiredWidth,
+ ImageVisualProperty.DesiredHeight,
+ ImageVisualProperty.FastTrackUploading,
+ };
internal PropertyMap cachedImagePropertyMap;
internal bool imagePropertyUpdatedFlag = false;
private bool imagePropertyUpdateProcessAttachedFlag = false;
private Rectangle _border;
+
+ // Development Guide : Please make ensure that these 4 values are matched with current image.
private string _resourceUrl = "";
private int _desired_width = -1;
private int _desired_height = -1;
private bool _fastTrackUploading = false;
+
private TriggerableSelector<string> resourceUrlSelector;
private TriggerableSelector<Rectangle> borderSelector;
{
if (_border == null)
{
- PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
- SetProperty(ImageView.Property.IMAGE, setValue);
-
- // Image properties are changed hardly. We should ignore lazy UpdateImage
- imagePropertyUpdatedFlag = false;
- cachedImagePropertyMap?.Dispose();
- cachedImagePropertyMap = null;
- MergeCachedImageVisualProperty(value);
+ SetImageByPropertyMap(value);
NotifyPropertyChanged();
- setValue?.Dispose();
}
}
}
{
if (_resourceUrl != ConvertResourceUrl(ref value))
{
- _resourceUrl = value;
- if (string.IsNullOrEmpty(_resourceUrl))
+ if (string.IsNullOrEmpty(value))
{
// Special case. If we set ResourceUrl as empty, Unregist visual.
RemoveImage();
}
else
{
+ _resourceUrl = value;
using (PropertyValue setValue = new PropertyValue(value))
{
UpdateImage(ImageVisualProperty.URL, setValue);
{
// If previous resourceUrl was already empty, we don't need to do anything. just ignore.
// Unregist and detach process only if previous resourceUrl was not empty
- string currentResourceUrl = "";
- PropertyValue currentResourceUrlValue = GetCachedImageVisualProperty(ImageVisualProperty.URL);
- if ((currentResourceUrlValue?.Get(out currentResourceUrl) ?? false) && !string.IsNullOrEmpty(currentResourceUrl))
+ if (!string.IsNullOrEmpty(_resourceUrl))
{
PropertyValue emptyValue = new PropertyValue();
imagePropertyUpdateProcessAttachedFlag = false;
}
// Update resourceUrl as empty value
+ _resourceUrl = "";
cachedImagePropertyMap[ImageVisualProperty.URL] = emptyValue;
-
- emptyValue?.Dispose();
}
- currentResourceUrlValue?.Dispose();
}
+ internal void SetImageByPropertyMap(PropertyMap map)
+ {
+ // Image properties are changed hardly. We should ignore lazy UpdateImage
+ imagePropertyUpdatedFlag = false;
+ cachedImagePropertyMap?.Dispose();
+ cachedImagePropertyMap = null;
+ MergeCachedImageVisualProperty(map);
+
+ // Update _resourceUrl, _desired_width, _desired_height, _fastTrackUploading here.
+ // Those values are C# side cached value.
+ _desired_width = _desired_height = -1;
+ _fastTrackUploading = false;
+
+ if (map != null)
+ {
+ _resourceUrl = "";
+ foreach (int key in cachedNUIImageViewPropertyKeyList)
+ {
+ using PropertyValue propertyValue = map.Find(key);
+ if (propertyValue != null)
+ {
+ if (key == ImageVisualProperty.URL)
+ {
+ propertyValue.Get(out _resourceUrl);
+ }
+ else if (key == ImageVisualProperty.DesiredWidth)
+ {
+ propertyValue.Get(out _desired_width);
+ }
+ else if (key == ImageVisualProperty.DesiredHeight)
+ {
+ propertyValue.Get(out _desired_height);
+ }
+ else if (key == ImageVisualProperty.FastTrackUploading)
+ {
+ propertyValue.Get(out _fastTrackUploading);
+ }
+ }
+ }
+
+ SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(map));
+ }
+ else
+ {
+ RemoveImage();
+ }
+ }
/// <summary>
/// Lazy call to UpdateImage.
/// Collect Properties need to be update, and set properties that starts the Processing.
// TODO : Couldn't we do this job in dali-engine side.
if (_desired_width != -1 && _desired_height != -1)
{
- if (_resourceUrl != null)
+ if (!string.IsNullOrEmpty(_resourceUrl))
{
Size2D imageSize = ImageLoader.GetOriginalImageSize(_resourceUrl, true);
if (imageSize.Height > 0 && imageSize.Width > 0 && _desired_width > 0 && _desired_height > 0)
{
// Update-or-Insert new value
cachedImagePropertyMap[key] = value;
- if (key == ImageVisualProperty.URL)
- {
- // Special case. If key is Url, update _resourceUrl here.
- value.Get(out _resourceUrl);
- }
}
}
}
defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
{
var imageView = (ImageView)bindable;
- string ret = "";
- imageView.GetCachedImageVisualProperty(ImageVisualProperty.URL)?.Get(out ret);
-
- return ret;
+ return imageView?._resourceUrl ?? "";
}));
/// Intenal used, will never be opened.
if (ret && alphaMaskURL.StartsWith("*Resource*"))
{
alphaMaskURL = alphaMaskURL.Replace("*Resource*", resource);
- mmap.Insert(NDalic.ImageVisualUrl, new PropertyValue(alphaMaskURL));
+ mmap.Insert(NDalic.ImageVisualAlphaMaskUrl, new PropertyValue(alphaMaskURL));
}
ret = false;
}
if (imageView._border == null)
{
- // Image properties are changed hardly. We should ignore lazy UpdateImage
- imageView.imagePropertyUpdatedFlag = false;
- imageView.cachedImagePropertyMap?.Dispose();
- imageView.cachedImagePropertyMap = null;
- imageView.MergeCachedImageVisualProperty(map);
-
- Tizen.NUI.Object.SetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(map));
+ imageView.SetImageByPropertyMap(map);
}
}
}),