From be04f298e62184e036b1505cce5cc2917ec04d32 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 16 Aug 2018 10:41:46 +0300 Subject: [PATCH] add check for messages expire time --- .../telegram/ui/MyLocationTabFragment.kt | 28 ++++++++++++++----- .../telegram/ui/SetTimeDialogFragment.kt | 1 - 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt index ddc2238eff..74d4cd7401 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt @@ -577,19 +577,33 @@ class MyLocationTabFragment : Fragment(), TelegramListener { } holder.stopSharingDescr?.apply { - visibility = View.VISIBLE - text = "${getText(R.string.stop_at)}:" + if (expiresIn > 0) { + visibility = View.VISIBLE + text = "${getText(R.string.stop_at)}:" + } else { + visibility = View.INVISIBLE + } } holder.stopSharingFirstPart?.apply { - visibility = View.VISIBLE - text = OsmandFormatter.getFormattedTime(expiresIn) + if (expiresIn > 0) { + visibility = View.VISIBLE + text = OsmandFormatter.getFormattedTime(expiresIn) + } else { + visibility = View.INVISIBLE + } } holder.stopSharingSecondPart?.apply { - visibility = View.VISIBLE - text = "(${getString(R.string.in_time, - OsmandFormatter.getFormattedDuration(context!!, expiresIn, true))})" + if (expiresIn > 0) { + visibility = View.VISIBLE + text = "(${getString( + R.string.in_time, + OsmandFormatter.getFormattedDuration(context!!, expiresIn, true) + )})" + } else { + visibility = View.INVISIBLE + } } } } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt index ee2e41ae31..3e128186d4 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt @@ -324,7 +324,6 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr private fun getListItemLiveTime(message: TdApi.Message): Long = (System.currentTimeMillis() / 1000) - message.date - inner class ChatViewHolder(val view: View) : RecyclerView.ViewHolder(view) { val icon: ImageView? = view.findViewById(R.id.icon) val title: TextView? = view.findViewById(R.id.title)