diff --git a/README.md b/README.md index 183ecfaa3..3ecfc9fc5 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,43 @@ const YourImage = () => ( /> ) ``` +OR +```jsx +import FastImage from 'react-native-fast-image' + +const YourImage = () => ( + +) +``` +- please add FireProvider by yourself like below +```xml + + + + + + + + + + +``` + + ## Are you using Glide already using an AppGlideModule? diff --git a/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java b/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java index 888b38e09..e63c9d63d 100644 --- a/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java +++ b/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java @@ -9,8 +9,12 @@ import com.bumptech.glide.load.model.Headers; import com.facebook.react.views.imagehelper.ImageSource; +import java.io.File; + import javax.annotation.Nullable; +import androidx.core.content.FileProvider; + public class FastImageSource extends ImageSource { private static final String DATA_SCHEME = "data"; private static final String LOCAL_RESOURCE_SCHEME = "res"; @@ -53,6 +57,13 @@ public FastImageSource(Context context, String source, double width, double heig mHeaders = headers == null ? Headers.DEFAULT : headers; mUri = super.getUri(); + if (mUri == null || TextUtils.isEmpty(mUri.toString())) { + Uri localUri = FileProvider.getUriForFile(context, + context.getApplicationContext().getPackageName() + ".provider", + new File(source)); + mUri = localUri; + } + if (isResource() && TextUtils.isEmpty(mUri.toString())) { throw new Resources.NotFoundException("Local Resource Not Found. Resource: '" + getSource() + "'."); }