Fixes issue with card layout selection + removes the card limit when a user edits a non-empty card selection

hh
Laurent 6 years ago
parent 796ace74e3
commit 74da03e7f8
  1. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/datalist/DataListActivity.kt
  2. 36
      app/src/main/java/net/pokeranalytics/android/ui/modules/datalist/DataSelectionDialogFragment.kt
  3. 3
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  4. 9
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  5. 1
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryRow.kt
  6. 7
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt
  7. 2
      app/src/main/res/layout/fragment_data_selection_dialog.xml

@ -101,10 +101,12 @@ class DataListActivity : BaseActivity() {
val dataListFragment = DataListFragment() val dataListFragment = DataListFragment()
val fragment = if (dialog) { if (dialog) {
val dataSelectionDialogFragment = DataSelectionDialogFragment() val dataSelectionDialogFragment = DataSelectionDialogFragment()
showFragment(dataSelectionDialogFragment, R.id.container) showFragment(dataSelectionDialogFragment, R.id.container)
dataSelectionDialogFragment.showFragment(dataListFragment) dataSelectionDialogFragment.showFragment(dataListFragment, supportFragmentManager)
// dataSelectionDialogFragment.show(supportFragmentManager, "alert")
} else { } else {
showFragment(dataListFragment, R.id.container) showFragment(dataListFragment, R.id.container)
} }

@ -6,14 +6,11 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
class DataSelectionDialogFragment : DialogFragment() {
private enum class BundleKey(var value: String) { class DataSelectionDialogFragment : DialogFragment() {
DATA_TYPE("data_type"),
ITEM_IDS("item_ids")
}
companion object { companion object {
@ -33,26 +30,37 @@ class DataSelectionDialogFragment : DialogFragment() {
return inflater.inflate(R.layout.fragment_data_selection_dialog, container, false) return inflater.inflate(R.layout.fragment_data_selection_dialog, container, false)
} }
// override fun onResume() {
// super.onResume()
//
// val params: ViewGroup.LayoutParams = dialog.window.attributes
// params.width = ViewGroup.LayoutParams.MATCH_PARENT
// params.height = ViewGroup.LayoutParams.MATCH_PARENT
// dialog.window.attributes = params as WindowManager.LayoutParams
// }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
// initDataListFragment() initDataListFragment()
} }
// private fun initDataListFragment() { private fun initDataListFragment() {
////
//// val dataListFragment = val dataListFragment = DataListFragment()
//// DataListFragment() this.showFragment(dataListFragment, childFragmentManager)
//// val dataType = this.arguments?.getInt(BundleKey.DATA_TYPE.value) ?: throw PAIllegalStateException("undefined datatype") //// val dataType = this.arguments?.getInt(BundleKey.DATA_TYPE.value) ?: throw PAIllegalStateException("undefined datatype")
//// val itemIds = this.arguments?.getStringArray(BundleKey.ITEM_IDS.value) //// val itemIds = this.arguments?.getStringArray(BundleKey.ITEM_IDS.value)
//// dataListFragment.setData(dataType, itemIds) //// dataListFragment.setData(dataType, itemIds)
//// ////
//// showFragment(dataListFragment) //// showFragment(dataListFragment)
//// ////
//// } // }
}
fun showFragment(fragment: Fragment) { fun showFragment(fragment: Fragment, fragmentManager: FragmentManager) {
val fragmentTransaction = requireFragmentManager().beginTransaction() val fragmentTransaction = fragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.container, fragment) fragmentTransaction.replace(R.id.frame_container, fragment)
fragmentTransaction.commit() fragmentTransaction.commit()
} }

@ -278,7 +278,7 @@ class HandHistoryAdapter(
} }
layout.setOnClickListener { layout.setOnClickListener {
delegate?.onRowSelected(this.currentPosition, row) delegate?.onRowSelected(this.currentPosition, row, layout.tag as Int)
} }
} }
@ -505,6 +505,7 @@ class HandHistoryAdapter(
init { init {
itemView.playerImage.tag = PlayerSetupRow.Tag.PLAYER.ordinal itemView.playerImage.tag = PlayerSetupRow.Tag.PLAYER.ordinal
itemView.ps_hand_layout.tag = PlayerSetupRow.Tag.HAND.ordinal
// itemView.ps_player_button.pointerIcon = // itemView.ps_player_button.pointerIcon =
// itemView.ps_player_button.ti = itemView.resources.getDrawable(R.drawable.circle, null) // itemView.ps_player_button.ti = itemView.resources.getDrawable(R.drawable.circle, null)

@ -138,10 +138,12 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
Timber.d("Current selection is ${selection.index} / ${selection.tag}") Timber.d("Current selection is ${selection.index} / ${selection.tag}")
val row = this.model.rowRepresentableForPosition(it.index) as HandHistoryRow val row = this.model.rowRepresentableForPosition(it.index) as HandHistoryRow
row.onSelect(selection.tag)
val keyboard = row.keyboardForTag(it.tag)
row.keyboardForTag(it.tag)?.let { keyboard -> keyboard?.let { kb ->
when (keyboard) { when (kb) {
HHKeyboard.ACTION -> { HHKeyboard.ACTION -> {
configureActionKeyboard() configureActionKeyboard()
} }
@ -151,7 +153,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
else -> {} else -> {}
} }
this.showKeyboard(keyboard) { this.showKeyboard(kb) {
this.scrollToPosition(selection.index) this.scrollToPosition(selection.index)
} }
@ -471,7 +473,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index) this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index)
} }
/*** /***
* Configures the action keyboard: * Configures the action keyboard:
* - Sets the available actions * - Sets the available actions

@ -14,4 +14,5 @@ interface HandHistoryRow : RowRepresentable {
fun amountForTag(handHistory: HandHistory, tag: Int): Double? { return null } fun amountForTag(handHistory: HandHistory, tag: Int): Double? { return null }
fun onSelect(tag: Int) {}
} }

@ -102,4 +102,11 @@ class PlayerSetupRow(var hero: Boolean = false,
this.playerSetup?.stack = amount this.playerSetup?.stack = amount
} }
override fun onSelect(tag: Int) {
// Removes the card limit when the user taps again on a non empty card count
if (tag == Tag.HAND.ordinal && this.maxCards != null && this.cardCount > 0) {
this.maxCards = null
}
}
} }

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container" android:id="@+id/frame_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">

Loading…
Cancel
Save