|
|
|
@ -9,7 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import kotlinx.android.synthetic.main.fragment_new_session.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_new_session.* |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.model.DataList |
|
|
|
import net.pokeranalytics.android.model.DataList |
|
|
|
import net.pokeranalytics.android.model.realm.* |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
import net.pokeranalytics.android.ui.activity.EditableDataActivity |
|
|
|
import net.pokeranalytics.android.ui.activity.EditableDataActivity |
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
import net.pokeranalytics.android.ui.adapter.components.DynamicListAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.components.DynamicListAdapter |
|
|
|
@ -22,7 +22,7 @@ import net.pokeranalytics.android.ui.fragment.components.DateTimePickerManager |
|
|
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
class NewSessionFragment : PokerAnalyticsFragment(), DynamicRowCallback, BottomSheetDelegate { |
|
|
|
class SessionFragment : PokerAnalyticsFragment(), DynamicRowCallback, BottomSheetDelegate { |
|
|
|
|
|
|
|
|
|
|
|
private lateinit var currentSession: Session |
|
|
|
private lateinit var currentSession: Session |
|
|
|
private lateinit var sessionAdapter : DynamicListAdapter |
|
|
|
private lateinit var sessionAdapter : DynamicListAdapter |
|
|
|
@ -75,31 +75,15 @@ class NewSessionFragment : PokerAnalyticsFragment(), DynamicRowCallback, BottomS |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun setValue(value: Any, row: DynamicRowInterface) { |
|
|
|
override fun setValue(value: Any, row: DynamicRowInterface) { |
|
|
|
when(row) { |
|
|
|
currentSession.setBottomSheetValue(value, row) |
|
|
|
SessionRow.GAME -> if (value is Game) currentSession.game = value |
|
|
|
sessionAdapter.refreshRow(row) |
|
|
|
SessionRow.BANKROLL -> if (value is Bankroll) currentSession.bankroll = value |
|
|
|
|
|
|
|
SessionRow.LOCATION -> if (value is Location) currentSession.location = value |
|
|
|
|
|
|
|
SessionRow.COMMENT -> if (value is String) currentSession.comment = value |
|
|
|
|
|
|
|
SessionRow.BLINDS -> if (value is ArrayList<*>) { |
|
|
|
|
|
|
|
currentSession.cgSmallBlind = (value[0] as String? ?: "0").toDouble() |
|
|
|
|
|
|
|
currentSession.cgBigBlind = (value[1] as String? ?: "0").toDouble() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.START_DATE -> if (value is Date) { |
|
|
|
|
|
|
|
val timeFrame = currentSession.timeFrame ?: TimeFrame() |
|
|
|
|
|
|
|
timeFrame.setDate(value, null) |
|
|
|
|
|
|
|
currentSession.timeFrame = timeFrame |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.END_DATE -> if (value is Date) { |
|
|
|
|
|
|
|
val timeFrame = currentSession.timeFrame ?: TimeFrame() |
|
|
|
|
|
|
|
timeFrame.setDate(timeFrame.startDate, value) |
|
|
|
|
|
|
|
currentSession.timeFrame = timeFrame |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sessionAdapter.notifyItemChanged(SessionRow.values().indexOf(row)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun initData() { |
|
|
|
private fun initData() { |
|
|
|
currentSession = Session() |
|
|
|
val realm = getRealm() |
|
|
|
|
|
|
|
realm.beginTransaction() |
|
|
|
|
|
|
|
currentSession = realm.createObject(Session::class.java, UUID.randomUUID().toString()) |
|
|
|
|
|
|
|
realm.commitTransaction() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |