Merge pull request #277 from gavine99/Attach-to-message-UI-266

important fix for npe in messagesadapter with out messages
This commit is contained in:
octoshrimpy
2025-02-11 10:33:16 -05:00
committed by GitHub
@@ -211,49 +211,53 @@ class MessagesAdapter @Inject constructor(
holder.containerView.isActivated = isSelected(message.id) || highlight == message.id holder.containerView.isActivated = isSelected(message.id) || highlight == message.id
// Bind the cancelFrame (cancel button) view // Bind the cancelFrame (cancel button) view
holder.cancelFrame.let { cancelFrame -> if (holder.cancelFrame != null) {
val isCancellable = message.isSending() && message.date > System.currentTimeMillis() holder.cancelFrame.let { cancelFrame ->
cancelFrame.visibility = if (isCancellable) View.VISIBLE else View.GONE val isCancellable = message.isSending() && message.date > System.currentTimeMillis()
cancelFrame.clicks().subscribe { cancelSendingClicks.onNext(message.id) } cancelFrame.visibility = if (isCancellable) View.VISIBLE else View.GONE
cancelFrame.cancel.progress = 2 cancelFrame.clicks().subscribe { cancelSendingClicks.onNext(message.id) }
cancelFrame.cancel.progress = 2
if (isCancellable) { if (isCancellable) {
val delay = when (prefs.sendDelay.get()) { val delay = when (prefs.sendDelay.get()) {
Preferences.SEND_DELAY_SHORT -> 3000 Preferences.SEND_DELAY_SHORT -> 3000
Preferences.SEND_DELAY_MEDIUM -> 5000 Preferences.SEND_DELAY_MEDIUM -> 5000
Preferences.SEND_DELAY_LONG -> 10000 Preferences.SEND_DELAY_LONG -> 10000
else -> 0 else -> 0
}
val progress =
(1 - (message.date - System.currentTimeMillis()) / delay.toFloat()) * 100
ObjectAnimator.ofInt(cancelFrame.cancel, "progress", progress.toInt(), 100)
.setDuration(message.date - System.currentTimeMillis())
.start()
} }
val progress =
(1 - (message.date - System.currentTimeMillis()) / delay.toFloat()) * 100
ObjectAnimator.ofInt(cancelFrame.cancel, "progress", progress.toInt(), 100)
.setDuration(message.date - System.currentTimeMillis())
.start()
} }
} }
// bind the send now icon view // bind the send now icon view
holder.sendNowIcon.let { sendNowIcon -> if (holder.sendNowIcon != null) {
if (message.isSending() && message.date > System.currentTimeMillis()) { holder.sendNowIcon.let { sendNowIcon ->
sendNowIcon.visibility = View.VISIBLE if (message.isSending() && message.date > System.currentTimeMillis()) {
sendNowIcon.clicks().subscribe { sendNowClicks.onNext(message.id) } sendNowIcon.visibility = View.VISIBLE
sendNowIcon.clicks().subscribe { sendNowClicks.onNext(message.id) }
} else
sendNowIcon.visibility = View.GONE
} }
else
sendNowIcon.visibility = View.GONE
} }
// bind the resend icon view // bind the resend icon view
holder.resendIcon.let { resendIcon -> if (holder.resendIcon != null) {
if (message.isFailedMessage()) { holder.resendIcon.let { resendIcon ->
resendIcon.visibility = View.VISIBLE if (message.isFailedMessage()) {
resendIcon.clicks().subscribe { resendIcon.visibility = View.VISIBLE
resendClicks.onNext(message.id) resendIcon.clicks().subscribe {
resendClicks.onNext(message.id)
resendIcon.visibility = View.GONE
}
} else
resendIcon.visibility = View.GONE resendIcon.visibility = View.GONE
}
} }
else
resendIcon.visibility = View.GONE
} }
// Bind the message status // Bind the message status