Skip to content

Commit c9b64f6

Browse files
pheiswojteg1337
authored andcommitted
fix: thumbImage on android release mode (#125)
1 parent 3487778 commit c9b64f6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,17 @@ private BitmapDrawable getBitmapDrawable(final String uri) {
134134
public BitmapDrawable call() {
135135
BitmapDrawable bitmapDrawable = null;
136136
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+
138148
bitmapDrawable = new BitmapDrawable(getResources(), bitmap);
139149
} catch (Exception e) {
140150
e.printStackTrace();

0 commit comments

Comments
 (0)