File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/android/src/main/java/com/reactnativecommunity/slider Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,17 @@ private BitmapDrawable getBitmapDrawable(final String uri) {
134
134
public BitmapDrawable call () {
135
135
BitmapDrawable bitmapDrawable = null ;
136
136
try {
137
- Bitmap bitmap = BitmapFactory .decodeStream (new URL (uri ).openStream ());
137
+ Bitmap bitmap = null ;
138
+ if (uri .startsWith ("http://" ) || uri .startsWith ("https://" ) ||
139
+ uri .startsWith ("file://" ) || uri .startsWith ("asset://" ) || uri .startsWith ("data:" )) {
140
+ bitmap = BitmapFactory .decodeStream (new URL (uri ).openStream ());
141
+ } else {
142
+ int drawableId = getResources ()
143
+ .getIdentifier (uri , "drawable" , getContext ()
144
+ .getPackageName ());
145
+ bitmap = BitmapFactory .decodeResource (getResources (), drawableId );
146
+ }
147
+
138
148
bitmapDrawable = new BitmapDrawable (getResources (), bitmap );
139
149
} catch (Exception e ) {
140
150
e .printStackTrace ();
You can’t perform that action at this time.
0 commit comments