|
|
|
|
@ -1,9 +1,7 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.modules.handhistory |
|
|
|
|
|
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
import android.view.* |
|
|
|
|
import androidx.lifecycle.Observer |
|
|
|
|
import androidx.lifecycle.ViewModelProviders |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_hand_history.* |
|
|
|
|
@ -39,6 +37,11 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
*/ |
|
|
|
|
private lateinit var handHistoryAdapter: HandHistoryAdapter |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* The fragment's menu |
|
|
|
|
*/ |
|
|
|
|
private var menu: Menu? = null |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
fun newInstance(id: String? = null): HandHistoryFragment { |
|
|
|
|
@ -153,6 +156,28 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
this.keyboard.setCardCentralizer(this.model) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) { |
|
|
|
|
menu?.clear() |
|
|
|
|
inflater?.inflate(R.menu.toolbar_hand_history, menu) |
|
|
|
|
updateMenuUI() |
|
|
|
|
super.onCreateOptionsMenu(menu, inflater) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Update menu UI |
|
|
|
|
*/ |
|
|
|
|
private fun updateMenuUI() { |
|
|
|
|
val titleResId = if (this.model.isEdited) R.string.save else R.string.edit |
|
|
|
|
this.menu?.findItem(R.id.edit_save)?.setTitle(titleResId) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem?): Boolean { |
|
|
|
|
when (item!!.itemId) { |
|
|
|
|
R.id.edit_save -> saveOrEdit() |
|
|
|
|
} |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun retrieveEditTextInputConnection(selection: HHSelection) { |
|
|
|
|
|
|
|
|
|
val handRow = this.model.rowRepresentableForPosition(selection.index) as? HandRowType |
|
|
|
|
@ -167,6 +192,15 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun saveOrEdit() { |
|
|
|
|
this.model.isEdited = !this.model.isEdited |
|
|
|
|
|
|
|
|
|
if (this.model.isEdited) { |
|
|
|
|
this.findNextActionToEdit(0) |
|
|
|
|
} |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun edit() { |
|
|
|
|
this.model.isEdited = true |
|
|
|
|
this.findNextActionToEdit(0) |
|
|
|
|
|