Skip to content

Commit

Permalink
Reuse DraweeControllerBuilder instead of allocating one for every image
Browse files Browse the repository at this point in the history
Reviewed By: astreet

Differential Revision: D2699801

fb-gh-sync-id: 883e788f0a5c7231bf26f1ba4149115a15487366
  • Loading branch information
lexs authored and facebook-github-bot-7 committed Nov 27, 2015
1 parent 699a75b commit 2c0679b
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public String getName() {
return REACT_CLASS;
}

private final @Nullable AbstractDraweeControllerBuilder mDraweeControllerBuilder;
private @Nullable AbstractDraweeControllerBuilder mDraweeControllerBuilder;
private final @Nullable Object mCallerContext;

public ReactImageManager(
Expand All @@ -43,16 +43,20 @@ public ReactImageManager(
}

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);
}

Expand Down

0 comments on commit 2c0679b

Please sign in to comment.