mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Implemented pause functionality
This commit is contained in:
parent
1286a8d928
commit
a6c97521a1
2 changed files with 21 additions and 5 deletions
|
|
@ -141,6 +141,8 @@ class PendingUploadsFragment : CommonsDaggerSupportFragment(), PendingUploadsCon
|
|||
binding.progressBarPending.progress = totalUploads-l.size
|
||||
if (x == l.size) {
|
||||
uploadProgressActivity.setPausedIcon(true)
|
||||
}else{
|
||||
uploadProgressActivity.setPausedIcon(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -200,10 +202,25 @@ class PendingUploadsFragment : CommonsDaggerSupportFragment(), PendingUploadsCon
|
|||
//TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
fun restartUpload() {
|
||||
fun restartUploads() {
|
||||
// TODO make the restart as in queue
|
||||
var contribution = l.get(0)
|
||||
contribution.state = Contribution.STATE_QUEUED
|
||||
pendingUploadsPresenter.saveContribution(contribution, this.requireContext().applicationContext)
|
||||
Timber.d("Restarting for %s", contribution.toString())
|
||||
}
|
||||
|
||||
fun pauseUploads() {
|
||||
if (l != null){
|
||||
l.forEach {
|
||||
//Pause the upload in the global singleton
|
||||
CommonsApplication.pauseUploads[it.pageId] = true
|
||||
//Retain the paused state in DB
|
||||
it.state = Contribution.STATE_PAUSED
|
||||
pendingUploadsPresenter.saveContribution(it, this.requireContext().applicationContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -90,6 +90,7 @@ class UploadProgressActivity : BaseActivity() {
|
|||
if (menu!!.findItem(R.id.pause_icon) == null) {
|
||||
menu!!.add(Menu.NONE, R.id.pause_icon, Menu.NONE, "Pause")
|
||||
.setIcon(android.R.drawable.ic_media_pause).setOnMenuItemClickListener {
|
||||
pendingUploadsFragment!!.pauseUploads()
|
||||
setPausedIcon(true)
|
||||
true
|
||||
}
|
||||
|
|
@ -107,7 +108,7 @@ class UploadProgressActivity : BaseActivity() {
|
|||
if (menu!!.findItem(R.id.resume_icon) == null) {
|
||||
menu!!.add(Menu.NONE, R.id.resume_icon, Menu.NONE, "Resume")
|
||||
.setIcon(android.R.drawable.ic_media_play).setOnMenuItemClickListener {
|
||||
pendingUploadsFragment!!.restartUpload()
|
||||
pendingUploadsFragment!!.restartUploads()
|
||||
setPausedIcon(false)
|
||||
true
|
||||
}
|
||||
|
|
@ -132,7 +133,6 @@ class UploadProgressActivity : BaseActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fun hidePendingIcons() {
|
||||
isPendingIconsVisible = false
|
||||
updateMenuItems(binding.uploadProgressViewPager.currentItem)
|
||||
|
|
@ -143,5 +143,4 @@ class UploadProgressActivity : BaseActivity() {
|
|||
updateMenuItems(binding.uploadProgressViewPager.currentItem)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue