| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -139,12 +139,11 @@ export class ImageSource implements ImageSourceDefinition { | |||
| 139 | 139 | }); | |
| 140 | 140 | } | |
| 141 | 141 | ||
| 142 | - public setNativeSource(source: any): boolean { | ||
| 143 | - if (!(source instanceof android.graphics.Bitmap)) { | ||
| 142 | + public setNativeSource(source: any): void { | ||
| 143 | + if (source && !(source instanceof android.graphics.Bitmap)) { | ||
| 144 | 144 | throw new Error("The method setNativeSource() expects android.graphics.Bitmap instance."); | |
| 145 | 145 | } | |
| 146 | 146 | this.android = source; | |
| 147 | - return source != null; | ||
| 148 | 147 | } | |
| 149 | 148 | ||
| 150 | 149 | public saveToFile(path: string, format: "png" | "jpeg" | "jpg", quality = 100): boolean { | |
@@ -242,8 +241,9 @@ export function fromBase64(source: string): ImageSource { | |||
| 242 | 241 | } | |
| 243 | 242 | ||
| 244 | 243 | export function fromNativeSource(source: any): ImageSource { | |
| 245 | - const image = new ImageSource(); | ||
| 246 | - return image.setNativeSource(source) ? image : null; | ||
| 244 | + const imageSource = new ImageSource(); | ||
| 245 | + imageSource.setNativeSource(source); | ||
| 246 | + return imageSource; | ||
| 247 | 247 | } | |
| 248 | 248 | ||
| 249 | 249 | export function fromUrl(url: string): Promise<ImageSourceDefinition> { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -118,12 +118,11 @@ export class ImageSource implements ImageSourceDefinition { | |||
| 118 | 118 | }); | |
| 119 | 119 | } | |
| 120 | 120 | ||
| 121 | - public setNativeSource(source: any): boolean { | ||
| 122 | - if (!(source instanceof UIImage)) { | ||
| 121 | + public setNativeSource(source: any): void { | ||
| 122 | + if (source && !(source instanceof UIImage)) { | ||
| 123 | 123 | throw new Error("The method setNativeSource() expects UIImage instance."); | |
| 124 | 124 | } | |
| 125 | 125 | this.ios = source; | |
| 126 | - return source != null; | ||
| 127 | 126 | } | |
| 128 | 127 | ||
| 129 | 128 | public saveToFile(path: string, format: "png" | "jpeg" | "jpg", quality?: number): boolean { | |
@@ -222,8 +221,9 @@ export function fromBase64(source: string): ImageSource { | |||
| 222 | 221 | } | |
| 223 | 222 | ||
| 224 | 223 | export function fromNativeSource(source: any): ImageSource { | |
| 225 | - const image = new ImageSource(); | ||
| 226 | - return image.setNativeSource(source) ? image : null; | ||
| 224 | + const imageSource = new ImageSource(); | ||
| 225 | + imageSource.setNativeSource(source); | ||
| 226 | + return imageSource; | ||
| 227 | 227 | } | |
| 228 | 228 | ||
| 229 | 229 | export function fromUrl(url: string): Promise<ImageSource> { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments