ReactImageView 设置位图源

ReactImageView set Bitmap source

我有一个相当奇怪的情况,我想在 React-Native 中以位图形式显示来自本机库的图像。为了获取需要渲染的 Bitmap 对象,组件需要使用 "adId" 属性。

到目前为止,我有以下原生组件代码:

import android.graphics.Bitmap;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.views.image.ReactImageView;

public class AdIconViewManager extends SimpleViewManager<ReactImageView> {
    public static final String REACT_CLASS = "RCTAdIconView";

    @Override
    public String getName() {
        return REACT_CLASS;
    }

    @Override
    public ReactImageView createViewInstance(ThemedReactContext context) {
        return new ReactImageView(context, Fresco.newDraweeControllerBuilder(), null, null);
    }

    @ReactProp(name = "adId")
    public void setAdId(ReactImageView view, String adId) {
        final Bitmap icon = AppodealModule.getIcon(adId);
        // What now?
    }
}

我的问题是我不知道如何设置 ReactImageView 的位图源。 ReactImageView 完全没有记录,但似乎使用了 Fresco(我根本不知道)。有什么方法可以使用其他 DraweeControllerBuilder 来提供位图吗?

Fresco 管理位图缓​​存本身,因此使用 getIconUrl 并设置 URL 而不是位图可能更方便,使用本指南 - http://frescolib.org/docs/using-simpledraweeview.html

如果您想使用位图本身,这些文档可以让您了解 fresco 管道 - http://frescolib.org/docs/using-image-pipeline.html