commit
b1fce6a99d
@ -0,0 +1,34 @@ |
||||
package net.pokeranalytics.android.calculus |
||||
|
||||
import net.pokeranalytics.android.util.TextFormat |
||||
import java.util.* |
||||
|
||||
/** |
||||
* ComputedStat contains a [stat] and their associated [value] |
||||
*/ |
||||
class ComputedStat(var stat: Stat, var value: Double, var secondValue: Double? = null, var currency: Currency? = null) { |
||||
|
||||
constructor(stat: Stat, value: Double, previousValue: Double?) : this(stat, value) { |
||||
if (previousValue != null) { |
||||
this.variation = (value - previousValue) / previousValue |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* The value used to get evolution dataset |
||||
*/ |
||||
var progressValue: Double? = null |
||||
|
||||
/** |
||||
* The variation of the stat |
||||
*/ |
||||
var variation: Double? = null |
||||
|
||||
/** |
||||
* Formats the value of the stat to be suitable for display |
||||
*/ |
||||
fun format(): TextFormat { |
||||
return this.stat.format(this.value, this.secondValue, this.currency) |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,118 @@ |
||||
package net.pokeranalytics.android.calculus.bankroll |
||||
|
||||
import io.realm.Realm |
||||
import io.realm.RealmResults |
||||
import kotlinx.coroutines.Dispatchers |
||||
import kotlinx.coroutines.GlobalScope |
||||
import kotlinx.coroutines.async |
||||
import kotlinx.coroutines.launch |
||||
import net.pokeranalytics.android.model.realm.Bankroll |
||||
import net.pokeranalytics.android.model.realm.ComputableResult |
||||
import net.pokeranalytics.android.model.realm.Transaction |
||||
import timber.log.Timber |
||||
import java.util.* |
||||
import kotlin.coroutines.CoroutineContext |
||||
|
||||
object BankrollReportManager { |
||||
|
||||
val coroutineContext: CoroutineContext |
||||
get() = Dispatchers.Main |
||||
|
||||
private var reports: MutableMap<String?, BankrollReport> = mutableMapOf() |
||||
|
||||
private var computableResults: RealmResults<ComputableResult> |
||||
private var bankrolls: RealmResults<Bankroll> |
||||
private var transactions: RealmResults<Transaction> |
||||
|
||||
init { |
||||
|
||||
val realm = Realm.getDefaultInstance() |
||||
computableResults = realm.where(ComputableResult::class.java).findAll() |
||||
bankrolls = realm.where(Bankroll::class.java).findAll() |
||||
transactions = realm.where(Transaction::class.java).findAll() |
||||
|
||||
initializeListeners() |
||||
realm.close() |
||||
} |
||||
|
||||
/** |
||||
* Listens to all objects that might have an impact on any bankroll report |
||||
*/ |
||||
private fun initializeListeners() { |
||||
|
||||
this.computableResults.addChangeListener { t, changeSet -> |
||||
val indexes = changeSet.changes.plus(changeSet.insertions).toList() |
||||
val bankrolls = indexes.mapNotNull { t[it]?.session?.bankroll }.toSet() |
||||
this.updateBankrolls(bankrolls) |
||||
} |
||||
this.bankrolls.addChangeListener { t, changeSet -> |
||||
val indexes = changeSet.changes.plus(changeSet.insertions).toList() |
||||
val bankrolls = indexes.mapNotNull { t[it] }.toSet() |
||||
this.updateBankrolls(bankrolls) |
||||
} |
||||
this.transactions.addChangeListener { t, changeSet -> |
||||
val indexes = changeSet.changes.plus(changeSet.insertions).toList() |
||||
val bankrolls = indexes.mapNotNull { t[it]?.bankroll }.toSet() |
||||
this.updateBankrolls(bankrolls) |
||||
} |
||||
} |
||||
|
||||
fun reportForBankroll(bankrollId: String?, handler: (BankrollReport) -> Unit) { |
||||
|
||||
Timber.d("Request bankroll report for bankrollId = $bankrollId") |
||||
// if the report exists, return it |
||||
val existingReport: BankrollReport? = this.reports[bankrollId] |
||||
if (existingReport != null) { |
||||
handler(existingReport) |
||||
return |
||||
} |
||||
|
||||
// otherwise compute it |
||||
GlobalScope.launch(coroutineContext) { |
||||
|
||||
var report: BankrollReport? = null |
||||
val coroutine = GlobalScope.async { |
||||
val s = Date() |
||||
Timber.d(">>>>> start computing bankroll...") |
||||
|
||||
val realm = Realm.getDefaultInstance() |
||||
|
||||
val setup = BankrollReportSetup(bankrollId) |
||||
report = BankrollCalculator.computeReport(realm, setup) |
||||
|
||||
realm.close() |
||||
|
||||
val e = Date() |
||||
val duration = (e.time - s.time) / 1000.0 |
||||
Timber.d(">>>>> ended in $duration seconds") |
||||
|
||||
} |
||||
coroutine.await() |
||||
|
||||
report?.let { |
||||
handler(it) |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Notifies the manager of cases not managed by RealmResults listener, such as deletions |
||||
*/ |
||||
fun notifyBankrollReportImpact(bankrollId: String) { |
||||
this.reports.remove(bankrollId) |
||||
this.reports.remove(null) |
||||
} |
||||
|
||||
private fun updateBankrolls(bankrolls: Set<Bankroll>) { |
||||
this.invalidateReport(bankrolls) |
||||
} |
||||
|
||||
private fun invalidateReport(bankrolls: Set<Bankroll>) { |
||||
this.reports.remove(null) |
||||
bankrolls.forEach { br -> |
||||
this.reports.remove(br.id) |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,39 @@ |
||||
package net.pokeranalytics.android.model.utils |
||||
|
||||
import io.realm.Realm |
||||
import net.pokeranalytics.android.model.realm.Session |
||||
import net.pokeranalytics.android.model.realm.Transaction |
||||
import net.pokeranalytics.android.model.realm.TransactionType |
||||
import java.util.* |
||||
|
||||
class DataUtils { |
||||
|
||||
companion object { |
||||
|
||||
/** |
||||
* Returns true if the provided parameters doesn't correspond to an existing session |
||||
*/ |
||||
fun sessionCount(realm: Realm, startDate: Date, endDate: Date, net: Double): Int { |
||||
val sessions = realm.where(Session::class.java) |
||||
.equalTo("startDate", startDate) |
||||
.equalTo("endDate", endDate) |
||||
.equalTo("result.net", net) |
||||
.findAll() |
||||
return sessions.size |
||||
} |
||||
|
||||
/** |
||||
* Returns true if the provided parameters doesn't correspond to an existing transaction |
||||
*/ |
||||
fun transactionUnicityCheck(realm: Realm, date: Date, amount: Double, type: TransactionType): Boolean { |
||||
val transactions = realm.where(Transaction::class.java) |
||||
.equalTo("date", date) |
||||
.equalTo("amount", amount) |
||||
.equalTo("type.id", type.id) |
||||
.findAll() |
||||
return transactions.isEmpty() |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -1,21 +0,0 @@ |
||||
package net.pokeranalytics.android.model.utils |
||||
|
||||
import io.realm.Realm |
||||
import net.pokeranalytics.android.model.realm.Session |
||||
import java.util.* |
||||
|
||||
class SessionUtils { |
||||
|
||||
companion object { |
||||
|
||||
/** |
||||
* Returns true if the provided parameters doesn't correspond to an existing session |
||||
*/ |
||||
fun unicityCheck(realm: Realm, startDate: Date, endDate: Date, net: Double) : Boolean { |
||||
val sessions = realm.where(Session::class.java).equalTo("startDate", startDate).equalTo("endDate", endDate).equalTo("result.net", net).findAll() |
||||
return sessions.isEmpty() |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,58 @@ |
||||
package net.pokeranalytics.android.ui.activity |
||||
|
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import android.os.Bundle |
||||
import androidx.fragment.app.Fragment |
||||
import kotlinx.android.synthetic.main.activity_filters_list.* |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
||||
import net.pokeranalytics.android.ui.fragment.FiltersListFragment |
||||
import net.pokeranalytics.android.ui.interfaces.FilterActivityRequestCode |
||||
|
||||
class FiltersListActivity : PokerAnalyticsActivity() { |
||||
|
||||
enum class IntentKey(val keyName: String) { |
||||
DATA_TYPE("DATA_TYPE"), |
||||
LIVE_DATA_TYPE("LIVE_DATA_TYPE"), |
||||
ITEM_DELETED("ITEM_DELETED"), |
||||
SHOW_ADD_BUTTON("SHOW_ADD_BUTTON"), |
||||
} |
||||
|
||||
companion object { |
||||
fun newInstance(context: Context, dataType: Int) { |
||||
context.startActivity(getIntent(context, dataType)) |
||||
} |
||||
|
||||
fun newSelectInstance(fragment: Fragment, dataType: Int, showAddButton: Boolean = true) { |
||||
val context = fragment.requireContext() |
||||
fragment.startActivityForResult(getIntent(context, dataType, showAddButton), FilterActivityRequestCode.SELECT_FILTER.ordinal) |
||||
} |
||||
|
||||
private fun getIntent(context: Context, dataType: Int, showAddButton: Boolean = true): Intent { |
||||
val intent = Intent(context, FiltersListActivity::class.java) |
||||
intent.putExtra(IntentKey.DATA_TYPE.keyName, dataType) |
||||
intent.putExtra(IntentKey.SHOW_ADD_BUTTON.keyName, showAddButton) |
||||
return intent |
||||
} |
||||
} |
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) { |
||||
super.onCreate(savedInstanceState) |
||||
setContentView(R.layout.activity_filters_list) |
||||
|
||||
initUI() |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
val dataType = intent.getIntExtra(IntentKey.DATA_TYPE.keyName, 0) |
||||
val showAddButton = intent.getBooleanExtra(IntentKey.SHOW_ADD_BUTTON.keyName, true) |
||||
val fragment = filtersListFragment as FiltersListFragment |
||||
fragment.setData(dataType) |
||||
fragment.updateUI(showAddButton) |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,33 @@ |
||||
package net.pokeranalytics.android.ui.activity |
||||
|
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import android.os.Bundle |
||||
import androidx.fragment.app.Fragment |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
||||
|
||||
class Top10Activity : PokerAnalyticsActivity() { |
||||
|
||||
companion object { |
||||
fun newInstance(context: Context) { |
||||
val intent = Intent(context, Top10Activity::class.java) |
||||
context.startActivity(intent) |
||||
} |
||||
|
||||
/** |
||||
* Create a new instance for result |
||||
*/ |
||||
fun newInstanceForResult(fragment: Fragment, requestCode: Int) { |
||||
val intent = Intent(fragment.requireContext(), Top10Activity::class.java) |
||||
fragment.startActivityForResult(intent, requestCode) |
||||
} |
||||
|
||||
} |
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) { |
||||
super.onCreate(savedInstanceState) |
||||
setContentView(R.layout.activity_top_10) |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,112 @@ |
||||
package net.pokeranalytics.android.ui.fragment |
||||
|
||||
import android.app.Activity |
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import io.realm.RealmResults |
||||
import net.pokeranalytics.android.model.LiveData |
||||
import net.pokeranalytics.android.model.interfaces.Deletable |
||||
import net.pokeranalytics.android.model.interfaces.Identifiable |
||||
import net.pokeranalytics.android.model.realm.Filter |
||||
import net.pokeranalytics.android.ui.activity.EditableDataActivity |
||||
import net.pokeranalytics.android.ui.activity.FiltersActivity |
||||
import net.pokeranalytics.android.ui.interfaces.FilterHandler.Companion.INTENT_FILTER_UPDATE_FILTER_UI |
||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||
import net.pokeranalytics.android.ui.view.RowViewType |
||||
import net.pokeranalytics.android.util.Preferences |
||||
import timber.log.Timber |
||||
|
||||
|
||||
open class FiltersListFragment : DataListFragment() { |
||||
|
||||
private var identifiableClass: Class<out Deletable> = Filter::class.java |
||||
private var dataType: LiveData = LiveData.FILTER |
||||
private lateinit var items: RealmResults<Filter> |
||||
|
||||
/** |
||||
* Set fragment data |
||||
*/ |
||||
override fun setData(dataType: Int) { |
||||
super.setData(dataType) |
||||
|
||||
this.dataType = LiveData.FILTER |
||||
this.identifiableClass = Filter::class.java |
||||
setToolbarTitle(this.dataType.pluralLocalizedTitle(requireContext())) |
||||
this.items = this.retrieveItems(getRealm()) as RealmResults<Filter> |
||||
} |
||||
|
||||
override fun rowRepresentableForPosition(position: Int): RowRepresentable? { |
||||
Timber.d("rowRepresentableForPosition: ${this.items[position] as RowRepresentable}") |
||||
return this.items[position] as RowRepresentable |
||||
} |
||||
|
||||
override fun numberOfRows(): Int { |
||||
return this.items.size |
||||
} |
||||
|
||||
override fun adapterRows(): List<RowRepresentable>? { |
||||
return items |
||||
} |
||||
|
||||
override fun viewTypeForPosition(position: Int): Int { |
||||
val viewType = (this.items[position] as RowRepresentable).viewType |
||||
return if (viewType != -1) viewType else RowViewType.DATA.ordinal |
||||
} |
||||
|
||||
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { |
||||
when (row) { |
||||
is Filter -> { |
||||
row.updateValue(value, row) |
||||
dataListAdapter.refreshRow(row) |
||||
updateFilterUIIfNecessary(requireContext(), row.id) |
||||
} |
||||
else -> super.onRowValueChanged(value, row) |
||||
} |
||||
} |
||||
|
||||
override fun onRowDeleted(row: RowRepresentable) { |
||||
when (row) { |
||||
is Filter -> { |
||||
val filterId = row.id |
||||
deleteItem(dataListAdapter, items, filterId) |
||||
if (filterId == Preferences.getActiveFilterId(requireContext())) { |
||||
Preferences.setActiveFilterId("", requireContext()) |
||||
updateFilterUIIfNecessary(requireContext(), "") |
||||
} |
||||
} |
||||
else -> super.onRowDeleted(row) |
||||
} |
||||
} |
||||
|
||||
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
||||
when (row) { |
||||
is Filter -> { |
||||
if (fromAction) { |
||||
row.startEditing(null, this) |
||||
} else { |
||||
val intent = Intent() |
||||
intent.putExtra(FiltersActivity.IntentKey.FILTER_ID.keyName, row.id) |
||||
activity?.setResult(Activity.RESULT_OK, intent) |
||||
activity?.finish() |
||||
} |
||||
} |
||||
else -> { |
||||
val identifier = (row as Identifiable).id |
||||
EditableDataActivity.newInstanceForResult(this, this.dataType, identifier, REQUEST_CODE_DETAILS) |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Update filter UI |
||||
*/ |
||||
fun updateFilterUIIfNecessary(context: Context, filterId: String) { |
||||
if (filterId == Preferences.getActiveFilterId(context)) { |
||||
// Send broadcast |
||||
val intent = Intent() |
||||
intent.action = INTENT_FILTER_UPDATE_FILTER_UI |
||||
context.sendBroadcast(intent) |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,175 @@ |
||||
package net.pokeranalytics.android.ui.fragment |
||||
|
||||
import android.os.Bundle |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import com.google.android.material.tabs.TabLayout |
||||
import io.realm.RealmResults |
||||
import io.realm.kotlin.where |
||||
import kotlinx.android.synthetic.main.fragment_top_10.* |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.model.realm.Session |
||||
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
||||
import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource |
||||
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
||||
import net.pokeranalytics.android.ui.fragment.components.RealmFragment |
||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||
import net.pokeranalytics.android.ui.view.RowViewType |
||||
import net.pokeranalytics.android.ui.view.SmoothScrollLinearLayoutManager |
||||
|
||||
|
||||
class Top10Fragment : RealmFragment(), RowRepresentableDataSource, RowRepresentableDelegate { |
||||
|
||||
private enum class Tab { |
||||
CASH_GAMES, |
||||
TOURNAMENTS |
||||
} |
||||
|
||||
companion object { |
||||
fun newInstance(): Top10Fragment { |
||||
val fragment = Top10Fragment() |
||||
val bundle = Bundle() |
||||
fragment.arguments = bundle |
||||
return fragment |
||||
} |
||||
} |
||||
|
||||
private lateinit var positiveSessions: RealmResults<Session> |
||||
private lateinit var dataListAdapter: RowRepresentableAdapter |
||||
|
||||
private var realmCashGames: List<Session> = mutableListOf() |
||||
private var realmTournaments: List<Session> = mutableListOf() |
||||
|
||||
private var currentTab: Tab = Tab.CASH_GAMES |
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||
super.onCreateView(inflater, container, savedInstanceState) |
||||
return inflater.inflate(R.layout.fragment_top_10, container, false) |
||||
} |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
initUI() |
||||
initData() |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
|
||||
dataListAdapter = RowRepresentableAdapter(this, this) |
||||
recyclerView.adapter = dataListAdapter |
||||
|
||||
setDisplayHomeAsUpEnabled(true) |
||||
|
||||
tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { |
||||
override fun onTabSelected(tab: TabLayout.Tab) { |
||||
when (tab.position) { |
||||
0 -> { |
||||
currentTab = Tab.CASH_GAMES |
||||
dataListAdapter.notifyDataSetChanged() |
||||
} |
||||
1 -> { |
||||
currentTab = Tab.TOURNAMENTS |
||||
} |
||||
} |
||||
dataListAdapter.notifyDataSetChanged() |
||||
} |
||||
|
||||
override fun onTabUnselected(tab: TabLayout.Tab) { |
||||
} |
||||
|
||||
override fun onTabReselected(tab: TabLayout.Tab) { |
||||
} |
||||
}) |
||||
|
||||
|
||||
val viewManager = SmoothScrollLinearLayoutManager(requireContext()) |
||||
recyclerView.apply { |
||||
setHasFixedSize(true) |
||||
layoutManager = viewManager |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Init data |
||||
*/ |
||||
private fun initData() { |
||||
|
||||
this.positiveSessions = getRealm().where<Session>() |
||||
.isNotNull("endDate") |
||||
.greaterThan("result.net", 0.0) |
||||
.findAll() |
||||
|
||||
updateTop10() |
||||
|
||||
} |
||||
|
||||
private fun updateTop10() { |
||||
|
||||
val cashGames = mutableListOf<Session>() |
||||
val tournaments = mutableListOf<Session>() |
||||
|
||||
// filter by type: cash game or tournament |
||||
this.positiveSessions.forEach { |
||||
when (it.type) { |
||||
Session.Type.CASH_GAME.ordinal -> { |
||||
cashGames.add(it) |
||||
} |
||||
else -> { |
||||
tournaments.add(it) |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Sort by rated net |
||||
val sortedCashGames = cashGames.sortedByDescending { |
||||
it.computableResult?.ratedNet |
||||
}.toMutableList() |
||||
val sortedTournaments = tournaments.sortedByDescending { |
||||
it.computableResult?.ratedNet |
||||
}.toMutableList() |
||||
|
||||
// Keep 10 items |
||||
if (sortedCashGames.size > 10) { |
||||
sortedCashGames.subList(10, sortedCashGames.size).clear() |
||||
} |
||||
if (sortedTournaments.size > 10) { |
||||
sortedTournaments.subList(10, sortedTournaments.size).clear() |
||||
} |
||||
|
||||
this.realmCashGames = sortedCashGames |
||||
this.realmTournaments = sortedTournaments |
||||
|
||||
dataListAdapter.notifyDataSetChanged() |
||||
} |
||||
|
||||
override fun adapterRows(): List<RowRepresentable>? { |
||||
return when (currentTab) { |
||||
Tab.CASH_GAMES -> realmCashGames |
||||
Tab.TOURNAMENTS -> realmTournaments |
||||
} |
||||
} |
||||
|
||||
override fun rowRepresentableForPosition(position: Int): RowRepresentable? { |
||||
return when (currentTab) { |
||||
Tab.CASH_GAMES -> realmCashGames[position] |
||||
Tab.TOURNAMENTS -> realmTournaments[position] |
||||
} |
||||
} |
||||
|
||||
override fun numberOfRows(): Int { |
||||
return when (currentTab) { |
||||
Tab.CASH_GAMES -> realmCashGames.size |
||||
Tab.TOURNAMENTS -> realmTournaments.size |
||||
} |
||||
} |
||||
|
||||
override fun viewTypeForPosition(position: Int): Int { |
||||
return RowViewType.ROW_TOP_10.ordinal |
||||
} |
||||
|
||||
} |
||||
@ -1,48 +0,0 @@ |
||||
package net.pokeranalytics.android.ui.fragment.components.bottomsheet |
||||
|
||||
enum class BottomSheetType { |
||||
NONE, |
||||
LIST, |
||||
LIST_STATIC, |
||||
LIST_GAME, |
||||
DOUBLE_LIST, |
||||
MULTI_SELECTION, |
||||
GRID, |
||||
EDIT_TEXT, |
||||
EDIT_TEXT_MULTI_LINES, |
||||
DOUBLE_EDIT_TEXT, |
||||
NUMERIC_TEXT, |
||||
SUM; |
||||
|
||||
fun newInstance(): BottomSheetFragment { |
||||
return when (this) { |
||||
NONE -> BottomSheetFragment() |
||||
LIST -> BottomSheetListFragment() |
||||
LIST_STATIC -> BottomSheetStaticListFragment() |
||||
LIST_GAME -> BottomSheetListGameFragment() |
||||
DOUBLE_LIST -> BottomSheetListGameFragment() |
||||
MULTI_SELECTION -> BottomSheetMultiSelectionFragment() |
||||
GRID -> BottomSheetTableSizeGridFragment() |
||||
EDIT_TEXT -> BottomSheetEditTextFragment() |
||||
EDIT_TEXT_MULTI_LINES -> BottomSheetEditTextMultiLinesFragment() |
||||
DOUBLE_EDIT_TEXT -> BottomSheetDoubleEditTextFragment() |
||||
NUMERIC_TEXT -> BottomSheetNumericTextFragment() |
||||
SUM -> BottomSheetSumFragment() |
||||
} |
||||
} |
||||
|
||||
val validationRequired: Boolean |
||||
get() = when (this) { |
||||
LIST, LIST_GAME, LIST_STATIC, GRID, DOUBLE_LIST -> false |
||||
else -> true |
||||
} |
||||
|
||||
val clearRequired: Boolean |
||||
get() = true |
||||
|
||||
val addRequired: Boolean |
||||
get() = when (this) { |
||||
EDIT_TEXT, NUMERIC_TEXT, DOUBLE_EDIT_TEXT, EDIT_TEXT_MULTI_LINES, GRID, LIST_STATIC, SUM -> false |
||||
else -> true |
||||
} |
||||
} |
||||
@ -0,0 +1,50 @@ |
||||
package net.pokeranalytics.android.ui.fragment.components.input |
||||
|
||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||
|
||||
enum class InputFragmentType { |
||||
NONE, |
||||
LIST, |
||||
LIST_STATIC, |
||||
LIST_GAME, |
||||
DOUBLE_LIST, |
||||
MULTI_SELECTION, |
||||
GRID, |
||||
EDIT_TEXT, |
||||
EDIT_TEXT_MULTI_LINES, |
||||
DOUBLE_EDIT_TEXT, |
||||
NUMERIC_TEXT, |
||||
SUM; |
||||
|
||||
fun newInstance(row: RowRepresentable): InputFragment { |
||||
return when (this) { |
||||
NONE -> InputFragment(row) |
||||
LIST -> InputListFragment(row) |
||||
LIST_STATIC -> InputStaticListFragment(row) |
||||
LIST_GAME -> InputListGameFragment(row) |
||||
DOUBLE_LIST -> InputListGameFragment(row) |
||||
MULTI_SELECTION -> InputMultiSelectionFragment(row) |
||||
GRID -> InputTableSizeGridFragment(row) |
||||
EDIT_TEXT -> InputEditTextFragment(row) |
||||
EDIT_TEXT_MULTI_LINES -> InputEditTextMultiLinesFragment(row) |
||||
DOUBLE_EDIT_TEXT -> InputDoubleEditTextFragment(row) |
||||
NUMERIC_TEXT -> InputNumericTextFragment(row) |
||||
SUM -> InputSumFragment(row) |
||||
} |
||||
} |
||||
|
||||
val validationRequired: Boolean |
||||
get() = when (this) { |
||||
LIST, LIST_GAME, LIST_STATIC, GRID, DOUBLE_LIST -> false |
||||
else -> true |
||||
} |
||||
|
||||
val clearRequired: Boolean |
||||
get() = true |
||||
|
||||
val addRequired: Boolean |
||||
get() = when (this) { |
||||
EDIT_TEXT, NUMERIC_TEXT, DOUBLE_EDIT_TEXT, EDIT_TEXT_MULTI_LINES, GRID, LIST_STATIC, SUM -> false |
||||
else -> true |
||||
} |
||||
} |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue