diff --git a/tns-core-modules/ui/image/image-common.ts b/tns-core-modules/ui/image/image-common.ts index c4269bfaa..84ab2ba3b 100644 --- a/tns-core-modules/ui/image/image-common.ts +++ b/tns-core-modules/ui/image/image-common.ts @@ -110,11 +110,7 @@ export abstract class ImageBase extends View implements ImageDefinition { export const imageSourceProperty = new Property({ name: "imageSource" }); imageSourceProperty.register(ImageBase); -function onSrcPropertyChanged(image: ImageBase, oldValue: string, newValue: string) { - image._createImageSourceFromSrc(); -}; - -export const srcProperty = new Property({ name: "src", valueChanged: onSrcPropertyChanged }); +export const srcProperty = new Property({ name: "src"}); srcProperty.register(ImageBase); export const loadModeProperty = new Property({ name: "loadMode", defaultValue: "async" }); diff --git a/tns-core-modules/ui/image/image.android.ts b/tns-core-modules/ui/image/image.android.ts index 4e5b24488..e64267722 100644 --- a/tns-core-modules/ui/image/image.android.ts +++ b/tns-core-modules/ui/image/image.android.ts @@ -1,5 +1,5 @@ import { - ImageSource, ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, unsetValue, Color, + ImageSource, ImageBase, stretchProperty, imageSourceProperty, srcProperty, tintColorProperty, unsetValue, Color, isDataURI, isFileOrResourcePath, RESOURCE_PREFIX } from "./image-common"; import { path, knownFolders } from "file-system"; @@ -38,7 +38,7 @@ export function initImageCache(context: android.content.Context, mode = CacheMod } let params = new org.nativescript.widgets.image.Cache.CacheParams(); - params.memoryCacheEnabled = mode !== CacheMode.none; + params.memoryCacheEnabled = mode !== CacheMode.none; params.setMemCacheSizePercent(memoryCacheSize); // Set memory cache to % of app memory params.diskCacheEnabled = mode === CacheMode.diskAndMemory; params.diskCacheSize = diskCacheSize; @@ -157,6 +157,13 @@ export class Image extends ImageBase { set [imageSourceProperty.native](value: ImageSource) { this._setNativeImage(value ? value.android : null); } + + get [srcProperty.native](): any { + return undefined; + } + set [srcProperty.native](value: any) { + this._createImageSourceFromSrc(); + } } @Interfaces([org.nativescript.widgets.image.Worker.OnImageLoadedListener]) diff --git a/tns-core-modules/ui/image/image.ios.ts b/tns-core-modules/ui/image/image.ios.ts index 557d29d16..8ea9400a1 100644 --- a/tns-core-modules/ui/image/image.ios.ts +++ b/tns-core-modules/ui/image/image.ios.ts @@ -1,5 +1,5 @@ import { - ImageSource, ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, layout, Color, + ImageSource, ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, srcProperty, layout, Color, traceEnabled, traceWrite, traceCategories } from "./image-common"; @@ -149,4 +149,11 @@ export class Image extends ImageBase { set [imageSourceProperty.native](value: ImageSource) { this._setNativeImage(value ? value.ios : null); } + + get [srcProperty.native](): any { + return undefined; + } + set [srcProperty.native](value: any) { + this._createImageSourceFromSrc(); + } } \ No newline at end of file