code cleanup

feature/top10
Laurent 7 years ago
parent 84b9162f04
commit ca2ef99609
  1. 2
      app/src/main/java/net/pokeranalytics/android/calculus/Report.kt
  2. 6
      app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  4. 12
      app/src/main/java/net/pokeranalytics/android/model/realm/SessionSet.kt
  5. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt
  6. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/StatsFragment.kt
  7. 6
      app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt
  8. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt
  9. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/TransactionRowView.kt

@ -391,7 +391,7 @@ class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValu
override fun formattedValue(stat: Stat, context: Context): TextFormat {
this.computedStat(stat)?.let {
return it.format(context)
return it.format()
} ?: run {
throw IllegalStateException("Missing stat in results")
}

@ -157,7 +157,7 @@ enum class Stat : RowRepresentable {
/**
* Formats the value of the stat to be suitable for display
*/
fun format(value: Double, secondValue: Double? = null, currency: Currency? = null, context: Context): TextFormat {
fun format(value: Double, secondValue: Double? = null, currency: Currency? = null): TextFormat {
if (value.isNaN()) {
return TextFormat(NULL_TEXT, R.color.white)
@ -297,8 +297,8 @@ class ComputedStat(var stat: Stat, var value: Double, var secondValue: Double? =
/**
* Formats the value of the stat to be suitable for display
*/
fun format(context: Context): TextFormat {
return this.stat.format(this.value, this.secondValue, this.currency, context)
fun format(): TextFormat {
return this.stat.format(this.value, this.secondValue, this.currency)
}
}

@ -950,7 +950,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
}
value?.let {
return stat.format(it, currency = currency, context = context)
return stat.format(it, currency = currency)
} ?: run {
return TextFormat(NULL_TEXT)
}

@ -120,15 +120,15 @@ open class SessionSet() : RealmObject(), Timed, Filterable {
override fun formattedValue(stat: Stat, context: Context) : TextFormat {
return when (stat) {
Stat.NET_RESULT, Stat.AVERAGE -> stat.format(this.ratedNet, currency = null, context = context)
Stat.DURATION, Stat.AVERAGE_DURATION -> stat.format(this.netDuration.toDouble(), currency = null, context = context)
Stat.HOURLY_RATE -> stat.format(this.hourlyRate, currency = null, context = context)
Stat.HANDS_PLAYED -> stat.format(this.estimatedHands, currency = null, context = context)
Stat.HOURLY_RATE_BB -> stat.format(this.bbHourlyRate, currency = null, context = context)
Stat.NET_RESULT, Stat.AVERAGE -> stat.format(this.ratedNet, currency = null)
Stat.DURATION, Stat.AVERAGE_DURATION -> stat.format(this.netDuration.toDouble(), currency = null)
Stat.HOURLY_RATE -> stat.format(this.hourlyRate, currency = null)
Stat.HANDS_PLAYED -> stat.format(this.estimatedHands, currency = null)
Stat.HOURLY_RATE_BB -> stat.format(this.bbHourlyRate, currency = null)
Stat.NET_BB_PER_100_HANDS, Stat.STANDARD_DEVIATION_BB_PER_100_HANDS -> {
val netBBPer100Hands = Stat.netBBPer100Hands(this.bbNet, this.estimatedHands)
if (netBBPer100Hands != null) {
return stat.format(this.estimatedHands, currency = null, context = context)
return stat.format(this.estimatedHands, currency = null)
} else {
return TextFormat(NULL_TEXT)
}

@ -84,7 +84,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
val formattedDate = it.entryTitle
val entryValue = it.formattedValue(this.stat, requireContext())
val totalStatValue = this.stat.format(entry.y.toDouble(), currency = null, context = requireContext())
val totalStatValue = this.stat.format(entry.y.toDouble(), currency = null)
this.legendView.setItemData(this.stat, formattedDate, entryValue, totalStatValue)
}

@ -77,7 +77,7 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc
if (row is StatRow) {
context?.let { context ->
row.computedStat?.let {
dc.textFormat = it.format(context)
dc.textFormat = it.format()
}
}
}
@ -87,7 +87,7 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc
override fun statFormatForRow(row: RowRepresentable): TextFormat {
if (row is StatRow) {
context?.let { context ->
row.computedStat?.let { return it.format(context) }
row.computedStat?.let { return it.format() }
}
}
return TextFormat(NULL_TEXT)

@ -136,7 +136,7 @@ enum class RowViewType(private var layoutRes: Int) {
// Value
itemView.findViewById<AppCompatTextView?>(R.id.value)?.let {
if (row.computedStat != null) {
val format = row.computedStat!!.format(itemView.context)
val format = row.computedStat!!.format()
it.setTextFormat(format, itemView.context)
} else if (row.value != null) {
it.text = row.value
@ -279,7 +279,7 @@ enum class RowViewType(private var layoutRes: Int) {
itemView.findViewById<AppCompatTextView?>(R.id.stat1Value)?.let { view ->
view.text = ""
row.computedStat1?.format(view.context)?.let {
row.computedStat1?.format()?.let {
view.setTextFormat(it, itemView.context)
}
}
@ -294,7 +294,7 @@ enum class RowViewType(private var layoutRes: Int) {
itemView.findViewById<AppCompatTextView?>(R.id.stat2Value)?.let { view ->
view.text = ""
row.computedStat2?.format(view.context)?.let {
row.computedStat2?.format()?.let {
view.setTextFormat(it, itemView.context)
}
}

@ -149,7 +149,7 @@ class SessionRowView : FrameLayout {
rowHistorySession.infoTitle.isVisible = false
val result = session.result?.net ?: 0.0
val formattedStat = ComputedStat(Stat.NET_RESULT, result, currency = session.currency).format(context)
val formattedStat = ComputedStat(Stat.NET_RESULT, result, currency = session.currency).format()
rowHistorySession.gameResult.setTextFormat(formattedStat, context)
}

@ -63,7 +63,7 @@ class TransactionRowView : FrameLayout {
rowTransaction.transactionSubtitle.text = subtitle
// Amount
val formattedStat = ComputedStat(Stat.NET_RESULT, transaction.amount).format(context)
val formattedStat = ComputedStat(Stat.NET_RESULT, transaction.amount).format()
rowTransaction.transactionAmount.setTextFormat(formattedStat, context)
}

Loading…
Cancel
Save