|
|
|
|
@ -2,10 +2,7 @@ package net.pokeranalytics.android.ui.view |
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
|
import android.graphics.Color |
|
|
|
|
import android.graphics.ImageDecoder |
|
|
|
|
import android.graphics.drawable.GradientDrawable |
|
|
|
|
import android.os.Build |
|
|
|
|
import android.provider.MediaStore |
|
|
|
|
import android.util.AttributeSet |
|
|
|
|
import android.util.TypedValue |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
@ -16,7 +13,6 @@ 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 |
|
|
|
|
@ -96,41 +92,13 @@ class PlayerImageView : FrameLayout { |
|
|
|
|
|
|
|
|
|
// Picture |
|
|
|
|
player.picture?.let { picture -> |
|
|
|
|
|
|
|
|
|
Timber.d("picture = $picture") |
|
|
|
|
|
|
|
|
|
val uri = picture.toUri() |
|
|
|
|
|
|
|
|
|
context?.contentResolver?.let { resolver -> |
|
|
|
|
val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { |
|
|
|
|
ImageDecoder.decodeBitmap(ImageDecoder.createSource(resolver, uri)) |
|
|
|
|
} else { |
|
|
|
|
MediaStore.Images.Media.getBitmap(resolver, uri) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val rDrawable = RoundedBitmapDrawableFactory.create(resources, bitmap) |
|
|
|
|
rDrawable.isCircular = true |
|
|
|
|
this.playerImage.setImageDrawable(rDrawable) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// player.picture?.let { pic -> |
|
|
|
|
// pic.toUri().path?.let { |
|
|
|
|
// val rDrawable = RoundedBitmapDrawableFactory.create(resources, it) |
|
|
|
|
// rDrawable.isCircular = true |
|
|
|
|
// this.playerImage.setImageDrawable(rDrawable) |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// this.playerImage.setImageURI(uri) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
} ?: run { |
|
|
|
|
|
|
|
|
|
this.playerImage.setImageURI(picture.toUri()) |
|
|
|
|
} ?: run { // no pic |
|
|
|
|
this.playerStroke.background = ResourcesCompat.getDrawable(resources, R.drawable.circle_stroke_kaki, null) |
|
|
|
|
this.playerImage.setImageDrawable(null) |
|
|
|
|
this.playerInitial.text = player.initials |
|
|
|
|
this.playerInitial.setTextSize(TypedValue.COMPLEX_UNIT_SP, size.getFontSize()) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Player color |
|
|
|
|
|