Merge branch 'master' of gitlab.com:stax-river/poker-analytics

feature/top10
Aurelien Hubert 7 years ago
commit b2455ac3f6
  1. 15
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  2. 20
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetMultiSelectionFragment.kt
  3. 8
      app/src/main/java/net/pokeranalytics/android/ui/view/RowRepresentable.kt
  4. 3
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/SessionRow.kt

@ -559,12 +559,14 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre
} ?: run { } ?: run {
NULL_TEXT NULL_TEXT
} }
SessionRow.TOURNAMENT_FEATURE -> tournamentFeatures?.let { SessionRow.TOURNAMENT_FEATURE -> {
if (it.size > 2) { if (tournamentFeatures.size > 2) {
"${it.size}" "${tournamentFeatures.subList(0,2).joinToString {
it.name
}}, ..."
} else { } else {
it.joinToString {feature -> tournamentFeatures.joinToString {
feature.name it.name
} }
} }
} }
@ -807,7 +809,8 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre
SessionRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName? SessionRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName?
SessionRow.TOURNAMENT_TYPE -> tournamentType = value as Int? SessionRow.TOURNAMENT_TYPE -> tournamentType = value as Int?
SessionRow.TOURNAMENT_FEATURE -> value?.let { SessionRow.TOURNAMENT_FEATURE -> value?.let {
tournamentFeatures.add(value as TournamentFeature) tournamentFeatures = RealmList()
tournamentFeatures.addAll((it as ArrayList<TournamentFeature>))
} }
} }
realm.commitTransaction() realm.commitTransaction()

@ -2,8 +2,10 @@ package net.pokeranalytics.android.ui.fragment.components.bottomsheet
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import io.realm.RealmList
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType import net.pokeranalytics.android.ui.view.RowViewType
import timber.log.Timber
/** /**
* Manage multiple items selection in a bottom sheet list * Manage multiple items selection in a bottom sheet list
@ -12,12 +14,6 @@ open class BottomSheetMultiSelectionFragment : BottomSheetListFragment() {
private val selectedRows: ArrayList<RowRepresentable> = ArrayList() private val selectedRows: ArrayList<RowRepresentable> = ArrayList()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initData()
initUI()
}
override fun viewTypeForPosition(position: Int): Int { override fun viewTypeForPosition(position: Int): Int {
return RowViewType.TITLE_CHECK.ordinal return RowViewType.TITLE_CHECK.ordinal
} }
@ -28,13 +24,11 @@ open class BottomSheetMultiSelectionFragment : BottomSheetListFragment() {
} }
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) {
if (selectedRows.contains(row)) { if (selectedRows.contains(row)) {
selectedRows.remove(row) selectedRows.remove(row)
} else { } else {
selectedRows.add(row) selectedRows.add(row)
} }
dataAdapter.refreshRow(row) dataAdapter.refreshRow(row)
/* /*
@ -52,4 +46,14 @@ open class BottomSheetMultiSelectionFragment : BottomSheetListFragment() {
return selectedRows.contains(row) return selectedRows.contains(row)
} }
override fun initData() {
super.initData()
getData().first().defaultValue?.let {
(it as RealmList<*>).forEach{row ->
selectedRows.add(row as RowRepresentable)
}
}
}
} }

@ -14,6 +14,14 @@ interface RowRepresentable : Displayable {
return NULL_TEXT return NULL_TEXT
} }
var isSelected: Boolean
get() {
return false
}
set(value) {
}
} }
/** /**

@ -132,7 +132,8 @@ enum class SessionRow : RowRepresentable {
BLINDS -> BottomSheetType.DOUBLE_EDIT_TEXT BLINDS -> BottomSheetType.DOUBLE_EDIT_TEXT
GAME -> BottomSheetType.LIST_GAME GAME -> BottomSheetType.LIST_GAME
TOURNAMENT_TYPE -> BottomSheetType.LIST_STATIC TOURNAMENT_TYPE -> BottomSheetType.LIST_STATIC
LOCATION, BANKROLL, TOURNAMENT_NAME, TOURNAMENT_FEATURE -> BottomSheetType.LIST LOCATION, BANKROLL, TOURNAMENT_NAME -> BottomSheetType.LIST
TOURNAMENT_FEATURE -> BottomSheetType.MULTI_SELECTION
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

Loading…
Cancel
Save