Reuse DraweeControllerBuilder instead of allocating one for every image

Reviewed By: astreet

Differential Revision: D2699801

fb-gh-sync-id: 883e788f0a5c7231bf26f1ba4149115a15487366
This commit is contained in:
Alexander Blom 2015-11-27 02:05:56 -08:00 committed by facebook-github-bot-7
parent 699a75b01f
commit 2c0679bed1

View File

@ -32,7 +32,7 @@ public class ReactImageManager extends SimpleViewManager<ReactImageView> {
return REACT_CLASS;
}
private final @Nullable AbstractDraweeControllerBuilder mDraweeControllerBuilder;
private @Nullable AbstractDraweeControllerBuilder mDraweeControllerBuilder;
private final @Nullable Object mCallerContext;
public ReactImageManager(
@ -43,16 +43,20 @@ public class ReactImageManager extends SimpleViewManager<ReactImageView> {
}
public ReactImageManager() {
// Lazily initialize as FrescoModule have not been initialized yet
mDraweeControllerBuilder = null;
mCallerContext = null;
}
@Override
public ReactImageView createViewInstance(ThemedReactContext context) {
if (mDraweeControllerBuilder == null) {
mDraweeControllerBuilder = Fresco.newDraweeControllerBuilder();
}
return new ReactImageView(
context,
mDraweeControllerBuilder == null ?
Fresco.newDraweeControllerBuilder() : mDraweeControllerBuilder,
mDraweeControllerBuilder,
mCallerContext);
}