add tournament name / feature management

feature/top10
Razmig Sarkissian 7 years ago
parent 3f9c0cfb11
commit d888798044
  1. 5
      app/src/main/java/net/pokeranalytics/android/model/LiveData.kt
  2. 10
      app/src/main/java/net/pokeranalytics/android/model/TournamentKind.kt
  3. 6
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  4. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/EditableDataFragment.kt
  5. 12
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetFragment.kt
  6. 74
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetStaticListFragment.kt
  7. 3
      app/src/main/java/net/pokeranalytics/android/ui/view/RowRepresentableEditDescriptor.kt
  8. 3
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/SessionRow.kt
  9. 8
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/SettingRow.kt
  10. 7
      app/src/main/res/values/strings.xml

@ -1,5 +1,6 @@
package net.pokeranalytics.android.model package net.pokeranalytics.android.model
import android.content.Context
import io.realm.Realm import io.realm.Realm
import io.realm.RealmObject import io.realm.RealmObject
import io.realm.RealmResults import io.realm.RealmResults
@ -96,6 +97,10 @@ enum class LiveData : Localizable {
TRANSACTION_TYPE -> R.string.operation_types TRANSACTION_TYPE -> R.string.operation_types
} }
} }
fun newEntityLocalizedTitle(context: Context): String {
return "${context.getString(R.string.new_entity)} ${this.localizedTitle(context)}"
}
} }
/* /*

@ -2,11 +2,19 @@ package net.pokeranalytics.android.model
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
enum class TournamentKind : RowRepresentable { enum class TournamentKind : RowRepresentable {
MTT, MTT,
SNG; SNG;
companion object {
val all : List<TournamentKind>
get() {
return TournamentKind.values() as List<TournamentKind>
}
}
override val resId: Int? override val resId: Int?
get() { get() {
return when (this) { return when (this) {
@ -14,4 +22,6 @@ enum class TournamentKind : RowRepresentable {
SNG -> R.string.sng SNG -> R.string.sng
} }
} }
override val viewType: Int = RowViewType.TITLE.ordinal
} }

@ -553,7 +553,9 @@ open class Session : RealmObject(), SessionInterface, Savable,
} }
SessionRow.TOURNAMENT_KIND -> { SessionRow.TOURNAMENT_KIND -> {
// Add current tournament kind and tournament kind list // Add current tournament kind and tournament kind list
data.add(RowRepresentableEditDescriptor(tournamentKind)) data.add(RowRepresentableEditDescriptor(tournamentKind, staticData = TournamentKind.values().map {
it
}))
} }
SessionRow.TOURNAMENT_FEATURE -> { SessionRow.TOURNAMENT_FEATURE -> {
// Add current tournament feature and tournament features list // Add current tournament feature and tournament features list
@ -668,7 +670,7 @@ open class Session : RealmObject(), SessionInterface, Savable,
result = localResult result = localResult
} }
SessionRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName? SessionRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName?
SessionRow.TOURNAMENT_KIND -> tournamentKind = value as Int?
} }
realm.commitTransaction() realm.commitTransaction()
} }

@ -213,10 +213,10 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate,
this.liveDataType = LiveData.values()[dataType] this.liveDataType = LiveData.values()[dataType]
val proxyItem: RealmObject? = this.liveDataType.getData(this.getRealm(), primaryKey) val proxyItem: RealmObject? = this.liveDataType.getData(this.getRealm(), primaryKey)
proxyItem?.let { proxyItem?.let {
this.appBar.toolbar.title = "Update ${this.liveDataType.name.toLowerCase().capitalize()}" this.appBar.toolbar.title = "Update ${this.liveDataType.localizedTitle(this.parentActivity).toLowerCase().capitalize()}"
isUpdating = true isUpdating = true
} ?: run { } ?: run {
this.appBar.toolbar.title = "New ${this.liveDataType.name.toLowerCase().capitalize()}" this.appBar.toolbar.title = "New ${this.liveDataType.localizedTitle(this.parentActivity).toLowerCase().capitalize()}"
} }
this.item = this.liveDataType.updateOrCreate(this.getRealm(), primaryKey) this.item = this.liveDataType.updateOrCreate(this.getRealm(), primaryKey)
this.rowRepresentableAdapter = RowRepresentableAdapter( this.rowRepresentableAdapter = RowRepresentableAdapter(

@ -25,6 +25,7 @@ import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow
enum class BottomSheetType { enum class BottomSheetType {
NONE, NONE,
LIST, LIST,
LIST_STATIC,
LIST_GAME, LIST_GAME,
DOUBLE_LIST, DOUBLE_LIST,
GRID, GRID,
@ -64,6 +65,7 @@ open class BottomSheetFragment : BottomSheetDialogFragment() {
val bottomSheetFragment = when (row.bottomSheetType) { val bottomSheetFragment = when (row.bottomSheetType) {
BottomSheetType.LIST -> BottomSheetListFragment() BottomSheetType.LIST -> BottomSheetListFragment()
BottomSheetType.LIST_GAME -> BottomSheetListGameFragment() BottomSheetType.LIST_GAME -> BottomSheetListGameFragment()
BottomSheetType.LIST_STATIC -> BottomSheetStaticListFragment()
BottomSheetType.GRID -> BottomSheetTableSizeGridFragment() BottomSheetType.GRID -> BottomSheetTableSizeGridFragment()
BottomSheetType.DOUBLE_LIST -> BottomSheetListGameFragment() BottomSheetType.DOUBLE_LIST -> BottomSheetListGameFragment()
BottomSheetType.EDIT_TEXT -> BottomSheetEditTextFragment() BottomSheetType.EDIT_TEXT -> BottomSheetEditTextFragment()
@ -150,6 +152,16 @@ open class BottomSheetFragment : BottomSheetDialogFragment() {
LiveData.LOCATION.ordinal, LiveData.LOCATION.ordinal,
requestCode = REQUEST_CODE_ADD_NEW_OBJECT requestCode = REQUEST_CODE_ADD_NEW_OBJECT
) )
SessionRow.TOURNAMENT_NAME -> EditableDataActivity.newInstanceForResult(
this,
LiveData.TOURNAMENT_NAME.ordinal,
requestCode = REQUEST_CODE_ADD_NEW_OBJECT
)
SessionRow.TOURNAMENT_FEATURE -> EditableDataActivity.newInstanceForResult(
this,
LiveData.TOURNAMENT_FEATURE.ordinal,
requestCode = REQUEST_CODE_ADD_NEW_OBJECT
)
} }
true true
} }

@ -0,0 +1,74 @@
package net.pokeranalytics.android.ui.fragment.components.bottomsheet
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import io.realm.RealmResults
import kotlinx.android.synthetic.main.bottom_sheet_list.*
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.*
import net.pokeranalytics.android.R
import net.pokeranalytics.android.model.TournamentKind
import net.pokeranalytics.android.ui.adapter.LiveRowRepresentableDataSource
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
class BottomSheetStaticListFragment : BottomSheetFragment(), StaticRowRepresentableDataSource,
RowRepresentableDelegate {
private var staticRows: List<RowRepresentable> = emptyList()
private lateinit var dataAdapter: RowRepresentableAdapter
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initData()
initUI()
}
override fun onResume() {
super.onResume()
dataAdapter.notifyDataSetChanged()
}
override fun adapterRows(): List<RowRepresentable>? {
return this.staticRows
}
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) {
this.delegate.onRowValueChanged((row as TournamentKind).ordinal, this.row)
dismiss()
super.onRowSelected(position, row, fromAction)
}
/**
* Init data
*/
private fun initData() {
val bottomSheetData = this.getData()
if (bottomSheetData.isNotEmpty() && bottomSheetData.first().staticData != null) {
this.staticRows = bottomSheetData.first().staticData as List<RowRepresentable>
}
}
/**
* Init UI
*/
private fun initUI() {
LayoutInflater.from(requireContext()).inflate(R.layout.bottom_sheet_list, view?.bottomSheetContainer, true)
val viewManager = LinearLayoutManager(requireContext())
dataAdapter = RowRepresentableAdapter(this, this)
reyclerView.apply {
setHasFixedSize(true)
layoutManager = viewManager
adapter = dataAdapter
}
}
}

