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

feature/top10
Razmig Sarkissian 7 years ago
commit 5301b81ebf
  1. BIN
      app/src/androidTest/assets/schema_0.realm
  2. 5
      app/src/androidTest/java/net/pokeranalytics/android/unitTests/FavoriteSessionUnitTest.kt
  3. 21
      app/src/main/java/net/pokeranalytics/android/calculus/Calculator.kt
  4. 8
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  5. 10
      app/src/main/java/net/pokeranalytics/android/model/utils/FavoriteSessionFinder.kt
  6. 32
      app/src/main/java/net/pokeranalytics/android/ui/fragment/SessionFragment.kt
  7. 5
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetFragment.kt
  8. 1
      app/src/main/res/layout/fragment_bottom_sheet.xml
  9. 8
      app/src/main/res/layout/fragment_session.xml
  10. 4
      app/src/main/res/values/styles.xml

@ -9,6 +9,7 @@ import net.pokeranalytics.android.model.utils.FavoriteSessionFinder
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
import java.util.*
@RunWith(AndroidJUnit4::class)
@ -25,6 +26,10 @@ class FavoriteSessionUnitTest : RealmInstrumentedUnitTest() {
val s2 = newSessionInstance(realm)
val s3 = newSessionInstance(realm)
s1.endDate = Date()
s2.endDate = Date()
s3.endDate = Date()
s1.cgBigBlind = 4.0
s2.cgBigBlind = 4.0
s3.cgBigBlind = 1.0

@ -2,6 +2,7 @@ package net.pokeranalytics.android.calculus
import net.pokeranalytics.android.calculus.Stat.*
import net.pokeranalytics.android.model.realm.ComputableResult
import net.pokeranalytics.android.model.realm.Filter
import net.pokeranalytics.android.model.realm.SessionSet
import timber.log.Timber
import java.util.*
@ -58,10 +59,19 @@ class Calculator {
companion object {
// fun computePreAggregation(sets: List<SessionSet>, options: Options): List<ComputedResults> {
// Timber.d("sets = ${sets.size}")
// return listOf()
// }
fun computeStatsWithFilters(filters: List<Filter>, options: Options): List<ComputedResults> {
var computableGroups: MutableList<ComputableGroup> = mutableListOf()
filters.forEach { filter ->
val results = filter.realm.where(ComputableResult::class.java).findAll()
val sets = filter.realm.where(SessionSet::class.java).findAll()
val group = ComputableGroup(filter.name, results, sets)
computableGroups.add(group)
}
return Calculator.computeGroups(computableGroups, options)
}
/**
* Computes all stats for list of Session sessionGroup
@ -176,7 +186,8 @@ class Calculator {
val sessionSets = computableGroup.sets
// Compute for each serie
val gHourlyDuration = sessionSets.sum(SessionSet.Field.NET_DURATION.identifier).toDouble() / 3600000 // (milliseconds to hours)
val gHourlyDuration =
sessionSets.sum(SessionSet.Field.NET_DURATION.identifier).toDouble() / 3600000 // (milliseconds to hours)
val gSum = sessionSets.sum(SessionSet.Field.RATED_NET.identifier).toDouble()
val gTotalHands = sessionSets.sum(SessionSet.Field.ESTIMATED_HANDS.identifier).toDouble()
val gBBSum = sessionSets.sum(SessionSet.Field.BB_NET.identifier).toDouble()

@ -321,8 +321,8 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
val computableResult = realm.createObject(ComputableResult::class.java)
computableResult.session = this
} // if a ComputableResult exists and the session is not completed, delete it
else if (this.startDate == null || this.endDate == null) {
this.computableResult?.deleteFromRealm()
else if ((this.startDate == null || this.endDate == null) && this.computableResult != null && this.computableResult.isValid) {
this.computableResult.deleteFromRealm()
}
// Update the ComputableResult
@ -441,9 +441,9 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
*/
fun restart() {
realm.executeTransaction {
// this.timeFrame?.paused = false
this.pauseDate = null
this.startDate = Date() // timeFrame?.setDate(Date(), null)
this.startDate = Date()
this.endDate = null
this.breakDuration = 0L
}
}

@ -26,22 +26,22 @@ fun Session.parameterRepresentation(context: Context): String {
*/
private fun Session.significantFields(): List<SessionRow> {
when (this.type) {
Session.Type.CASH_GAME.ordinal -> {
Session.Type.TOURNAMENT.ordinal -> {
return listOf(
SessionRow.GAME,
SessionRow.INITIAL_BUY_IN,
SessionRow.BANKROLL,
SessionRow.TABLE_SIZE,
SessionRow.TOURNAMENT_NAME
SessionRow.TOURNAMENT_NAME,
SessionRow.TOURNAMENT_TYPE
)
}
Session.Type.TOURNAMENT.ordinal -> {
Session.Type.CASH_GAME.ordinal -> {
return listOf(
SessionRow.GAME,
SessionRow.BLINDS,
SessionRow.BANKROLL,
SessionRow.TABLE_SIZE,
SessionRow.TOURNAMENT_TYPE
SessionRow.TABLE_SIZE
)
}
}

@ -88,7 +88,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
val data = currentSession.editDescriptors(row)
when (row) {
SessionRow.START_DATE -> DateTimePickerManager.create(requireContext(),row,this,currentSession.startDate)
SessionRow.START_DATE -> DateTimePickerManager.create(requireContext(), row, this, currentSession.startDate)
SessionRow.END_DATE -> DateTimePickerManager.create(
requireContext(),
row,
@ -135,15 +135,15 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
}
floatingActionButton.setOnClickListener {
if (this.currentSession.isValidForSave()) {
sessionHasBeenCustomized = true
manageSessionState()
} else {
val builder = AlertDialog.Builder(requireContext())
.setMessage(this.currentSession.getFailedSaveMessage(SaveValidityStatus.DATA_INVALID))
.setNegativeButton(R.string.ok, null)
builder.show()
}
if (this.currentSession.isValidForSave()) {
sessionHasBeenCustomized = true
manageSessionState()
} else {
val builder = AlertDialog.Builder(requireContext())
.setMessage(this.currentSession.getFailedSaveMessage(SaveValidityStatus.DATA_INVALID))
.setNegativeButton(R.string.ok, null)
builder.show()
}
}
}
@ -151,12 +151,14 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
* Update the UI with the session data
* Should be called after the initialization of the session
*/
private fun updateSessionUI() {
private fun updateSessionUI(firstDisplay: Boolean = false) {
this.currentSession.updateRowRepresentation()
handler.removeCallbacksAndMessages(null)
val animationDuration = if (firstDisplay) 0L else 300L
when (currentSession.getState()) {
SessionState.PENDING, SessionState.PLANNED -> {
state.setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
@ -164,6 +166,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
floatingActionButton.setImageResource(R.drawable.ic_outline_play)
sessionMenu?.findItem(R.id.stop)?.isVisible = false
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f)
.setDuration(animationDuration)
.setInterpolator(OvershootInterpolator()).start()
}
SessionState.STARTED -> {
@ -172,6 +175,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
floatingActionButton.setImageResource(R.drawable.ic_outline_pause)
sessionMenu?.findItem(R.id.stop)?.isVisible = true
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f)
.setDuration(animationDuration)
.setInterpolator(OvershootInterpolator()).start()
handler.postDelayed(refreshTimer, 30000)
}
@ -181,6 +185,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
floatingActionButton.setImageResource(R.drawable.ic_outline_play)
sessionMenu?.findItem(R.id.stop)?.isVisible = true
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f)
.setDuration(animationDuration)
.setInterpolator(OvershootInterpolator()).start()
}
SessionState.FINISHED -> {
@ -188,6 +193,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
sessionMenu?.findItem(R.id.restart)?.isVisible = true
sessionMenu?.findItem(R.id.stop)?.isVisible = false
floatingActionButton.animate().scaleX(0f).scaleY(0f).alpha(0f)
.setDuration(animationDuration)
.setInterpolator(FastOutSlowInInterpolator()).start()
}
}
@ -299,7 +305,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
currentSession.location = location
realm.commitTransaction()
updateSessionUI()
updateSessionUI(true)
}
}
sessionHasBeenCustomized = false
@ -312,7 +318,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
sessionAdapter = RowRepresentableAdapter(currentSession, this)
recyclerView.adapter = sessionAdapter
updateSessionUI()
updateSessionUI(true)
}
/**

@ -9,6 +9,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.appcompat.view.ContextThemeWrapper
import androidx.fragment.app.FragmentManager
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import io.realm.RealmObject
@ -57,7 +58,9 @@ open class BottomSheetFragment : BottomSheetDialogFragment() {
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_bottom_sheet, container, false)
//TODO: When dependency 'com.google.android.material:material:1.1.0' will be available in stable version, upgrade and remove that
val contextThemeWrapper = ContextThemeWrapper(activity, R.style.PokerAnalyticsTheme)
return inflater.cloneInContext(contextThemeWrapper).inflate(R.layout.fragment_bottom_sheet, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

@ -8,7 +8,6 @@
<androidx.appcompat.widget.Toolbar
android:id="@+id/bottomSheetToolbar"
style="@style/PokerAnalyticsTheme.Toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
tools:title="Test" />

@ -145,8 +145,14 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="28dp"
android:alpha="0"
android:elevation="16dp"
android:scaleX="0"
android:scaleY="0"
android:src="@drawable/ic_outline_play"
android:tint="@color/black" />
android:tint="@color/black"
tools:alpha="1"
tools:scaleX="1"
tools:scaleY="1" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

@ -6,9 +6,10 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorControlHighlight">@color/green_transparent</item>
<item name="android:windowBackground">@color/gray_dark</item>
<item name="android:navigationBarColor">@color/colorPrimary</item>
<item name="colorControlHighlight">@color/green_transparent</item>
<item name="android:actionMenuTextColor">@color/white</item>
<item name="bottomNavigationStyle">@style/PokerAnalyticsTheme.BottomNavigationView</item>
<item name="toolbarStyle">@style/PokerAnalyticsTheme.Toolbar</item>
@ -61,7 +62,6 @@
<item name="android:colorPrimary">@color/white</item>
<item name="android:titleTextColor">@color/white</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<item name="actionMenuTextColor">@color/white</item>
</style>
<!-- TextView -->

Loading…
Cancel
Save