Skip to content

Commit 9c5625e

Browse files
author
radeva
authored
Merge pull request #123 from NativeScript/radeva/remove-thumb
refactor: Remove deprecated property `thumb`. Use thumbAsset instead.
2 parents d706aa9 + f7d7a2a commit 9c5625e

File tree

3 files changed

+0
-80
lines changed

3 files changed

+0
-80
lines changed

src/imagepicker.android.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ let StaticArrayBuffer = <ArrayBufferStatic>ArrayBuffer;
1818

1919
export class SelectedAsset extends imageAssetModule.ImageAsset {
2020
private _uri: android.net.Uri;
21-
private _thumb: imagesource.ImageSource;
22-
private _thumbRequested: boolean;
2321
private _thumbAsset: imageAssetModule.ImageAsset;
2422
private _fileUri: string;
2523
private _data: ArrayBuffer;
2624

2725
constructor(uri: android.net.Uri) {
2826
super(SelectedAsset._calculateFileUri(uri));
2927
this._uri = uri;
30-
this._thumbRequested = false;
3128
}
3229

3330
data(): Promise<any> {
@@ -58,14 +55,6 @@ export class SelectedAsset extends imageAssetModule.ImageAsset {
5855
});
5956
}
6057

61-
// [Deprecated. Please use thumbAsset instead.]
62-
get thumb(): imagesource.ImageSource {
63-
if (!this._thumbRequested) {
64-
this.decodeThumbUri();
65-
}
66-
return this._thumb;
67-
}
68-
6958
get thumbAsset(): imageAssetModule.ImageAsset {
7059
return this._thumbAsset;
7160
}
@@ -188,18 +177,6 @@ export class SelectedAsset extends imageAssetModule.ImageAsset {
188177
return "com.android.providers.media.documents" === uri.getAuthority();
189178
}
190179

191-
private decodeThumbUri(): void {
192-
// Decode image size
193-
let REQUIRED_SIZE = {
194-
maxWidth: 100,
195-
maxHeight: 100
196-
};
197-
198-
// Decode with scale
199-
this._thumb = this.decodeUri(this._uri, REQUIRED_SIZE);
200-
this.notifyPropertyChange("thumb", this._thumb);
201-
}
202-
203180
private decodeThumbAssetUri(): void {
204181
// Decode image size
205182
let REQUIRED_SIZE = {

src/imagepicker.ios.ts

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export class Album extends data_observable.Observable {
117117
private _imagePicker: ImagePicker;
118118
private _assets: data_observablearray.ObservableArray<Asset>;
119119
private _title: string;
120-
private _thumb: image_source.ImageSource;
121120
private _thumbAsset: imageAssetModule.ImageAsset;
122121

123122
constructor(imagePicker: ImagePicker, title: string) {
@@ -139,16 +138,6 @@ export class Album extends data_observable.Observable {
139138
return this._assets;
140139
}
141140

142-
// [Deprecated. Please use thumbAsset instead.]
143-
get thumb(): image_source.ImageSource {
144-
return this._thumb;
145-
}
146-
147-
protected setThumb(value: image_source.ImageSource): void {
148-
this._thumb = value;
149-
this.notifyPropertyChange("thumb", value);
150-
}
151-
152141
get thumbAsset(): imageAssetModule.ImageAsset {
153142
return this._thumbAsset;
154143
}
@@ -160,11 +149,6 @@ export class Album extends data_observable.Observable {
160149
}
161150

162151
export class SelectedAsset extends imageAssetModule.ImageAsset {
163-
// [Deprecated. SelectedAsset will be used directly as a source for the thumb image]
164-
get thumb(): image_source.ImageSource {
165-
return null;
166-
}
167-
168152
get uri(): string {
169153
return null;
170154
}
@@ -186,9 +170,7 @@ export class Asset extends SelectedAsset {
186170
private _selected: boolean;
187171
private _album: Album;
188172

189-
private _thumb: image_source.ImageSource;
190173
private _image: image_source.ImageSource;
191-
private _thumbRequested: boolean;
192174

193175
constructor(album: Album, asset: PHAsset | UIImage) {
194176
super(asset);
@@ -200,15 +182,6 @@ export class Asset extends SelectedAsset {
200182
return this._album;
201183
}
202184

203-
// [Deprecated. Asset will be used directly as a source for the thumb image]
204-
get thumb(): image_source.ImageSource {
205-
if (!this._thumbRequested) {
206-
this._thumbRequested = true;
207-
this.onThumbRequest();
208-
}
209-
return this._thumb;
210-
}
211-
212185
get selected(): boolean {
213186
return !!this._selected;
214187
}
@@ -243,14 +216,6 @@ export class Asset extends SelectedAsset {
243216
data(): Promise<any> {
244217
return Promise.reject(new Error("Not implemented."));
245218
}
246-
247-
protected setThumb(value: image_source.ImageSource): void {
248-
this._thumb = value;
249-
this.notifyPropertyChange("thumb", this._thumb);
250-
}
251-
252-
protected onThumbRequest(): void {
253-
}
254219
}
255220

256221
// iOS8+ Photo framework based view model implementation...
@@ -314,15 +279,6 @@ class ImagePickerPH extends ImagePicker {
314279
}
315280
}
316281

317-
createPHImageThumb(target, asset: PHAsset): void {
318-
PHImageManager.defaultManager().requestImageForAssetTargetSizeContentModeOptionsResultHandler(asset, this._thumbRequestSize, PHImageContentMode.AspectFill,
319-
this._thumbRequestOptions, function (target, uiImage, info) {
320-
let imageSource = new image_source.ImageSource();
321-
imageSource.setNativeSource(uiImage);
322-
target.setThumb(imageSource);
323-
}.bind(this, target));
324-
}
325-
326282
createPHImageThumbAsset(target, asset: PHAsset): void {
327283
PHImageManager.defaultManager().requestImageForAssetTargetSizeContentModeOptionsResultHandler(asset, this._thumbRequestSize, PHImageContentMode.AspectFill,
328284
this._thumbRequestOptions, function (target, uiImage, info) {
@@ -427,7 +383,6 @@ class AlbumPH extends Album {
427383

428384
if (!this._setThumb && imagePicker) {
429385
this._setThumb = true;
430-
imagePicker.createPHImageThumb(this, asset);
431386
imagePicker.createPHImageThumbAsset(this, asset);
432387

433388
}
@@ -456,11 +411,6 @@ class AssetPH extends Asset {
456411
return this._phAsset;
457412
}
458413

459-
protected onThumbRequest(): void {
460-
super.onThumbRequest();
461-
(<ImagePickerPH>(<AlbumPH>this.album).imagePicker).createPHImageThumb(this, this._phAsset);
462-
}
463-
464414
get uri(): string {
465415
return this._phAsset.localIdentifier.toString();
466416
}

src/index.d.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ export interface ImageOptions {
2020
}
2121

2222
export class SelectedAsset extends imageAssetModule.ImageAsset {
23-
/**
24-
* [Deprecated. SelectedAsset will be used directly as a source for the thumb image]
25-
* A 100x100 pixels thumb of the selected image.
26-
* This property will be initialized on demand. The first access will return undefined or null.
27-
* It will trigger an async load and when the thumb is obtained, a property changed notification will occur.
28-
*/
29-
thumb: imagesource.ImageSource;
3023

3124
/**
3225
* URI that identifies the image asset.

0 commit comments

Comments
 (0)