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()) {
|
when (val latestPayload = payloads.lastOrNull()) {
|
||||||
is ContributionChangePayload.Progress -> holder.bindProgress(
|
is ContributionChangePayload.Progress -> holder.bindProgress(
|
||||||
latestPayload.transferred,
|
latestPayload.transferred,
|
||||||
latestPayload.total
|
latestPayload.total,
|
||||||
|
getItem(position)!!.state
|
||||||
)
|
)
|
||||||
|
|
||||||
is ContributionChangePayload.State -> holder.bindState(latestPayload.state)
|
is ContributionChangePayload.State -> holder.bindState(latestPayload.state)
|
||||||
else -> onBindViewHolder(holder, position)
|
else -> onBindViewHolder(holder, position)
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +81,7 @@ class PendingUploadsAdapter(private val callback: Callback) :
|
||||||
}
|
}
|
||||||
|
|
||||||
bindState(contribution.state)
|
bindState(contribution.state)
|
||||||
bindProgress(contribution.transferred, contribution.dataLength)
|
bindProgress(contribution.transferred, contribution.dataLength, contribution.state)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bindState(state: Int) {
|
fun bindState(state: Int) {
|
||||||
|
|
@ -95,20 +95,26 @@ class PendingUploadsAdapter(private val callback: Callback) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bindProgress(transferred: Long, total: Long) {
|
fun bindProgress(transferred: Long, total: Long, state: Int) {
|
||||||
if (transferred == 0L) {
|
if (transferred == 0L) {
|
||||||
errorTextView.text = "Queued"
|
errorTextView.text = "Queued"
|
||||||
errorTextView.visibility = View.VISIBLE
|
errorTextView.visibility = View.VISIBLE
|
||||||
itemProgress.visibility = View.GONE
|
itemProgress.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
errorTextView.visibility = View.GONE
|
if (state == Contribution.STATE_QUEUED){
|
||||||
itemProgress.visibility = View.VISIBLE
|
errorTextView.text = "Queued"
|
||||||
if (transferred >= total) {
|
errorTextView.visibility = View.VISIBLE
|
||||||
itemProgress.isIndeterminate = true
|
itemProgress.visibility = View.GONE
|
||||||
} else {
|
} else{
|
||||||
itemProgress.isIndeterminate = false
|
errorTextView.visibility = View.GONE
|
||||||
itemProgress.progress =
|
itemProgress.visibility = View.VISIBLE
|
||||||
((transferred.toDouble() / total.toDouble()) * 100).toInt()
|
if (transferred >= total) {
|
||||||
|
itemProgress.isIndeterminate = true
|
||||||
|
} else {
|
||||||
|
itemProgress.isIndeterminate = false
|
||||||
|
itemProgress.progress =
|
||||||
|
((transferred.toDouble() / total.toDouble()) * 100).toInt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue