mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make ImageLoaderModule TurboModule-compatible
Summary: Modifying ImageLoaderModule to be TM-compatible by extending the generated abstract class and fixing the conflicting method signatures (int -> double). Changelog: [Android] [Changed] Changing method signatures for ImageLoaderModule to accept double for requestId Reviewed By: mdvacca Differential Revision: D18435628 fbshipit-source-id: bc2a82bda49e339d1feebfe917b0862a1af15a1f
This commit is contained in:
committed by
Facebook Github Bot
parent
8797a5cfcb
commit
641e9657dd
@@ -21,4 +21,7 @@ rn_android_library(
|
||||
react_native_target("java/com/facebook/react/module/annotations:annotations"),
|
||||
react_native_target("java/com/facebook/react/views/imagehelper:imagehelper"),
|
||||
],
|
||||
exported_deps = [
|
||||
react_native_target("java/com/facebook/fbreact/specs:FBReactNativeSpec"),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.facebook.datasource.BaseDataSubscriber;
|
||||
import com.facebook.datasource.DataSource;
|
||||
import com.facebook.datasource.DataSubscriber;
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.fbreact.specs.NativeImageLoaderAndroidSpec;
|
||||
import com.facebook.imagepipeline.core.ImagePipeline;
|
||||
import com.facebook.imagepipeline.image.CloseableImage;
|
||||
import com.facebook.imagepipeline.request.ImageRequest;
|
||||
@@ -25,7 +26,6 @@ import com.facebook.react.bridge.GuardedAsyncTask;
|
||||
import com.facebook.react.bridge.LifecycleEventListener;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
@@ -35,7 +35,7 @@ import com.facebook.react.modules.fresco.ReactNetworkImageRequest;
|
||||
import com.facebook.react.views.imagehelper.ImageSource;
|
||||
|
||||
@ReactModule(name = ImageLoaderModule.NAME)
|
||||
public class ImageLoaderModule extends ReactContextBaseJavaModule
|
||||
public class ImageLoaderModule extends NativeImageLoaderAndroidSpec
|
||||
implements LifecycleEventListener {
|
||||
|
||||
private static final String ERROR_INVALID_URI = "E_INVALID_URI";
|
||||
@@ -183,12 +183,15 @@ public class ImageLoaderModule extends ReactContextBaseJavaModule
|
||||
* Prefetches the given image to the Fresco image disk cache.
|
||||
*
|
||||
* @param uriString the URI of the remote image to prefetch
|
||||
* @param requestId the client-supplied request ID used to identify this request
|
||||
* @param requestIdAsDouble the client-supplied request ID used to identify this request
|
||||
* @param promise the promise that is fulfilled when the image is successfully prefetched or
|
||||
* rejected when there is an error
|
||||
*/
|
||||
@ReactMethod
|
||||
public void prefetchImage(final String uriString, final int requestId, final Promise promise) {
|
||||
@Override
|
||||
public void prefetchImage(
|
||||
final String uriString, final double requestIdAsDouble, final Promise promise) {
|
||||
final int requestId = (int) requestIdAsDouble;
|
||||
|
||||
if (uriString == null || uriString.isEmpty()) {
|
||||
promise.reject(ERROR_INVALID_URI, "Cannot prefetch an image for an empty URI");
|
||||
return;
|
||||
@@ -228,9 +231,9 @@ public class ImageLoaderModule extends ReactContextBaseJavaModule
|
||||
prefetchSource.subscribe(prefetchSubscriber, CallerThreadExecutor.getInstance());
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void abortRequest(final int requestId) {
|
||||
DataSource<Void> request = removeRequest(requestId);
|
||||
@Override
|
||||
public void abortRequest(double requestId) {
|
||||
DataSource<Void> request = removeRequest((int) requestId);
|
||||
if (request != null) {
|
||||
request.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user