Skip to content

Commit

Permalink
Merge pull request #219 from alibaba/216-android-本地图片资源-模版localxxxx-不…
Browse files Browse the repository at this point in the history
…生效问题

fix: to fix local resource not redner in android platform
  • Loading branch information
biezhihua authored Sep 16, 2022
2 parents cc1a685 + 11cc1fc commit 313360d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ open class GXImageView : AppCompatImageView, GXIImageView {

private fun getResIdByUri(imageView: ImageView, uri: String): Int {
try {
return imageView.resources.getIdentifier(uri, "drawable", imageView.context.packageName)
// drawable resource
imageView.resources.getIdentifier(uri, "drawable", imageView.context.packageName)
.takeIf { it != 0 }?.let {
return it
}

// mipmap resource
imageView.resources.getIdentifier(uri, "mipmap", imageView.context.packageName)
.takeIf { it != 0 }?.let {
return it
}
} catch (e: Exception) {
e.printStackTrace()
}
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 313360d

Please sign in to comment.