Laurent 5 years ago
parent 27b1f46285
commit 9e1eae3a17
  1. 12
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  2. 26
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerFragment.kt

@ -69,11 +69,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
companion object {
fun newInstance(
id: String? = null,
configurationId: String? = null,
attached: Boolean = false
): HandHistoryFragment {
fun newInstance(id: String? = null, configurationId: String? = null, attached: Boolean = false): HandHistoryFragment {
val fragment = HandHistoryFragment()
val bundle = Bundle()
bundle.putSerializable(BundleKey.HAND_HISTORY_ID.value, id)
@ -94,11 +90,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
super.onCreateView(inflater, container, savedInstanceState)
return inflater.inflate(R.layout.fragment_hand_history, container, false)
}

@ -27,7 +27,6 @@ class ReplayerFragment : RealmFragment() {
bundle.putSerializable(BundleKey.HAND_HISTORY_ID.value, handHistoryId)
fragment.arguments = bundle
return fragment
}
}
@ -36,6 +35,14 @@ class ReplayerFragment : RealmFragment() {
*/
private lateinit var model: ReplayerModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.model = activity?.run {
ViewModelProviders.of(this)[ReplayerModel::class.java]
} ?: throw Exception("Invalid Activity")
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
super.onCreateView(inflater, container, savedInstanceState)
@ -48,15 +55,6 @@ class ReplayerFragment : RealmFragment() {
initUI()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.model = activity?.run {
ViewModelProviders.of(this)[ReplayerModel::class.java]
} ?: throw Exception("Invalid Activity")
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.toolbar_replayer, menu)
@ -79,17 +77,9 @@ class ReplayerFragment : RealmFragment() {
}
private fun initData() {
val id = arguments?.getString(BundleKey.HAND_HISTORY_ID.value) ?: throw PAIllegalStateException("Attempt to start a replayer without hh id")
val hh = getRealm().findById<HandHistory>(id) ?: throw PAIllegalStateException("hh with id: $id not found")
loadHand(hh)
// TODO change
// val hh = getRealm().where(HandHistory::class.java).findFirst()!!
// Timber.d(">>> Load HH with player count = ${hh.numberOfPlayers}")
// this.model.setHandHistory(hh)
// val hhm = ViewModelProviders.of(this)[HandHistoryViewModel::class.java]
}
private fun initUI() {

Loading…
Cancel
Save