Manage new and older way of displaying pictures

realmasync
Laurent 3 years ago
parent dd71fd9db9
commit 2def8c8aeb
  1. 9
      app/src/main/java/net/pokeranalytics/android/ui/view/PlayerImageView.kt

@ -13,6 +13,7 @@ import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat.getColor
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
import androidx.core.net.toUri
import net.pokeranalytics.android.R
import net.pokeranalytics.android.model.realm.Player
@ -93,7 +94,13 @@ class PlayerImageView : FrameLayout {
// Picture
player.picture?.let { picture ->
Timber.d("picture = $picture")
this.playerImage.setImageURI(picture.toUri())
if (picture.startsWith("content://")) {
this.playerImage.setImageURI(picture.toUri())
} else { // older way
val rDrawable = RoundedBitmapDrawableFactory.create(resources, picture)
rDrawable.isCircular = true
this.playerImage.setImageDrawable(rDrawable)
}
} ?: run { // no pic
this.playerStroke.background = ResourcesCompat.getDrawable(resources, R.drawable.circle_stroke_kaki, null)
this.playerImage.setImageDrawable(null)

Loading…
Cancel
Save