From 7715d421f6b5a82f6542b0ba11003bded2c938e8 Mon Sep 17 00:00:00 2001 From: Aurelien Hubert Date: Wed, 6 Mar 2019 10:53:03 +0100 Subject: [PATCH] Remove unnecessary FormattedTextView & clean code --- .../android/ui/view/FormattedTextView.kt | 47 ------------------- .../android/ui/view/RowViewType.kt | 4 +- .../android/ui/view/SessionRowView.kt | 5 +- .../res/layout/row_header_title_amount.xml | 2 +- .../layout/row_header_title_amount_big.xml | 2 +- .../res/layout/row_header_title_value.xml | 2 +- app/src/main/res/layout/row_session_view.xml | 7 ++- app/src/main/res/values/attrs.xml | 7 --- 8 files changed, 11 insertions(+), 65 deletions(-) delete mode 100644 app/src/main/java/net/pokeranalytics/android/ui/view/FormattedTextView.kt delete mode 100644 app/src/main/res/values/attrs.xml diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/FormattedTextView.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/FormattedTextView.kt deleted file mode 100644 index 831fd19b..00000000 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/FormattedTextView.kt +++ /dev/null @@ -1,47 +0,0 @@ -package net.pokeranalytics.android.ui.view - -import android.content.Context -import android.util.AttributeSet -import androidx.appcompat.widget.AppCompatTextView -import net.pokeranalytics.android.calculus.TextFormat - -/** - * Extended TextView to display a TextFormat object - */ -class FormattedTextView: AppCompatTextView { - - var textFormat: TextFormat? = null - set(value) { - field = value - updateUI() - } - - constructor(context: Context?) : super(context) { - init(null) - } - - constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) { - init(attrs) - } - - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(attrs) - } - - /** - * Init class - */ - private fun init(attrs: AttributeSet?) { - } - - /** - * Update the UI to manage currency format & color management - */ - private fun updateUI() { - textFormat?.let { - setTextColor(it.getColor(context)) - text = it.text - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt index 1e5bba6d..179cd30a 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt @@ -83,7 +83,7 @@ enum class RowViewType(private var layoutRes: Int) { // Separator SEPARATOR -> SeparatorViewHolder(layout) - else -> throw Exception("Undefined rowViewType's holder") + //else -> throw Exception("Undefined rowViewType's holder") } } @@ -102,7 +102,7 @@ enum class RowViewType(private var layoutRes: Int) { } // Value - itemView.findViewById(R.id.value)?.let { + itemView.findViewById(R.id.value)?.let { if (row.computedStat != null) { val format = row.computedStat!!.format(itemView.context) it.setTextColor(format.getColor(itemView.context)) 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 f3b84f00..65549184 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 @@ -134,8 +134,9 @@ class SessionRowView : FrameLayout { rowHistorySession.infoTitle.isVisible = false val result = session.result?.net ?: 0.0 - val stat = ComputedStat(Stat.NETRESULT, result) - rowHistorySession.gameResult.textFormat = stat.format(context) + val formattedStat = ComputedStat(Stat.NETRESULT, result).format(context) + rowHistorySession.gameResult.setTextColor(formattedStat.getColor(context)) + rowHistorySession.gameResult.text = formattedStat.text } } diff --git a/app/src/main/res/layout/row_header_title_amount.xml b/app/src/main/res/layout/row_header_title_amount.xml index 34e505c7..59326e1f 100644 --- a/app/src/main/res/layout/row_header_title_amount.xml +++ b/app/src/main/res/layout/row_header_title_amount.xml @@ -24,7 +24,7 @@ app:layout_constraintTop_toTopOf="parent" tools:text="Title" /> - - - - + tools:visibility="visible" + tools:text="$ 1000"/> - - - - - - \ No newline at end of file