refactor getListItemLiveTimeDescr
This commit is contained in:
parent
85bd983223
commit
f99086f668
3 changed files with 16 additions and 25 deletions
|
@ -362,9 +362,8 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
|||
}
|
||||
|
||||
private fun getListItemLiveTimeDescr(item: ListItem): String {
|
||||
return getString(R.string.last_response) +
|
||||
": ${OsmandFormatter.getFormattedDuration(app, getListItemLiveTime(item))} " +
|
||||
getString(R.string.time_ago)
|
||||
val formattedTime = OsmandFormatter.getFormattedDuration(app, getListItemLiveTime(item))
|
||||
return getString(R.string.last_response) + ": $formattedTime " + getString(R.string.time_ago)
|
||||
}
|
||||
|
||||
private fun getListItemLiveTime(item: ListItem): Long = (System.currentTimeMillis() / 1000) - item.lastUpdated
|
||||
|
|
|
@ -577,35 +577,27 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
}
|
||||
|
||||
holder.stopSharingDescr?.apply {
|
||||
if (expiresIn > 0) {
|
||||
visibility = View.VISIBLE
|
||||
visibility = getStopSharingVisibility(expiresIn)
|
||||
text = "${getText(R.string.stop_at)}:"
|
||||
} else {
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
holder.stopSharingFirstPart?.apply {
|
||||
if (expiresIn > 0) {
|
||||
visibility = View.VISIBLE
|
||||
visibility = getStopSharingVisibility(expiresIn)
|
||||
text = OsmandFormatter.getFormattedTime(expiresIn)
|
||||
} else {
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
holder.stopSharingSecondPart?.apply {
|
||||
if (expiresIn > 0) {
|
||||
visibility = View.VISIBLE
|
||||
text = "(${getString(R.string.in_time,
|
||||
OsmandFormatter.getFormattedDuration(context!!, expiresIn, true))})"
|
||||
} else {
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
visibility = getStopSharingVisibility(expiresIn)
|
||||
text = "(${getString(
|
||||
R.string.in_time,
|
||||
OsmandFormatter.getFormattedDuration(context!!, expiresIn, true)
|
||||
)})"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getStopSharingVisibility(expiresIn: Long) = if (expiresIn > 0) View.VISIBLE else View.INVISIBLE
|
||||
|
||||
private fun removeItem(chat: TdApi.Chat) {
|
||||
chats.remove(chat)
|
||||
if (chats.isEmpty()) {
|
||||
|
|
|
@ -324,8 +324,8 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr
|
|||
override fun getItemCount() = chats.size
|
||||
|
||||
private fun getListItemLiveTimeDescr(lastUpdated: Int): String {
|
||||
return "${OsmandFormatter.getFormattedDuration(app, getListItemLiveTime(lastUpdated))} " +
|
||||
getString(R.string.time_ago)
|
||||
val formattedTime = OsmandFormatter.getFormattedDuration(app, getListItemLiveTime(lastUpdated))
|
||||
return "$formattedTime " + getString(R.string.time_ago)
|
||||
}
|
||||
|
||||
private fun getListItemLiveTime(lastUpdated: Int): Long {
|
||||
|
|
Loading…
Reference in a new issue