Skip to content

Commit

Permalink
fix(android): fix for ImageSource stretch not being respected
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Jan 9, 2021
1 parent 63c7b5f commit 6d5d6e9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/image.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,30 +495,34 @@ export class Img extends ImageBase {
// this.nativeViewProtected.setImageURI(null);
const src = this.src;
if (src) {
let drawable: android.graphics.drawable.BitmapDrawable;
if (src instanceof ImageSource) {
this.nativeViewProtected.setImageBitmap(src.android);
drawable = new android.graphics.drawable.BitmapDrawable(src.android as android.graphics.Bitmap);
this.updateViewSize(src.android);
return;
} else if (isFontIconURI(src as string)) {
const fontIconCode = (src as string).split('//')[1];
if (fontIconCode !== undefined) {
// support sync mode only
const font = this.style.fontInternal;
const color = this.style.color;
this.nativeViewProtected.setImageBitmap(ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
drawable = new android.graphics.drawable.BitmapDrawable(ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android as android.graphics.Bitmap);
}
}
if (drawable) {
const hierarchy: com.facebook.drawee.generic.GenericDraweeHierarchy = this.nativeViewProtected.getHierarchy();
hierarchy.setImage(drawable, 1, hierarchy.getFadeDuration() === 0);
return;
}
if (this.noCache) {
const uri = getUri(src);
const uri = getUri(src as string);
const imagePipeLine = getImagePipeline();
const isInCache = imagePipeLine.isInBitmapMemoryCache(uri);
if (isInCache) {
imagePipeLine.evictFromCache(uri);
}
}
this.isLoading = true;
const uri = getUri(src);
const uri = getUri(src as string);
if (!uri) {
console.log(`Error: 'src' not valid: ${src}`);
return;
Expand Down

0 comments on commit 6d5d6e9

Please sign in to comment.