mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-20 19:25:01 +01:00
extract visibility toggle for play/pause Vs. loading-animation
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
86d3501553
commit
195bdfb05a
@ -95,8 +95,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View) : MessageHolders
|
|||||||
binding.seekbar.max = message.voiceMessageDuration
|
binding.seekbar.max = message.voiceMessageDuration
|
||||||
|
|
||||||
if (message.isPlayingVoiceMessage) {
|
if (message.isPlayingVoiceMessage) {
|
||||||
binding.progressBar.visibility = View.GONE
|
showPlayButton()
|
||||||
binding.playPauseBtn.visibility = View.VISIBLE
|
|
||||||
binding.playPauseBtn.icon = ContextCompat.getDrawable(
|
binding.playPauseBtn.icon = ContextCompat.getDrawable(
|
||||||
context!!,
|
context!!,
|
||||||
R.drawable.ic_baseline_pause_voice_message_24
|
R.drawable.ic_baseline_pause_voice_message_24
|
||||||
@ -111,8 +110,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View) : MessageHolders
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message.isDownloadingVoiceMessage) {
|
if (message.isDownloadingVoiceMessage) {
|
||||||
binding.playPauseBtn.visibility = View.GONE
|
showVoiceMessageLoading()
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
|
||||||
} else {
|
} else {
|
||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.visibility = View.GONE
|
||||||
}
|
}
|
||||||
@ -152,26 +150,22 @@ class IncomingVoiceMessageViewHolder(incomingView: View) : MessageHolders
|
|||||||
try {
|
try {
|
||||||
for (workInfo in workers.get()) {
|
for (workInfo in workers.get()) {
|
||||||
if (workInfo.state == WorkInfo.State.RUNNING || workInfo.state == WorkInfo.State.ENQUEUED) {
|
if (workInfo.state == WorkInfo.State.RUNNING || workInfo.state == WorkInfo.State.ENQUEUED) {
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
showVoiceMessageLoading()
|
||||||
binding.playPauseBtn.visibility = View.GONE
|
|
||||||
WorkManager.getInstance(context!!).getWorkInfoByIdLiveData(workInfo.id)
|
WorkManager.getInstance(context!!).getWorkInfoByIdLiveData(workInfo.id)
|
||||||
.observeForever { info: WorkInfo? ->
|
.observeForever { info: WorkInfo? ->
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
when (info.state) {
|
when (info.state) {
|
||||||
WorkInfo.State.RUNNING -> {
|
WorkInfo.State.RUNNING -> {
|
||||||
Log.d(TAG, "WorkInfo.State.RUNNING in ViewHolder")
|
Log.d(TAG, "WorkInfo.State.RUNNING in ViewHolder")
|
||||||
binding.playPauseBtn.visibility = View.GONE
|
showVoiceMessageLoading()
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
|
||||||
}
|
}
|
||||||
WorkInfo.State.SUCCEEDED -> {
|
WorkInfo.State.SUCCEEDED -> {
|
||||||
Log.d(TAG, "WorkInfo.State.SUCCEEDED in ViewHolder")
|
Log.d(TAG, "WorkInfo.State.SUCCEEDED in ViewHolder")
|
||||||
binding.playPauseBtn.visibility = View.VISIBLE
|
showPlayButton()
|
||||||
binding.progressBar.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
WorkInfo.State.FAILED -> {
|
WorkInfo.State.FAILED -> {
|
||||||
Log.d(TAG, "WorkInfo.State.FAILED in ViewHolder")
|
Log.d(TAG, "WorkInfo.State.FAILED in ViewHolder")
|
||||||
binding.playPauseBtn.visibility = View.VISIBLE
|
showPlayButton()
|
||||||
binding.progressBar.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
}
|
}
|
||||||
@ -187,6 +181,16 @@ class IncomingVoiceMessageViewHolder(incomingView: View) : MessageHolders
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showPlayButton() {
|
||||||
|
binding.playPauseBtn.visibility = View.VISIBLE
|
||||||
|
binding.progressBar.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showVoiceMessageLoading() {
|
||||||
|
binding.playPauseBtn.visibility = View.GONE
|
||||||
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||||
val author: String = message.actorDisplayName
|
val author: String = message.actorDisplayName
|
||||||
if (!TextUtils.isEmpty(author)) {
|
if (!TextUtils.isEmpty(author)) {
|
||||||
|
@ -94,8 +94,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
|||||||
binding.seekbar.max = message.voiceMessageDuration
|
binding.seekbar.max = message.voiceMessageDuration
|
||||||
|
|
||||||
if (message.isPlayingVoiceMessage) {
|
if (message.isPlayingVoiceMessage) {
|
||||||
binding.progressBar.visibility = View.GONE
|
showPlayButton()
|
||||||
binding.playPauseBtn.visibility = View.VISIBLE
|
|
||||||
binding.playPauseBtn.icon = ContextCompat.getDrawable(
|
binding.playPauseBtn.icon = ContextCompat.getDrawable(
|
||||||
context!!,
|
context!!,
|
||||||
R.drawable.ic_baseline_pause_voice_message_24
|
R.drawable.ic_baseline_pause_voice_message_24
|
||||||
@ -110,8 +109,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message.isDownloadingVoiceMessage) {
|
if (message.isDownloadingVoiceMessage) {
|
||||||
binding.playPauseBtn.visibility = View.GONE
|
showVoiceMessageLoading()
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
|
||||||
} else {
|
} else {
|
||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.visibility = View.GONE
|
||||||
}
|
}
|
||||||
@ -172,8 +170,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
|||||||
try {
|
try {
|
||||||
for (workInfo in workers.get()) {
|
for (workInfo in workers.get()) {
|
||||||
if (workInfo.state == WorkInfo.State.RUNNING || workInfo.state == WorkInfo.State.ENQUEUED) {
|
if (workInfo.state == WorkInfo.State.RUNNING || workInfo.state == WorkInfo.State.ENQUEUED) {
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
showVoiceMessageLoading()
|
||||||
binding.playPauseBtn.visibility = View.GONE
|
|
||||||
WorkManager.getInstance(context!!).getWorkInfoByIdLiveData(workInfo.id)
|
WorkManager.getInstance(context!!).getWorkInfoByIdLiveData(workInfo.id)
|
||||||
.observeForever { info: WorkInfo? ->
|
.observeForever { info: WorkInfo? ->
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
@ -181,18 +178,15 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
|||||||
when (info.state) {
|
when (info.state) {
|
||||||
WorkInfo.State.RUNNING -> {
|
WorkInfo.State.RUNNING -> {
|
||||||
Log.d(TAG, "WorkInfo.State.RUNNING in ViewHolder")
|
Log.d(TAG, "WorkInfo.State.RUNNING in ViewHolder")
|
||||||
binding.playPauseBtn.visibility = View.GONE
|
showVoiceMessageLoading()
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
|
||||||
}
|
}
|
||||||
WorkInfo.State.SUCCEEDED -> {
|
WorkInfo.State.SUCCEEDED -> {
|
||||||
Log.d(TAG, "WorkInfo.State.SUCCEEDED in ViewHolder")
|
Log.d(TAG, "WorkInfo.State.SUCCEEDED in ViewHolder")
|
||||||
binding.playPauseBtn.visibility = View.VISIBLE
|
showPlayButton()
|
||||||
binding.progressBar.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
WorkInfo.State.FAILED -> {
|
WorkInfo.State.FAILED -> {
|
||||||
Log.d(TAG, "WorkInfo.State.FAILED in ViewHolder")
|
Log.d(TAG, "WorkInfo.State.FAILED in ViewHolder")
|
||||||
binding.playPauseBtn.visibility = View.VISIBLE
|
showPlayButton()
|
||||||
binding.progressBar.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
}
|
}
|
||||||
@ -208,6 +202,16 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showPlayButton() {
|
||||||
|
binding.playPauseBtn.visibility = View.VISIBLE
|
||||||
|
binding.progressBar.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showVoiceMessageLoading() {
|
||||||
|
binding.playPauseBtn.visibility = View.GONE
|
||||||
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
|
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
|
||||||
if (!message.isDeleted && message.parentMessage != null) {
|
if (!message.isDeleted && message.parentMessage != null) {
|
||||||
val parentChatMessage = message.parentMessage
|
val parentChatMessage = message.parentMessage
|
||||||
|
Loading…
Reference in New Issue
Block a user