File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import android.content.res.ColorStateList
66import android.graphics.Typeface
77import android.graphics.drawable.ColorDrawable
88import android.graphics.drawable.Drawable
9+ import android.net.Uri
910import android.os.Build
1011import android.util.Log
1112import android.util.TypedValue
@@ -180,10 +181,27 @@ class ReactBottomNavigationView(context: Context) : BottomNavigationView(context
180181 itemRippleColor = color
181182 }
182183
184+ private fun formatUri (uri : Uri ): Uri {
185+ return when (uri.scheme) {
186+ " res" -> {
187+ val uriString = uri.toString()
188+ val parts = uriString.split(" :/" )
189+
190+ if (parts.size > 1 ) {
191+ val resourceId = parts[1 ].toIntOrNull()
192+ Uri .parse(" android.resource://${context.packageName} /${resourceId} " )
193+ } else {
194+ uri
195+ }
196+ }
197+ else -> uri
198+ }
199+ }
200+
183201 @SuppressLint(" CheckResult" )
184202 private fun getDrawable (imageSource : ImageSource , onDrawableReady : (Drawable ? ) -> Unit ) {
185203 val request = ImageRequest .Builder (context)
186- .data(imageSource.uri)
204+ .data(formatUri( imageSource.uri) )
187205 .target { drawable ->
188206 post { onDrawableReady(drawable.asDrawable(context.resources)) }
189207 }
You can’t perform that action at this time.
0 commit comments