Update BottomSheet value management

dev_raz_wip
Aurelien Hubert 7 years ago
parent 8e661c440a
commit 0fbe773cc0
  1. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  2. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/EditableDataFragment.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/SessionFragment.kt
  4. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetDoubleEditTextFragment.kt
  5. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetEditTextFragment.kt
  6. 16
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetFragment.kt
  7. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetSumFragment.kt
  8. 10
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetTableSizeGridFragment.kt

@ -293,7 +293,7 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource
data.add(BottomSheetData("", inputType = InputType.TYPE_CLASS_NUMBER))
data.add(BottomSheetData("", inputType = InputType.TYPE_CLASS_NUMBER))
}
SessionRow.TABLE_SIZE -> {}
SessionRow.TABLE_SIZE -> {data.add(BottomSheetData(tableSize))}
SessionRow.GAME -> {
// Add current game & games list
data.add(BottomSheetData(game, data = LiveData.GAME.items(realm)))

@ -55,7 +55,7 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate,
rowRepresentableAdapter.refreshRow(row)
}
override fun setValue(value: Any, row: RowRepresentable) {
override fun setValue(value: Any?, row: RowRepresentable) {
(this.item as RowEditable).updateValue(value, row)
this.getRealm().executeTransaction {
it.copyToRealmOrUpdate(this.item)

@ -93,7 +93,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, Bott
sessionAdapter.refreshRow(row)
}
override fun setValue(value: Any, row: RowRepresentable) {
override fun setValue(value: Any?, row: RowRepresentable) {
currentSession.updateValue(value, row)
sessionAdapter.refreshRow(row)
}

@ -26,7 +26,7 @@ class BottomSheetDoubleEditTextFragment : BottomSheetFragment() {
editText1.requestFocus()
}
override fun getValue(): Any {
override fun getValue(): Any? {
return values
}

@ -26,7 +26,7 @@ class BottomSheetEditTextFragment : BottomSheetFragment() {
editText1.requestFocus()
}
override fun getValue(): Any {
override fun getValue(): Any? {
return value
}

@ -24,7 +24,7 @@ enum class BottomSheetType {
interface BottomSheetDelegate {
fun clickOnAdd(row: RowRepresentable)
fun clickOnClear(row: RowRepresentable)
fun setValue(value: Any, row: RowRepresentable)
fun setValue(value: Any?, row: RowRepresentable)
}
@ -37,10 +37,10 @@ open class BottomSheetFragment : BottomSheetDialogFragment() {
companion object {
fun create(
fragmentManager: FragmentManager?,
row: RowRepresentable,
bottomSheetDelegate: BottomSheetDelegate,
data: ArrayList<BottomSheetData>
fragmentManager: FragmentManager?,
row: RowRepresentable,
bottomSheetDelegate: BottomSheetDelegate,
data: ArrayList<BottomSheetData>
): BottomSheetFragment {
val bottomSheetFragment = when (row.bottomSheetType) {
@ -62,7 +62,7 @@ open class BottomSheetFragment : BottomSheetDialogFragment() {
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_bottom_sheet,container,false)
return inflater.inflate(R.layout.fragment_bottom_sheet, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -114,8 +114,8 @@ open class BottomSheetFragment : BottomSheetDialogFragment() {
return data
}
open fun getValue(): Any {
return Any()
open fun getValue(): Any? {
return null
}
/**

@ -28,7 +28,7 @@ class BottomSheetSumFragment : BottomSheetFragment() {
editText1.requestFocus()
}
override fun getValue(): Any {
override fun getValue(): Any? {
return value
}

@ -15,6 +15,7 @@ class BottomSheetTableSizeGridFragment : BottomSheetFragment() {
private var dataList: ArrayList<String> = ArrayList()
private lateinit var dataAdapter: TableSizeGridAdapter
private var defaultSize: Int? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -27,11 +28,20 @@ class BottomSheetTableSizeGridFragment : BottomSheetFragment() {
dataAdapter.notifyDataSetChanged()
}
override fun getValue(): Any? {
return defaultSize
}
/**
* Init data
*/
private fun initData() {
val bottomSheetData = getData()
if (bottomSheetData.isNotEmpty() && bottomSheetData.first().defaultValue != null) {
defaultSize = bottomSheetData.first().defaultValue as Int?
}
dataList.add(getString(net.pokeranalytics.android.R.string.heads_up))
for (i in 3..10) {
dataList.add("$i-max")

Loading…
Cancel
Save