From f6bd1cbd0f88692ae702d3d2c619e3b3add3b052 Mon Sep 17 00:00:00 2001 From: Aurelien Hubert Date: Mon, 4 Mar 2019 11:43:39 +0100 Subject: [PATCH] Update session row for planned state --- .../android/ui/view/SessionRowView.kt | 18 +++++++++++++----- .../android/util/DateExtension.kt | 17 +++++++++++++++++ app/src/main/res/layout/row_session_view.xml | 4 ++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt index e26a7e48..f3b84f00 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt @@ -16,6 +16,7 @@ import net.pokeranalytics.android.model.extensions.getState import net.pokeranalytics.android.model.realm.Session import net.pokeranalytics.android.util.getDayNumber import net.pokeranalytics.android.util.getShortDayName +import net.pokeranalytics.android.util.shortTime import net.pokeranalytics.android.util.toCurrency /** @@ -117,15 +118,22 @@ class SessionRowView : FrameLayout { // State if (session.getState() == SessionState.STARTED) { rowHistorySession.gameResult.isVisible = false - rowHistorySession.playingIcon.isVisible = true - rowHistorySession.playingTitle.isVisible = true + rowHistorySession.infoIcon.isVisible = true + rowHistorySession.infoIcon.setImageResource(R.drawable.chip) + rowHistorySession.infoTitle.isVisible = true + rowHistorySession.infoTitle.text = context.getString(R.string.running_session_state) + } else if (session.getState() == SessionState.PLANNED) { + rowHistorySession.gameResult.isVisible = false + rowHistorySession.infoIcon.isVisible = true + rowHistorySession.infoIcon.setImageResource(R.drawable.ic_planned) + rowHistorySession.infoTitle.isVisible = true + rowHistorySession.infoTitle.text = session.timeFrame?.startDate?.shortTime() } else { rowHistorySession.gameResult.isVisible = true - rowHistorySession.playingIcon.isVisible = false - rowHistorySession.playingTitle.isVisible = false + rowHistorySession.infoIcon.isVisible = false + rowHistorySession.infoTitle.isVisible = false val result = session.result?.net ?: 0.0 - val stat = ComputedStat(Stat.NETRESULT, result) rowHistorySession.gameResult.textFormat = stat.format(context) } diff --git a/app/src/main/java/net/pokeranalytics/android/util/DateExtension.kt b/app/src/main/java/net/pokeranalytics/android/util/DateExtension.kt index c50f4757..af945f5e 100644 --- a/app/src/main/java/net/pokeranalytics/android/util/DateExtension.kt +++ b/app/src/main/java/net/pokeranalytics/android/util/DateExtension.kt @@ -38,6 +38,23 @@ fun Date.fullDate(): String { return DateFormat.getDateInstance(DateFormat.FULL).format(this) } +// Return a short string of the time +fun Date.shortTime(): String { + return DateFormat.getTimeInstance(DateFormat.SHORT).format(this) +} +// Return a short string of the time +fun Date.mediumTime(): String { + return DateFormat.getTimeInstance(DateFormat.MEDIUM).format(this) +} +// Return a long string of the time +fun Date.longTime(): String { + return DateFormat.getTimeInstance(DateFormat.LONG).format(this) +} +// Return a short string of the time +fun Date.fullTime(): String { + return DateFormat.getTimeInstance(DateFormat.FULL).format(this) +} + // Return a short string of the date & time fun Date.shortDateTime(): String { return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(this) diff --git a/app/src/main/res/layout/row_session_view.xml b/app/src/main/res/layout/row_session_view.xml index ed2b9007..fcc7ed1e 100644 --- a/app/src/main/res/layout/row_session_view.xml +++ b/app/src/main/res/layout/row_session_view.xml @@ -162,7 +162,7 @@ tools:visibility="visible" />