Main list shows 'Now' as the next check time if the status is pending

This commit is contained in:
Aidan Follestad 2018-12-01 12:33:57 -08:00
commit c6307f5061
2 changed files with 19 additions and 12 deletions

View file

@ -11,6 +11,7 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.afollestad.nocknock.R import com.afollestad.nocknock.R
import com.afollestad.nocknock.data.ServerModel import com.afollestad.nocknock.data.ServerModel
import com.afollestad.nocknock.data.isPending
import com.afollestad.nocknock.data.textRes import com.afollestad.nocknock.data.textRes
import com.afollestad.nocknock.utilities.ui.onDebouncedClick import com.afollestad.nocknock.utilities.ui.onDebouncedClick
import kotlinx.android.synthetic.main.list_item_server.view.iconStatus import kotlinx.android.synthetic.main.list_item_server.view.iconStatus
@ -46,15 +47,25 @@ class ServerVH constructor(
itemView.textStatus.setText(statusText) itemView.textStatus.setText(statusText)
} }
if (model.disabled) { val res = itemView.resources
when {
model.disabled -> {
itemView.textInterval.setText(R.string.checks_disabled) itemView.textInterval.setText(R.string.checks_disabled)
} else { }
itemView.textInterval.text = itemView.resources.getString( model.status.isPending() -> {
itemView.textInterval.text = res.getString(
R.string.next_check_x,
res.getString(R.string.now)
)
}
else -> {
itemView.textInterval.text = res.getString(
R.string.next_check_x, R.string.next_check_x,
model.intervalText() model.intervalText()
) )
} }
} }
}
override fun onLongClick(view: View): Boolean { override fun onLongClick(view: View): Boolean {
adapter.performClick(adapterPosition, true) adapter.performClick(adapterPosition, true)
@ -116,11 +127,6 @@ class ServerAdapter(private val listener: Listener) : RecyclerView.Adapter<Serve
notifyDataSetChanged() notifyDataSetChanged()
} }
fun clear() {
models.clear()
notifyDataSetChanged()
}
override fun onCreateViewHolder( override fun onCreateViewHolder(
parent: ViewGroup, parent: ViewGroup,
viewType: Int viewType: Int

View file

@ -37,6 +37,7 @@
<string name="last_check_result">Last Check Result</string> <string name="last_check_result">Last Check Result</string>
<string name="next_check">Next Check</string> <string name="next_check">Next Check</string>
<string name="next_check_x">Next Check: %1$s</string> <string name="next_check_x">Next Check: %1$s</string>
<string name="now">Now</string>
<string name="none_turned_off">None (turned off)</string> <string name="none_turned_off">None (turned off)</string>
<string name="none">None</string> <string name="none">None</string>