Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for fix #1045

Open
krunal54 opened this issue Aug 26, 2024 · 4 comments
Open

Patch for fix #1045

krunal54 opened this issue Aug 26, 2024 · 4 comments

Comments

@krunal54
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

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
index d9dbd99..1c67401 100644
--- 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
@@ -11,7 +11,7 @@ import com.facebook.react.views.imagehelper.ImageSource;
 
 import javax.annotation.Nullable;
 
-public class FastImageSource extends ImageSource {
+public class FastImageSource {
     private static final String DATA_SCHEME = "data";
     private static final String LOCAL_RESOURCE_SCHEME = "res";
     private static final String ANDROID_RESOURCE_SCHEME = "android.resource";
@@ -19,6 +19,7 @@ public class FastImageSource extends ImageSource {
     private static final String LOCAL_FILE_SCHEME = "file";
     private final Headers mHeaders;
     private Uri mUri;
+    private final ImageSource imageSource; // Composition instead of inheritance
 
     public static boolean isBase64Uri(Uri uri) {
         return DATA_SCHEME.equals(uri.getScheme());
@@ -49,9 +50,9 @@ public class FastImageSource extends ImageSource {
     }
 
     public FastImageSource(Context context, String source, double width, double height, @Nullable Headers headers) {
-        super(context, source, width, height);
+        imageSource = new ImageSource(context, source, width, height); // Create ImageSource instance
         mHeaders = headers == null ? Headers.DEFAULT : headers;
-        mUri = super.getUri();
+        mUri = imageSource.getUri(); // Get URI from ImageSource
 
         if (isResource() && TextUtils.isEmpty(mUri.toString())) {
             throw new Resources.NotFoundException("Local Resource Not Found. Resource: '" + getSource() + "'.");
@@ -59,12 +60,11 @@ public class FastImageSource extends ImageSource {
 
         if (isLocalResourceUri(mUri)) {
             // Convert res:/ scheme to android.resource:// so
-            // glide can understand the uri.
+            // Glide can understand the URI.
             mUri = Uri.parse(mUri.toString().replace("res:/", ANDROID_RESOURCE_SCHEME + "://" + context.getPackageName() + "/"));
         }
     }
 
-
     public boolean isBase64Resource() {
         return mUri != null && FastImageSource.isBase64Uri(mUri);
     }
@@ -97,7 +97,6 @@ public class FastImageSource extends ImageSource {
         return getGlideUrl();
     }
 
-    @Override
     public Uri getUri() {
         return mUri;
     }
@@ -109,4 +108,8 @@ public class FastImageSource extends ImageSource {
     public GlideUrl getGlideUrl() {
         return new GlideUrl(getUri().toString(), getHeaders());
     }
+
+    public String getSource() {
+        return imageSource.getSource(); // Delegate to ImageSource
+    }
 }
\ No newline at end of file

This issue body was partially generated by patch-package.

@kodeandoec
Copy link

sorry for the question, how i can patch package?
Can you get me instructions please?

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

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
index d9dbd99..1c67401 100644
--- 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
@@ -11,7 +11,7 @@ import com.facebook.react.views.imagehelper.ImageSource;
 
 import javax.annotation.Nullable;
 
-public class FastImageSource extends ImageSource {
+public class FastImageSource {
     private static final String DATA_SCHEME = "data";
     private static final String LOCAL_RESOURCE_SCHEME = "res";
     private static final String ANDROID_RESOURCE_SCHEME = "android.resource";
@@ -19,6 +19,7 @@ public class FastImageSource extends ImageSource {
     private static final String LOCAL_FILE_SCHEME = "file";
     private final Headers mHeaders;
     private Uri mUri;
+    private final ImageSource imageSource; // Composition instead of inheritance
 
     public static boolean isBase64Uri(Uri uri) {
         return DATA_SCHEME.equals(uri.getScheme());
@@ -49,9 +50,9 @@ public class FastImageSource extends ImageSource {
     }
 
     public FastImageSource(Context context, String source, double width, double height, @Nullable Headers headers) {
-        super(context, source, width, height);
+        imageSource = new ImageSource(context, source, width, height); // Create ImageSource instance
         mHeaders = headers == null ? Headers.DEFAULT : headers;
-        mUri = super.getUri();
+        mUri = imageSource.getUri(); // Get URI from ImageSource
 
         if (isResource() && TextUtils.isEmpty(mUri.toString())) {
             throw new Resources.NotFoundException("Local Resource Not Found. Resource: '" + getSource() + "'.");
@@ -59,12 +60,11 @@ public class FastImageSource extends ImageSource {
 
         if (isLocalResourceUri(mUri)) {
             // Convert res:/ scheme to android.resource:// so
-            // glide can understand the uri.
+            // Glide can understand the URI.
             mUri = Uri.parse(mUri.toString().replace("res:/", ANDROID_RESOURCE_SCHEME + "://" + context.getPackageName() + "/"));
         }
     }
 
-
     public boolean isBase64Resource() {
         return mUri != null && FastImageSource.isBase64Uri(mUri);
     }
@@ -97,7 +97,6 @@ public class FastImageSource extends ImageSource {
         return getGlideUrl();
     }
 
-    @Override
     public Uri getUri() {
         return mUri;
     }
@@ -109,4 +108,8 @@ public class FastImageSource extends ImageSource {
     public GlideUrl getGlideUrl() {
         return new GlideUrl(getUri().toString(), getHeaders());
     }
+
+    public String getSource() {
+        return imageSource.getSource(); // Delegate to ImageSource
+    }
 }
\ No newline at end of file

This issue body was partially generated by patch-package.

@kkkasio
Copy link

kkkasio commented Aug 30, 2024

desculpe pela pergunta, como posso corrigir o pacote? Você pode me dar instruções, por favor?

Olá! 👋
Primeiramente, obrigado pelo seu trabalho neste projeto! 🙂
Hoje usei o patch-package para aplicar patches [email protected]no projeto no qual estou trabalhando.
Aqui está o diff que resolveu meu problema:

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
index d9dbd99..1c67401 100644
--- 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
@@ -11,7 +11,7 @@ import com.facebook.react.views.imagehelper.ImageSource;
 
 import javax.annotation.Nullable;
 
-public class FastImageSource extends ImageSource {
+public class FastImageSource {
     private static final String DATA_SCHEME = "data";
     private static final String LOCAL_RESOURCE_SCHEME = "res";
     private static final String ANDROID_RESOURCE_SCHEME = "android.resource";
@@ -19,6 +19,7 @@ public class FastImageSource extends ImageSource {
     private static final String LOCAL_FILE_SCHEME = "file";
     private final Headers mHeaders;
     private Uri mUri;
+    private final ImageSource imageSource; // Composition instead of inheritance
 
     public static boolean isBase64Uri(Uri uri) {
         return DATA_SCHEME.equals(uri.getScheme());
@@ -49,9 +50,9 @@ public class FastImageSource extends ImageSource {
     }
 
     public FastImageSource(Context context, String source, double width, double height, @Nullable Headers headers) {
-        super(context, source, width, height);
+        imageSource = new ImageSource(context, source, width, height); // Create ImageSource instance
         mHeaders = headers == null ? Headers.DEFAULT : headers;
-        mUri = super.getUri();
+        mUri = imageSource.getUri(); // Get URI from ImageSource
 
         if (isResource() && TextUtils.isEmpty(mUri.toString())) {
             throw new Resources.NotFoundException("Local Resource Not Found. Resource: '" + getSource() + "'.");
@@ -59,12 +60,11 @@ public class FastImageSource extends ImageSource {
 
         if (isLocalResourceUri(mUri)) {
             // Convert res:/ scheme to android.resource:// so
-            // glide can understand the uri.
+            // Glide can understand the URI.
             mUri = Uri.parse(mUri.toString().replace("res:/", ANDROID_RESOURCE_SCHEME + "://" + context.getPackageName() + "/"));
         }
     }
 
-
     public boolean isBase64Resource() {
         return mUri != null && FastImageSource.isBase64Uri(mUri);
     }
@@ -97,7 +97,6 @@ public class FastImageSource extends ImageSource {
         return getGlideUrl();
     }
 
-    @Override
     public Uri getUri() {
         return mUri;
     }
@@ -109,4 +108,8 @@ public class FastImageSource extends ImageSource {
     public GlideUrl getGlideUrl() {
         return new GlideUrl(getUri().toString(), getHeaders());
     }
+
+    public String getSource() {
+        return imageSource.getSource(); // Delegate to ImageSource
+    }
 }
\ No newline at end of file

Este corpo de problema foi parcialmente gerado pelo patch-package .

change file in package (react-native-fast-image) from your node_modules folder then run the command

➜ npx patch-package react-native-fast-image --use-yarn

@spyshower
Copy link

desculpe pela pergunta, como posso corrigir o pacote? Você pode me dar instruções, por favor?

Olá! 👋
Primeiramente, obrigado pelo seu trabalho neste projeto! 🙂
Hoje usei o patch-package para aplicar patches [email protected]no projeto no qual estou trabalhando.
Aqui está o diff que resolveu meu problema:

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
index d9dbd99..1c67401 100644
--- 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
@@ -11,7 +11,7 @@ import com.facebook.react.views.imagehelper.ImageSource;
 
 import javax.annotation.Nullable;
 
-public class FastImageSource extends ImageSource {
+public class FastImageSource {
     private static final String DATA_SCHEME = "data";
     private static final String LOCAL_RESOURCE_SCHEME = "res";
     private static final String ANDROID_RESOURCE_SCHEME = "android.resource";
@@ -19,6 +19,7 @@ public class FastImageSource extends ImageSource {
     private static final String LOCAL_FILE_SCHEME = "file";
     private final Headers mHeaders;
     private Uri mUri;
+    private final ImageSource imageSource; // Composition instead of inheritance
 
     public static boolean isBase64Uri(Uri uri) {
         return DATA_SCHEME.equals(uri.getScheme());
@@ -49,9 +50,9 @@ public class FastImageSource extends ImageSource {
     }
 
     public FastImageSource(Context context, String source, double width, double height, @Nullable Headers headers) {
-        super(context, source, width, height);
+        imageSource = new ImageSource(context, source, width, height); // Create ImageSource instance
         mHeaders = headers == null ? Headers.DEFAULT : headers;
-        mUri = super.getUri();
+        mUri = imageSource.getUri(); // Get URI from ImageSource
 
         if (isResource() && TextUtils.isEmpty(mUri.toString())) {
             throw new Resources.NotFoundException("Local Resource Not Found. Resource: '" + getSource() + "'.");
@@ -59,12 +60,11 @@ public class FastImageSource extends ImageSource {
 
         if (isLocalResourceUri(mUri)) {
             // Convert res:/ scheme to android.resource:// so
-            // glide can understand the uri.
+            // Glide can understand the URI.
             mUri = Uri.parse(mUri.toString().replace("res:/", ANDROID_RESOURCE_SCHEME + "://" + context.getPackageName() + "/"));
         }
     }
 
-
     public boolean isBase64Resource() {
         return mUri != null && FastImageSource.isBase64Uri(mUri);
     }
@@ -97,7 +97,6 @@ public class FastImageSource extends ImageSource {
         return getGlideUrl();
     }
 
-    @Override
     public Uri getUri() {
         return mUri;
     }
@@ -109,4 +108,8 @@ public class FastImageSource extends ImageSource {
     public GlideUrl getGlideUrl() {
         return new GlideUrl(getUri().toString(), getHeaders());
     }
+
+    public String getSource() {
+        return imageSource.getSource(); // Delegate to ImageSource
+    }
 }
\ No newline at end of file

Este corpo de problema foi parcialmente gerado pelo patch-package .

change file in package (react-native-fast-image) from your node_modules folder then run the command

➜ npx patch-package react-native-fast-image --use-yarn

if yarn isn't necessary for this, edit your comment and remove it, otherwise you will be messing up with people's environment

@deepanshushuklad11
Copy link

Issue has been fixed in @d11/react-native-fast-image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@spyshower @kkkasio @krunal54 @kodeandoec @deepanshushuklad11 and others