Avoid leaking FrescoModule when setting SoLoaderShim handler

Summary: The anonymous class had an implicit reference back to FrescoModule that would in turn retain the context.

public

Reviewed By: astreet

Differential Revision: D2690747

fb-gh-sync-id: 8a97c102e461b903c6adf7c65956baf364fa5faf
This commit is contained in:
Alexander Blom 2015-11-24 09:47:26 -08:00 committed by facebook-github-bot-7
parent 5387df8dc5
commit 69c8dd50fe
1 changed files with 8 additions and 7 deletions

View File

@ -65,13 +65,7 @@ public class FrescoModule extends ReactContextBaseJavaModule implements
super.initialize();
// Make sure the SoLoaderShim is configured to use our loader for native libraries.
// This code can be removed if using Fresco from Maven rather than from source
SoLoaderShim.setHandler(
new SoLoaderShim.Handler() {
@Override
public void loadLibrary(String libraryName) {
SoLoader.loadLibrary(libraryName);
}
});
SoLoaderShim.setHandler(new FrescoHandler());
HashSet<RequestListener> requestListeners = new HashSet<>();
requestListeners.add(new SystraceRequestListener());
@ -110,4 +104,11 @@ public class FrescoModule extends ReactContextBaseJavaModule implements
imagePipelineFactory.getMainDiskStorageCache().clearAll();
imagePipelineFactory.getSmallImageDiskStorageCache().clearAll();
}
private static class FrescoHandler implements SoLoaderShim.Handler {
@Override
public void loadLibrary(String libraryName) {
SoLoader.loadLibrary(libraryName);
}
}
}