[NUI] Make subclass of ImageView can use ResourceUrl normally.
authorEunki Hong <eunkiki.hong@samsung.com>
Mon, 19 Jun 2023 15:51:02 +0000 (00:51 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Wed, 21 Jun 2023 03:04:41 +0000 (12:04 +0900)
If we skip to set ImageVisualType, or set ImageVisualType as Image,
we will try to find best visual by it's file format codes.
But previously, we fix the type of visual.
So, instead of some special case like URLs, just make we use Image type.

And also, make _resourceUrl latest value if we success to get url from visual.

Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/AnimatedImageView.cs
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs

index e878923780c6cf2fab506e2ff2a81b6ed2574604..e8ac7c7a1eb586633455171c521601597a3d2aa2 100755 (executable)
@@ -388,6 +388,13 @@ namespace Tizen.NUI.BaseComponents
         {
             if (!imagePropertyUpdatedFlag) return;
 
+            // Assume that we are using standard Image at first.
+            // (Since we might cache Visual.Property.Type as Visual.Type.AnimatedImage even we don't use URLs.)
+            using (PropertyValue imageType = new PropertyValue((int)Visual.Type.Image))
+            {
+                UpdateImage(Visual.Property.Type, imageType, false);
+            }
+
             if (resourceURLs != null && resourceURLs.Count != 0)
             {
                 using (PropertyArray indexPropertyArray = new PropertyArray())
@@ -406,10 +413,11 @@ namespace Tizen.NUI.BaseComponents
                     // Trigger the ImageView so that we have something update
                     UpdateImage(ImageVisualProperty.URL, arrayProperty, false);
                 }
-            }
 
-            using PropertyValue animatiedImage = new PropertyValue((int)Visual.Type.AnimatedImage);
-            UpdateImage(Visual.Property.Type, animatiedImage, false);
+                // Trick that we are using resourceURLs without ResourceUrl API.
+                using PropertyValue animatiedImage = new PropertyValue((int)Visual.Type.AnimatedImage);
+                UpdateImage(Visual.Property.Type, animatiedImage, false);
+            }
 
             base.UpdateImage();
         }
index 3e520a33de1a18b984f40bba0a33a186a1b98faf..c654a2cca5a8469a2519666fed835a65c4e9d2f4 100755 (executable)
@@ -1525,9 +1525,9 @@ namespace Tizen.NUI.BaseComponents
             }
 
             // Checkup the cached visual type is AnimatedImage.
-            // It is trick to know that this code is running on AnimatedImageView.UpdateImage() / LottieAnimationView.UpdateImage() or not.
+            // It is trick to know that this code is running on AnimatedImageView.UpdateImage() with resourceURLs or not.
             int visualType = (int)Visual.Type.Invalid;
-            if (!((GetCachedImageVisualProperty(Visual.Property.Type)?.Get(out visualType) ?? false) && (visualType == (int)Visual.Type.AnimatedImage || visualType == (int)Visual.Type.AnimatedVectorImage)))
+            if (!((GetCachedImageVisualProperty(Visual.Property.Type)?.Get(out visualType) ?? false) && (visualType == (int)Visual.Type.AnimatedImage)))
             {
                 // If ResourceUrl is not setuped, don't set property. fast return.
                 if (string.IsNullOrEmpty(_resourceUrl))
@@ -1691,6 +1691,11 @@ namespace Tizen.NUI.BaseComponents
                 {
                     // 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);
+                    }
                 }
             }
         }
index caffb58399d6b245c5f962f42d525b4312c41540..5dd2c4fee36a649f57c43283a5d35c7aa89a6c35 100755 (executable)
@@ -700,9 +700,6 @@ namespace Tizen.NUI.BaseComponents
                 currentStates.changed = false;
             }
 
-            using PropertyValue animatiedImage = new PropertyValue((int)Visual.Type.AnimatedVectorImage);
-            UpdateImage(Visual.Property.Type, animatiedImage, false);
-
             base.UpdateImage();
         }