Clean Player code

feature/players
Aurelien Hubert 7 years ago
parent b1064100a6
commit 047a08c2a0
  1. 7
      app/src/main/java/net/pokeranalytics/android/model/realm/Player.kt
  2. 10
      app/src/main/java/net/pokeranalytics/android/ui/fragment/data/PlayerDataFragment.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/PlayerImageView.kt

@ -78,4 +78,11 @@ open class Player : RealmObject(), NameManageable, Deletable, StaticRowRepresent
} }
} }
/**
* Return if the player has a picture
*/
fun hasPicture() : Boolean {
return picture != null && picture?.isNotEmpty() == true
}
} }

@ -48,7 +48,6 @@ class PlayerDataFragment : EditableDataFragment(), StaticRowRepresentableDataSou
player.updateValue(picture.absolutePath, PlayerRow.PLAYER_IMAGE) player.updateValue(picture.absolutePath, PlayerRow.PLAYER_IMAGE)
rowRepresentableAdapter.refreshRow(PlayerRow.PLAYER_IMAGE) rowRepresentableAdapter.refreshRow(PlayerRow.PLAYER_IMAGE)
} }
} }
override fun getDataSource(): RowRepresentableDataSource { override fun getDataSource(): RowRepresentableDataSource {
@ -127,17 +126,20 @@ class PlayerDataFragment : EditableDataFragment(), StaticRowRepresentableDataSou
placesArray.add(getString(R.string.library)) placesArray.add(getString(R.string.library))
placesArray.add(getString(R.string.select_a_color)) placesArray.add(getString(R.string.select_a_color))
if (player.picture != null) { if (player.hasPicture()) {
placesArray.add(getString(R.string.remove_picture)) placesArray.add(getString(R.string.remove_picture))
} }
builder.setItems(placesArray.toTypedArray()) { dialog, which -> builder.setItems(placesArray.toTypedArray()) { _, which ->
when (which) { when (which) {
0 -> mediaActivity?.openImageCaptureIntent(false) 0 -> mediaActivity?.openImageCaptureIntent(false)
1 -> mediaActivity?.openImageGalleryIntent(false) 1 -> mediaActivity?.openImageGalleryIntent(false)
2 -> { 2 -> {
} }
3 -> player.updateValue(null, PlayerRow.PLAYER_IMAGE) 3 -> {
player.updateValue(null, PlayerRow.PLAYER_IMAGE)
rowRepresentableAdapter.refreshRow(PlayerRow.PLAYER_IMAGE)
}
} }
} }
builder.show() builder.show()

@ -72,7 +72,7 @@ class PlayerImageView : FrameLayout {
playerImageView.playerInitial.text = playerInitial playerImageView.playerInitial.text = playerInitial
// Picture // Picture
if (player.picture != null && player.picture?.isNotEmpty() == true) { if (player.hasPicture()) {
playerImageView.playerStroke.background = null playerImageView.playerStroke.background = null
Glide.with(this) Glide.with(this)

Loading…
Cancel
Save