Add some color to History, include success state
This commit is contained in:
parent
735ff383d9
commit
f96727224d
1 changed files with 13 additions and 5 deletions
|
@ -211,8 +211,14 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTextColor(commandType: OmnipodCommandType): Int {
|
private fun setTextViewColor(includeresult: Boolean, textview: TextView, record: HistoryRecord) {
|
||||||
val textColor = when (commandType) {
|
if (includeresult && !record.isSuccess()) {
|
||||||
|
// Record says not success
|
||||||
|
textview.setTextColor(android.graphics.Color.YELLOW)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// On success set color
|
||||||
|
val textColor = when (record.commandType) {
|
||||||
// Operational
|
// Operational
|
||||||
OmnipodCommandType.INITIALIZE_POD,
|
OmnipodCommandType.INITIALIZE_POD,
|
||||||
OmnipodCommandType.CONFIGURE_ALERTS,
|
OmnipodCommandType.CONFIGURE_ALERTS,
|
||||||
|
@ -239,12 +245,13 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
// Other
|
// Other
|
||||||
android.graphics.Color.LTGRAY
|
android.graphics.Color.LTGRAY
|
||||||
}
|
}
|
||||||
return textColor
|
textview.setTextColor(textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setType(record: HistoryRecord, typeView: TextView) {
|
private fun setType(record: HistoryRecord, typeView: TextView) {
|
||||||
typeView.text = resourceHelper.gs(record.commandType.resourceId)
|
typeView.text = resourceHelper.gs(record.commandType.resourceId)
|
||||||
typeView.setTextColor(getTextColor(record.commandType))
|
// Set some color, include result
|
||||||
|
setTextViewColor(includeresult=true, typeView, record)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setValue(historyEntry: HistoryRecord, valueView: TextView) {
|
private fun setValue(historyEntry: HistoryRecord, valueView: TextView) {
|
||||||
|
@ -277,7 +284,8 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
else ->
|
else ->
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
valueView.setTextColor(getTextColor(historyEntry.commandType))
|
// Set some color
|
||||||
|
setTextViewColor(includeresult=false, valueView, historyEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
|
|
Loading…
Add table
Reference in a new issue