mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 15:05:44 +03:00
extract method to reduce complexity
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
c93041d402
commit
300e7da172
1 changed files with 23 additions and 19 deletions
|
@ -189,25 +189,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
||||||
showVoiceMessageLoading()
|
showVoiceMessageLoading()
|
||||||
WorkManager.getInstance(context!!).getWorkInfoByIdLiveData(workInfo.id)
|
WorkManager.getInstance(context!!).getWorkInfoByIdLiveData(workInfo.id)
|
||||||
.observeForever { info: WorkInfo? ->
|
.observeForever { info: WorkInfo? ->
|
||||||
if (info != null) {
|
updateDownloadState(info)
|
||||||
|
|
||||||
when (info.state) {
|
|
||||||
WorkInfo.State.RUNNING -> {
|
|
||||||
Log.d(TAG, "WorkInfo.State.RUNNING in ViewHolder")
|
|
||||||
showVoiceMessageLoading()
|
|
||||||
}
|
|
||||||
WorkInfo.State.SUCCEEDED -> {
|
|
||||||
Log.d(TAG, "WorkInfo.State.SUCCEEDED in ViewHolder")
|
|
||||||
showPlayButton()
|
|
||||||
}
|
|
||||||
WorkInfo.State.FAILED -> {
|
|
||||||
Log.d(TAG, "WorkInfo.State.FAILED in ViewHolder")
|
|
||||||
showPlayButton()
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,6 +200,28 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateDownloadState(info: WorkInfo?) {
|
||||||
|
if (info != null) {
|
||||||
|
when (info.state) {
|
||||||
|
WorkInfo.State.RUNNING -> {
|
||||||
|
Log.d(TAG, "WorkInfo.State.RUNNING in ViewHolder")
|
||||||
|
showVoiceMessageLoading()
|
||||||
|
}
|
||||||
|
WorkInfo.State.SUCCEEDED -> {
|
||||||
|
Log.d(TAG, "WorkInfo.State.SUCCEEDED in ViewHolder")
|
||||||
|
showPlayButton()
|
||||||
|
}
|
||||||
|
WorkInfo.State.FAILED -> {
|
||||||
|
Log.d(TAG, "WorkInfo.State.FAILED in ViewHolder")
|
||||||
|
showPlayButton()
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
Log.d(TAG, "WorkInfo.State unused in ViewHolder")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun showPlayButton() {
|
private fun showPlayButton() {
|
||||||
binding.playPauseBtn.visibility = View.VISIBLE
|
binding.playPauseBtn.visibility = View.VISIBLE
|
||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.visibility = View.GONE
|
||||||
|
|
Loading…
Reference in a new issue