Avoid warnings in ChatListAdapter

This commit is contained in:
Juha Heinanen
2021-06-06 11:35:25 +03:00
parent 4ac290be1d
commit 8696b5d0eb
@@ -76,19 +76,17 @@ class ChatListAdapter(private val ctx: Context, private val rows: ArrayList<Mess
val cal = GregorianCalendar() val cal = GregorianCalendar()
cal.timeInMillis = message.timeStamp cal.timeInMillis = message.timeStamp
val fmt: DateFormat val fmt: DateFormat = if (isToday(message.timeStamp))
if (isToday(message.timeStamp)) DateFormat.getTimeInstance(DateFormat.SHORT)
fmt = DateFormat.getTimeInstance(DateFormat.SHORT)
else else
fmt = DateFormat.getDateInstance(DateFormat.SHORT) DateFormat.getDateInstance(DateFormat.SHORT)
viewHolder.infoView.text = fmt.format(cal.time) viewHolder.infoView.text = fmt.format(cal.time)
if (message.direction == R.drawable.arrow_up_red) { if (message.direction == R.drawable.arrow_up_red) {
val info: String val info: String = if (message.responseCode != 0)
if (message.responseCode != 0) "${viewHolder.infoView.text} - ${ctx.getString(R.string.message_failed)}: " +
info = "${viewHolder.infoView.text} - ${ctx.getString(R.string.message_failed)}: " + "${message.responseCode} ${message.responseReason}"
"${message.responseCode} ${message.responseReason}"
else else
info = "${viewHolder.infoView.text} - ${ctx.getString(R.string.sending_failed)}" "${viewHolder.infoView.text} - ${ctx.getString(R.string.sending_failed)}"
viewHolder.infoView.text = info viewHolder.infoView.text = info
viewHolder.infoView.setTextColor(ContextCompat.getColor(ctx, R.color.colorAccent)) viewHolder.infoView.setTextColor(ContextCompat.getColor(ctx, R.color.colorAccent))
} }