Skip to content

Commit 6d5d6e9

Browse files
committed
fix(android): fix for ImageSource stretch not being respected
1 parent 63c7b5f commit 6d5d6e9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/image.android.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,30 +495,34 @@ export class Img extends ImageBase {
495495
// this.nativeViewProtected.setImageURI(null);
496496
const src = this.src;
497497
if (src) {
498+
let drawable: android.graphics.drawable.BitmapDrawable;
498499
if (src instanceof ImageSource) {
499-
this.nativeViewProtected.setImageBitmap(src.android);
500+
drawable = new android.graphics.drawable.BitmapDrawable(src.android as android.graphics.Bitmap);
500501
this.updateViewSize(src.android);
501-
return;
502502
} else if (isFontIconURI(src as string)) {
503503
const fontIconCode = (src as string).split('//')[1];
504504
if (fontIconCode !== undefined) {
505505
// support sync mode only
506506
const font = this.style.fontInternal;
507507
const color = this.style.color;
508-
this.nativeViewProtected.setImageBitmap(ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
508+
drawable = new android.graphics.drawable.BitmapDrawable(ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android as android.graphics.Bitmap);
509509
}
510+
}
511+
if (drawable) {
512+
const hierarchy: com.facebook.drawee.generic.GenericDraweeHierarchy = this.nativeViewProtected.getHierarchy();
513+
hierarchy.setImage(drawable, 1, hierarchy.getFadeDuration() === 0);
510514
return;
511515
}
512516
if (this.noCache) {
513-
const uri = getUri(src);
517+
const uri = getUri(src as string);
514518
const imagePipeLine = getImagePipeline();
515519
const isInCache = imagePipeLine.isInBitmapMemoryCache(uri);
516520
if (isInCache) {
517521
imagePipeLine.evictFromCache(uri);
518522
}
519523
}
520524
this.isLoading = true;
521-
const uri = getUri(src);
525+
const uri = getUri(src as string);
522526
if (!uri) {
523527
console.log(`Error: 'src' not valid: ${src}`);
524528
return;

0 commit comments

Comments
 (0)