@ -9,5 +9,6 @@ class RowRepresentableEditDescriptor(
var defaultValue: Any? = null, var defaultValue: Any? = null,
var hint: Int? = null, var hint: Int? = null,
var inputType: Int? = null, var inputType: Int? = null,
var data: RealmResults<*>? = null var data: RealmResults<*>? = null,
var staticData: List<RowRepresentable>? = null
) )

@ -131,7 +131,8 @@ enum class SessionRow : RowRepresentable {
BUY_IN, TIPS -> BottomSheetType.SUM BUY_IN, TIPS -> BottomSheetType.SUM
BLINDS -> BottomSheetType.DOUBLE_EDIT_TEXT BLINDS -> BottomSheetType.DOUBLE_EDIT_TEXT
GAME -> BottomSheetType.LIST_GAME GAME -> BottomSheetType.LIST_GAME
LOCATION, BANKROLL, TOURNAMENT_KIND, TOURNAMENT_NAME, TOURNAMENT_FEATURE -> BottomSheetType.LIST TOURNAMENT_KIND -> BottomSheetType.LIST_STATIC
LOCATION, BANKROLL, TOURNAMENT_NAME, TOURNAMENT_FEATURE -> BottomSheetType.LIST
TABLE_SIZE -> BottomSheetType.GRID TABLE_SIZE -> BottomSheetType.GRID
COMMENT -> BottomSheetType.EDIT_TEXT_MULTI_LINES COMMENT -> BottomSheetType.EDIT_TEXT_MULTI_LINES
else -> BottomSheetType.NONE else -> BottomSheetType.NONE

@ -24,7 +24,8 @@ enum class SettingRow : RowRepresentable {
BANKROLL, BANKROLL,
GAME, GAME,
LOCATION, LOCATION,
TOURNAMENT_TYPE, TOURNAMENT_NAME,
TOURNAMENT_FEATURE,
// Terms // Terms
PRIVACY_POLICY, PRIVACY_POLICY,
@ -54,7 +55,7 @@ enum class SettingRow : RowRepresentable {
resId = R.string.data_management resId = R.string.data_management
) )
) )
rows.addAll(arrayListOf(BANKROLL, GAME, LOCATION, TOURNAMENT_TYPE)) rows.addAll(arrayListOf(BANKROLL, GAME, LOCATION, TOURNAMENT_NAME, TOURNAMENT_FEATURE))
rows.add(HeaderRowRepresentable(customViewType = RowViewType.HEADER_TITLE, resId = R.string.terms)) rows.add(HeaderRowRepresentable(customViewType = RowViewType.HEADER_TITLE, resId = R.string.terms))
rows.addAll(arrayListOf(PRIVACY_POLICY, TERMS_OF_USE, GDPR)) rows.addAll(arrayListOf(PRIVACY_POLICY, TERMS_OF_USE, GDPR))
@ -101,7 +102,8 @@ enum class SettingRow : RowRepresentable {
BANKROLL -> LiveData.BANKROLL BANKROLL -> LiveData.BANKROLL
GAME -> LiveData.GAME GAME -> LiveData.GAME
LOCATION -> LiveData.LOCATION LOCATION -> LiveData.LOCATION
TOURNAMENT_TYPE -> LiveData.TOURNAMENT_NAME TOURNAMENT_NAME -> LiveData.TOURNAMENT_NAME
TOURNAMENT_FEATURE -> LiveData.TOURNAMENT_FEATURE
else -> null else -> null
} }
} }

@ -734,9 +734,8 @@
<string name="save">Save</string> <string name="save">Save</string>
<string name="tournament_name">Tournament name</string> <string name="tournament_name">Tournament Name</string>
<string name="tournament_feature">Tournament feature</string> <string name="tournament_feature">Tournament Feature</string>
<string name="new_tournament_name">New tournament name</string> <string name="new_entity">New</string>
<string name="new_tournament_feature">New tournament feature</string>
</resources> </resources>

Loading…
Cancel
Save