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

feature/top10
Aurelien Hubert 7 years ago
commit cd92e39427
  1. 10
      app/src/main/java/net/pokeranalytics/android/model/extensions/SessionExtensions.kt
  2. 9
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  3. 14
      app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt
  4. 1
      app/src/main/res/layout/row_session_view.xml

@ -8,7 +8,15 @@ enum class SessionState {
PLANNED, PLANNED,
STARTED, STARTED,
PAUSED, PAUSED,
FINISHED FINISHED;
var hasStarted: Boolean = false
get() {
return when (this) {
STARTED, PAUSED, FINISHED -> true
else -> false
}
}
} }
/** /**

@ -192,6 +192,9 @@ open class Session : RealmObject(), SessionInterface, Savable, StaticRowRepresen
return this.endDate ?: Date() return this.endDate ?: Date()
} }
/**
* Returns the nullable date
*/
override fun startDate(): Date? { override fun startDate(): Date? {
return this.startDate return this.startDate
} }
@ -363,7 +366,11 @@ open class Session : RealmObject(), SessionInterface, Savable, StaticRowRepresen
* Return the netDuration of the current session * Return the netDuration of the current session
*/ */
fun getFormattedDuration(): String { fun getFormattedDuration(): String {
return this.netDuration.toMinutes() this.startDate?.let { start ->
val netDuration = this.endDate().time - start.time - this.breakDuration
return netDuration.toMinutes()
}
return NULL_TEXT
} }
/** /**

@ -100,7 +100,6 @@ class SessionRowView : FrameLayout {
// session.timeFrame?.let { // session.timeFrame?.let {
// rowHistorySession.sessionInfoDurationValue.text = session.getFormattedDuration() // rowHistorySession.sessionInfoDurationValue.text = session.getFormattedDuration()
// } // }
rowHistorySession.sessionInfoDurationValue.text = session.getFormattedDuration() rowHistorySession.sessionInfoDurationValue.text = session.getFormattedDuration()
// Location // Location
@ -117,19 +116,28 @@ class SessionRowView : FrameLayout {
rowHistorySession.sessionInfoTableValue.text = TableSize(it).localizedTitle(context) rowHistorySession.sessionInfoTableValue.text = TableSize(it).localizedTitle(context)
} }
val state = session.getState()
rowHistorySession.sessionInfoDurationIcon.isVisible = state.hasStarted
rowHistorySession.sessionInfoDurationValue.isVisible = state.hasStarted
// State // State
if (session.getState() == SessionState.STARTED) { if (state == SessionState.STARTED) {
rowHistorySession.gameResult.isVisible = false rowHistorySession.gameResult.isVisible = false
rowHistorySession.infoIcon.isVisible = true rowHistorySession.infoIcon.isVisible = true
rowHistorySession.infoIcon.setImageResource(R.drawable.chip) rowHistorySession.infoIcon.setImageResource(R.drawable.chip)
rowHistorySession.infoTitle.isVisible = true rowHistorySession.infoTitle.isVisible = true
rowHistorySession.infoTitle.text = context.getString(R.string.running_session_state) rowHistorySession.infoTitle.text = context.getString(R.string.running_session_state)
} else if (session.getState() == SessionState.PLANNED) { } else if (state == SessionState.PLANNED) {
rowHistorySession.gameResult.isVisible = false rowHistorySession.gameResult.isVisible = false
rowHistorySession.infoIcon.isVisible = true rowHistorySession.infoIcon.isVisible = true
rowHistorySession.infoIcon.setImageResource(R.drawable.ic_planned) rowHistorySession.infoIcon.setImageResource(R.drawable.ic_planned)
rowHistorySession.infoTitle.isVisible = true rowHistorySession.infoTitle.isVisible = true
rowHistorySession.infoTitle.text = session.startDate!!.shortTime() rowHistorySession.infoTitle.text = session.startDate!!.shortTime()
} else if (state == SessionState.PENDING) {
rowHistorySession.gameResult.isVisible = false
rowHistorySession.infoIcon.isVisible = false
rowHistorySession.infoTitle.isVisible = false
} else { } else {
rowHistorySession.gameResult.isVisible = true rowHistorySession.gameResult.isVisible = true
rowHistorySession.infoIcon.isVisible = false rowHistorySession.infoIcon.isVisible = false

@ -86,6 +86,7 @@
android:textAllCaps="true" android:textAllCaps="true"
android:textColor="@color/kaki_lighter" android:textColor="@color/kaki_lighter"
android:textSize="12sp" android:textSize="12sp"
android:visibility="gone"
tools:text="4:21" tools:text="4:21"
tools:visibility="visible" /> tools:visibility="visible" />

Loading…
Cancel
Save