Split JS spec for image loader module

Summary:
It turns out the ImageLoader native module has different method signatures on iOS than on Android, so the JS spec we currently have won't work for ANdroid. In this diff I'm splitting up the spec for NativeImageLoader into an Android & iOS versions (similar to PlatformConstants), and updating the Android spec to match the native implementation. I'm also changing `RCTImageLoader` to use the new generated spec, and updating the JS callers (`Image.android.js` and `Image.ios.js`) to use the right one for the platform (instead of importing the untyped `ImageLoader` native module from `react-native`, like we were on Android :-/).

This will be a breaking change for anyone who's directly using `NativeImageLoader.js`, but I think most callsites should be using the `Image` component instead.

Changelog: [General] [Changed] Split NativeImageLoader into NativeImageLoaderAndroid and NativeImageLoaderIOS

Reviewed By: RSNara

Differential Revision: D18439538

fbshipit-source-id: 94c796d3fd27800ea17053e963bee51aca921718
This commit is contained in:
Emily Janzer
2019-11-11 17:18:40 -08:00
committed by Facebook Github Bot
parent 390546f6ed
commit d37baa78f1
9 changed files with 221 additions and 29 deletions
@@ -0,0 +1,43 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
*
* <p>Generated by an internal genrule from Flow types.
*
* @generated
* @nolint
*/
package com.facebook.fbreact.specs;
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.ReactModuleWithSpec;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
public abstract class NativeImageLoaderAndroidSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
public NativeImageLoaderAndroidSpec(ReactApplicationContext reactContext) {
super(reactContext);
}
@ReactMethod
public abstract void getSize(String uri, Promise promise);
@ReactMethod
public abstract void abortRequest(double requestId);
@ReactMethod
public abstract void prefetchImage(String uri, double requestId, Promise promise);
@ReactMethod
public abstract void queryCache(ReadableArray uris, Promise promise);
@ReactMethod
public abstract void getSizeWithHeaders(String uri, ReadableMap headers, Promise promise);
}
@@ -0,0 +1,40 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
*
* <p>Generated by an internal genrule from Flow types.
*
* @generated
* @nolint
*/
package com.facebook.fbreact.specs;
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.ReactModuleWithSpec;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
public abstract class NativeImageLoaderIOSSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
public NativeImageLoaderIOSSpec(ReactApplicationContext reactContext) {
super(reactContext);
}
@ReactMethod
public abstract void getSize(String uri, Promise promise);
@ReactMethod
public abstract void prefetchImage(String uri, Promise promise);
@ReactMethod
public abstract void queryCache(ReadableArray uris, Promise promise);
@ReactMethod
public abstract void getSizeWithHeaders(String uri, ReadableMap headers, Promise promise);
}