fix lastUpdated item time and refactor onBindViewHolder for holder in SetTimeDialogFragment

This commit is contained in:
Chumva 2018-08-16 11:31:28 +03:00
parent be04f298e6
commit ebd912bd42
3 changed files with 28 additions and 16 deletions

View file

@ -54,7 +54,12 @@ object TelegramUiHelper {
val type = chat.type
val message = messages.firstOrNull()
if (message != null) {
res.lastUpdated = message.editDate
val lastUpdated = message.editDate
res.lastUpdated = if (lastUpdated != 0) {
lastUpdated
} else {
message.date
}
res.created = message.date
}
if (type is TdApi.ChatTypePrivate || type is TdApi.ChatTypeSecret) {
@ -147,7 +152,12 @@ object TelegramUiHelper {
photoPath = helper.getUserPhotoPath(user)
placeholderId = R.drawable.img_user_picture
userId = message.senderUserId
lastUpdated = message.editDate
val editDate = message.editDate
lastUpdated = if (editDate != 0) {
editDate
} else {
message.date
}
created = message.date
}
}

View file

@ -597,10 +597,8 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
holder.stopSharingSecondPart?.apply {
if (expiresIn > 0) {
visibility = View.VISIBLE
text = "(${getString(
R.string.in_time,
OsmandFormatter.getFormattedDuration(context!!, expiresIn, true)
)})"
text = "(${getString(R.string.in_time,
OsmandFormatter.getFormattedDuration(context!!, expiresIn, true))})"
} else {
visibility = View.INVISIBLE
}

View file

@ -277,14 +277,16 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr
TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId, false)
holder.title?.text = chat.title
val message = telegramHelper.getChatMessages(chat.id).firstOrNull()
if (message != null) {
val content = message.content
if (content is TdApi.MessageLocation && (location != null && content.location != null)) {
holder.description?.visibility = View.VISIBLE
if (telegramHelper.isGroup(chat)) {
holder.description?.text = getString(R.string.shared_string_group)
} else {
if (telegramHelper.isGroup(chat)) {
holder.locationViewContainer?.visibility = View.GONE
holder.description?.visibility = View.VISIBLE
holder.description?.text = getString(R.string.shared_string_group)
} else {
val message = telegramHelper.getChatMessages(chat.id).firstOrNull()
if (message != null) {
val content = message.content
if (content is TdApi.MessageLocation && (location != null && content.location != null)) {
holder.description?.visibility = View.VISIBLE
holder.description?.text = getListItemLiveTimeDescr(message)
holder.locationViewContainer?.visibility = View.VISIBLE
@ -297,12 +299,14 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr
LatLon(content.location.latitude, content.location.longitude),
locationViewCache
)
} else {
holder.locationViewContainer?.visibility = View.GONE
holder.description?.visibility = View.INVISIBLE
}
} else {
holder.locationViewContainer?.visibility = View.GONE
holder.description?.visibility = View.INVISIBLE
}
} else {
holder.description?.visibility = View.INVISIBLE
}
holder.textInArea?.apply {