From fb4c97b4c5347ffe6893514b116ddbb96366e986 Mon Sep 17 00:00:00 2001 From: Veselina Radeva Date: Sat, 21 Oct 2017 14:17:46 +0300 Subject: [PATCH 1/2] refactor: Remove deprecated property `thumb`. Use thumbAsset instead. --- src/imagepicker.android.ts | 8 -------- src/imagepicker.ios.ts | 19 ------------------- src/index.d.ts | 7 ------- 3 files changed, 34 deletions(-) diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index 03bd969..5640d88 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -58,14 +58,6 @@ export class SelectedAsset extends imageAssetModule.ImageAsset { }); } - // [Deprecated. Please use thumbAsset instead.] - get thumb(): imagesource.ImageSource { - if (!this._thumbRequested) { - this.decodeThumbUri(); - } - return this._thumb; - } - get thumbAsset(): imageAssetModule.ImageAsset { return this._thumbAsset; } diff --git a/src/imagepicker.ios.ts b/src/imagepicker.ios.ts index ad30719..342667d 100644 --- a/src/imagepicker.ios.ts +++ b/src/imagepicker.ios.ts @@ -139,11 +139,6 @@ export class Album extends data_observable.Observable { return this._assets; } - // [Deprecated. Please use thumbAsset instead.] - get thumb(): image_source.ImageSource { - return this._thumb; - } - protected setThumb(value: image_source.ImageSource): void { this._thumb = value; this.notifyPropertyChange("thumb", value); @@ -160,11 +155,6 @@ export class Album extends data_observable.Observable { } export class SelectedAsset extends imageAssetModule.ImageAsset { - // [Deprecated. SelectedAsset will be used directly as a source for the thumb image] - get thumb(): image_source.ImageSource { - return null; - } - get uri(): string { return null; } @@ -200,15 +190,6 @@ export class Asset extends SelectedAsset { return this._album; } - // [Deprecated. Asset will be used directly as a source for the thumb image] - get thumb(): image_source.ImageSource { - if (!this._thumbRequested) { - this._thumbRequested = true; - this.onThumbRequest(); - } - return this._thumb; - } - get selected(): boolean { return !!this._selected; } diff --git a/src/index.d.ts b/src/index.d.ts index 0c173a7..e2930c6 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -20,13 +20,6 @@ export interface ImageOptions { } export class SelectedAsset extends imageAssetModule.ImageAsset { - /** - * [Deprecated. SelectedAsset will be used directly as a source for the thumb image] - * A 100x100 pixels thumb of the selected image. - * This property will be initialized on demand. The first access will return undefined or null. - * It will trigger an async load and when the thumb is obtained, a property changed notification will occur. - */ - thumb: imagesource.ImageSource; /** * URI that identifies the image asset. From f7d7a2ac5131e49633593bdfd973056c25a361f3 Mon Sep 17 00:00:00 2001 From: Veselina Radeva Date: Sat, 21 Oct 2017 14:29:39 +0300 Subject: [PATCH 2/2] refactor: Remove thumb related methods and properties. Use `thumbAsset` instead. --- src/imagepicker.android.ts | 15 --------------- src/imagepicker.ios.ts | 31 ------------------------------- 2 files changed, 46 deletions(-) diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index 5640d88..770f391 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -18,8 +18,6 @@ let StaticArrayBuffer = ArrayBuffer; export class SelectedAsset extends imageAssetModule.ImageAsset { private _uri: android.net.Uri; - private _thumb: imagesource.ImageSource; - private _thumbRequested: boolean; private _thumbAsset: imageAssetModule.ImageAsset; private _fileUri: string; private _data: ArrayBuffer; @@ -27,7 +25,6 @@ export class SelectedAsset extends imageAssetModule.ImageAsset { constructor(uri: android.net.Uri) { super(SelectedAsset._calculateFileUri(uri)); this._uri = uri; - this._thumbRequested = false; } data(): Promise { @@ -180,18 +177,6 @@ export class SelectedAsset extends imageAssetModule.ImageAsset { return "com.android.providers.media.documents" === uri.getAuthority(); } - private decodeThumbUri(): void { - // Decode image size - let REQUIRED_SIZE = { - maxWidth: 100, - maxHeight: 100 - }; - - // Decode with scale - this._thumb = this.decodeUri(this._uri, REQUIRED_SIZE); - this.notifyPropertyChange("thumb", this._thumb); - } - private decodeThumbAssetUri(): void { // Decode image size let REQUIRED_SIZE = { diff --git a/src/imagepicker.ios.ts b/src/imagepicker.ios.ts index 342667d..5687e60 100644 --- a/src/imagepicker.ios.ts +++ b/src/imagepicker.ios.ts @@ -117,7 +117,6 @@ export class Album extends data_observable.Observable { private _imagePicker: ImagePicker; private _assets: data_observablearray.ObservableArray; private _title: string; - private _thumb: image_source.ImageSource; private _thumbAsset: imageAssetModule.ImageAsset; constructor(imagePicker: ImagePicker, title: string) { @@ -139,11 +138,6 @@ export class Album extends data_observable.Observable { return this._assets; } - protected setThumb(value: image_source.ImageSource): void { - this._thumb = value; - this.notifyPropertyChange("thumb", value); - } - get thumbAsset(): imageAssetModule.ImageAsset { return this._thumbAsset; } @@ -176,9 +170,7 @@ export class Asset extends SelectedAsset { private _selected: boolean; private _album: Album; - private _thumb: image_source.ImageSource; private _image: image_source.ImageSource; - private _thumbRequested: boolean; constructor(album: Album, asset: PHAsset | UIImage) { super(asset); @@ -224,14 +216,6 @@ export class Asset extends SelectedAsset { data(): Promise { return Promise.reject(new Error("Not implemented.")); } - - protected setThumb(value: image_source.ImageSource): void { - this._thumb = value; - this.notifyPropertyChange("thumb", this._thumb); - } - - protected onThumbRequest(): void { - } } // iOS8+ Photo framework based view model implementation... @@ -295,15 +279,6 @@ class ImagePickerPH extends ImagePicker { } } - createPHImageThumb(target, asset: PHAsset): void { - PHImageManager.defaultManager().requestImageForAssetTargetSizeContentModeOptionsResultHandler(asset, this._thumbRequestSize, PHImageContentMode.AspectFill, - this._thumbRequestOptions, function (target, uiImage, info) { - let imageSource = new image_source.ImageSource(); - imageSource.setNativeSource(uiImage); - target.setThumb(imageSource); - }.bind(this, target)); - } - createPHImageThumbAsset(target, asset: PHAsset): void { PHImageManager.defaultManager().requestImageForAssetTargetSizeContentModeOptionsResultHandler(asset, this._thumbRequestSize, PHImageContentMode.AspectFill, this._thumbRequestOptions, function (target, uiImage, info) { @@ -408,7 +383,6 @@ class AlbumPH extends Album { if (!this._setThumb && imagePicker) { this._setThumb = true; - imagePicker.createPHImageThumb(this, asset); imagePicker.createPHImageThumbAsset(this, asset); } @@ -437,11 +411,6 @@ class AssetPH extends Asset { return this._phAsset; } - protected onThumbRequest(): void { - super.onThumbRequest(); - ((this.album).imagePicker).createPHImageThumb(this, this._phAsset); - } - get uri(): string { return this._phAsset.localIdentifier.toString(); }