mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fixed progress bar issue
This commit is contained in:
parent
a01263a6e8
commit
170d0b156e
1 changed files with 18 additions and 12 deletions
|
|
@ -32,9 +32,9 @@ class PendingUploadsAdapter(private val callback: Callback) :
|
|||
when (val latestPayload = payloads.lastOrNull()) {
|
||||
is ContributionChangePayload.Progress -> holder.bindProgress(
|
||||
latestPayload.transferred,
|
||||
latestPayload.total
|
||||
latestPayload.total,
|
||||
getItem(position)!!.state
|
||||
)
|
||||
|
||||
is ContributionChangePayload.State -> holder.bindState(latestPayload.state)
|
||||
else -> onBindViewHolder(holder, position)
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ class PendingUploadsAdapter(private val callback: Callback) :
|
|||
}
|
||||
|
||||
bindState(contribution.state)
|
||||
bindProgress(contribution.transferred, contribution.dataLength)
|
||||
bindProgress(contribution.transferred, contribution.dataLength, contribution.state)
|
||||
}
|
||||
|
||||
fun bindState(state: Int) {
|
||||
|
|
@ -95,12 +95,17 @@ class PendingUploadsAdapter(private val callback: Callback) :
|
|||
}
|
||||
}
|
||||
|
||||
fun bindProgress(transferred: Long, total: Long) {
|
||||
fun bindProgress(transferred: Long, total: Long, state: Int) {
|
||||
if (transferred == 0L) {
|
||||
errorTextView.text = "Queued"
|
||||
errorTextView.visibility = View.VISIBLE
|
||||
itemProgress.visibility = View.GONE
|
||||
} else {
|
||||
if (state == Contribution.STATE_QUEUED){
|
||||
errorTextView.text = "Queued"
|
||||
errorTextView.visibility = View.VISIBLE
|
||||
itemProgress.visibility = View.GONE
|
||||
} else{
|
||||
errorTextView.visibility = View.GONE
|
||||
itemProgress.visibility = View.VISIBLE
|
||||
if (transferred >= total) {
|
||||
|
|
@ -113,6 +118,7 @@ class PendingUploadsAdapter(private val callback: Callback) :
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Callback {
|
||||
fun deleteUpload(contribution: Contribution?)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue