mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 22:08:27 +00:00
Fix timer icon flashes expired
This commit is contained in:
parent
fc9ea46ed8
commit
725ad43b1d
@ -3,17 +3,19 @@ package org.thoughtcrime.securesms.conversation.v2.components
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.AnimationDrawable
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.snode.SnodeAPI.nowWithOffset
|
||||
import kotlin.math.round
|
||||
|
||||
class ExpirationTimerView @JvmOverloads constructor(
|
||||
context: Context?,
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ImageView(context, attrs, defStyleAttr) {
|
||||
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
||||
private val frames = intArrayOf(
|
||||
R.drawable.timer00,
|
||||
R.drawable.timer05,
|
||||
@ -36,6 +38,12 @@ class ExpirationTimerView @JvmOverloads constructor(
|
||||
return
|
||||
}
|
||||
|
||||
if (startedAt == 0L) {
|
||||
// timer has not started
|
||||
setImageResource(R.drawable.timer60)
|
||||
return
|
||||
}
|
||||
|
||||
val elapsedTime = nowWithOffset - startedAt
|
||||
val remainingTime = expiresIn - elapsedTime
|
||||
val remainingPercent = (remainingTime / expiresIn.toFloat()).coerceIn(0f, 1f)
|
||||
|
Loading…
x
Reference in New Issue
Block a user