Fixes player stroke issue

hh
Laurent 6 years ago
parent 5d048015d8
commit 796ace74e3
  1. 5
      app/src/main/java/net/pokeranalytics/android/ui/modules/datalist/DataListFragment.kt
  2. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  3. 15
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  4. 7
      app/src/main/java/net/pokeranalytics/android/ui/view/PlayerImageView.kt

@ -165,14 +165,13 @@ open class DataListFragment : DeletableItemFragment(), RowRepresentableDelegate
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
when (requestCode) { when (requestCode) {
RequestCode.NEW_DATA.value -> { RequestCode.NEW_DATA.value -> {
if (this.model.isSelectionInstance) { if (this.model.isSelectionInstance && resultCode == Activity.RESULT_OK) {
data?.getStringExtra(EditableDataActivity.IntentKey.PRIMARY_KEY.keyName)?.let { id -> data?.getStringExtra(EditableDataActivity.IntentKey.PRIMARY_KEY.keyName)?.let { id ->
finishActivityWithSelection(id) finishActivityWithSelection(id)
} ?: throw PAIllegalStateException("identifier not found") } ?: throw PAIllegalStateException("identifier not found")
} }
} }
} }

@ -534,8 +534,12 @@ class HandHistoryAdapter(
delegate?.onItemClick(position, row, itemView.playerImage.tag as Int) delegate?.onItemClick(position, row, itemView.playerImage.tag as Int)
} }
itemView.playerImage.setOnImageClickListener(listener) itemView.playerImage.setOnImageClickListener(listener)
val size = PlayerImageView.Size.SMALL
row.playerSetup?.player?.let { player -> row.playerSetup?.player?.let { player ->
itemView.playerImage.setPlayer(player, PlayerImageView.Size.SMALL) itemView.playerImage.setPlayer(player, size)
} ?: run {
itemView.playerImage.clear(size)
} }
// Title // Title

@ -1,6 +1,7 @@
package net.pokeranalytics.android.ui.modules.handhistory package net.pokeranalytics.android.ui.modules.handhistory
import android.animation.ValueAnimator import android.animation.ValueAnimator
import android.app.Activity
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
@ -199,11 +200,15 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
when (requestCode) { when (requestCode) {
RequestCode.PLAYER_SELECTION.ordinal -> { RequestCode.PLAYER_SELECTION.ordinal -> {
val playerId = data?.getStringExtra(BaseFragment.BundleKey.PRIMARY_KEY.value) ?: throw PAIllegalStateException("Primary key not set where as activity has finished")
getRealm().findById<Player>(playerId)?.let { player -> if (resultCode == Activity.RESULT_OK) {
this.model.playerSelected(player) val playerId = data?.getStringExtra(BaseFragment.BundleKey.PRIMARY_KEY.value) ?: throw PAIllegalStateException("Primary key not set where as activity has finished")
} ?: throw PAIllegalStateException("Player (id=$playerId) not found") getRealm().findById<Player>(playerId)?.let { player ->
this.handHistoryAdapter.notifyDataSetChanged() this.model.playerSelected(player)
} ?: throw PAIllegalStateException("Player (id=$playerId) not found")
this.handHistoryAdapter.notifyDataSetChanged()
}
} }
} }

@ -67,7 +67,7 @@ class PlayerImageView : FrameLayout {
*/ */
private fun init() { private fun init() {
val layoutInflater = LayoutInflater.from(context) val layoutInflater = LayoutInflater.from(context)
playerImageView = layoutInflater.inflate(R.layout.view_player_image, this, false) as ConstraintLayout this.playerImageView = layoutInflater.inflate(R.layout.view_player_image, this, false) as ConstraintLayout
val layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) val layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
addView(playerImageView, layoutParams) addView(playerImageView, layoutParams)
} }
@ -145,4 +145,9 @@ class PlayerImageView : FrameLayout {
} }
fun clear(size: Size = Size.NORMAL) {
val drawable = this.playerImageView.playerStroke.background as GradientDrawable?
drawable?.setStroke(size.getStrokeSize(), getColor(context, R.color.kaki))
}
} }
Loading…
Cancel
Save