|
| 1 | +diff --git a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java |
| 2 | +index d9dbd99..e45f8e3 100644 |
| 3 | +--- a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java |
| 4 | ++++ b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java |
| 5 | +@@ -11,7 +11,7 @@ import com.facebook.react.views.imagehelper.ImageSource; |
| 6 | + |
| 7 | + import javax.annotation.Nullable; |
| 8 | + |
| 9 | +-public class FastImageSource extends ImageSource { |
| 10 | ++public class FastImageSource { |
| 11 | + private static final String DATA_SCHEME = "data"; |
| 12 | + private static final String LOCAL_RESOURCE_SCHEME = "res"; |
| 13 | + private static final String ANDROID_RESOURCE_SCHEME = "android.resource"; |
| 14 | +@@ -19,6 +19,7 @@ public class FastImageSource extends ImageSource { |
| 15 | + private static final String LOCAL_FILE_SCHEME = "file"; |
| 16 | + private final Headers mHeaders; |
| 17 | + private Uri mUri; |
| 18 | ++ private final ImageSource imageSource; // Composition instead of inheritance |
| 19 | + |
| 20 | + public static boolean isBase64Uri(Uri uri) { |
| 21 | + return DATA_SCHEME.equals(uri.getScheme()); |
| 22 | +@@ -49,9 +50,9 @@ public class FastImageSource extends ImageSource { |
| 23 | + } |
| 24 | + |
| 25 | + public FastImageSource(Context context, String source, double width, double height, @Nullable Headers headers) { |
| 26 | +- super(context, source, width, height); |
| 27 | ++ imageSource = new ImageSource(context, source, width, height); // Create ImageSource instance |
| 28 | + mHeaders = headers == null ? Headers.DEFAULT : headers; |
| 29 | +- mUri = super.getUri(); |
| 30 | ++ mUri = imageSource.getUri(); |
| 31 | + |
| 32 | + if (isResource() && TextUtils.isEmpty(mUri.toString())) { |
| 33 | + throw new Resources.NotFoundException("Local Resource Not Found. Resource: '" + getSource() + "'."); |
| 34 | +@@ -97,7 +98,6 @@ public class FastImageSource extends ImageSource { |
| 35 | + return getGlideUrl(); |
| 36 | + } |
| 37 | + |
| 38 | +- @Override |
| 39 | + public Uri getUri() { |
| 40 | + return mUri; |
| 41 | + } |
| 42 | +@@ -109,4 +109,8 @@ public class FastImageSource extends ImageSource { |
| 43 | + public GlideUrl getGlideUrl() { |
| 44 | + return new GlideUrl(getUri().toString(), getHeaders()); |
| 45 | + } |
| 46 | ++ |
| 47 | ++ public String getSource() { |
| 48 | ++ return imageSource.getSource(); // delegate to ImageSource |
| 49 | ++ } |
| 50 | + } |
0 commit comments