mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Improved pausing
This commit is contained in:
parent
7d56b31d6e
commit
aeb49cd7de
4 changed files with 10 additions and 3 deletions
|
|
@ -142,6 +142,8 @@ public class CommonsApplication extends MultiDexApplication {
|
|||
@Inject
|
||||
ContributionDao contributionDao;
|
||||
|
||||
public static Boolean isPaused = false;
|
||||
|
||||
/**
|
||||
* Used to declare and initialize various components and dependencies
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import androidx.paging.PagedList
|
|||
import androidx.paging.PositionalDataSource
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
|
||||
import fr.free.nrw.commons.CommonsApplication
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.auth.SessionManager
|
||||
import fr.free.nrw.commons.contributions.Contribution
|
||||
|
|
@ -120,7 +121,7 @@ class PendingUploadsFragment : CommonsDaggerSupportFragment(), PendingUploadsCon
|
|||
binding.pendingUplaodsLl.visibility = View.VISIBLE
|
||||
adapter.submitList(list)
|
||||
binding.progressTextView.setText(contributionsSize.toString() + " uploads left")
|
||||
if (pausedOrQueuedUploads == contributionsSize) {
|
||||
if ((pausedOrQueuedUploads == contributionsSize) || CommonsApplication.isPaused) {
|
||||
uploadProgressActivity.setPausedIcon(true)
|
||||
} else {
|
||||
uploadProgressActivity.setPausedIcon(false)
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ public class PendingUploadsPresenter implements UserActionListener {
|
|||
}
|
||||
|
||||
public void pauseUploads(List<Integer> states, int newState) {
|
||||
CommonsApplication.isPaused = true ;
|
||||
compositeDisposable.add(repository
|
||||
.updateContributionWithStates(states, newState)
|
||||
.subscribeOn(ioThreadScheduler)
|
||||
|
|
@ -124,6 +125,7 @@ public class PendingUploadsPresenter implements UserActionListener {
|
|||
}
|
||||
|
||||
public void restartUploads(List<Contribution> contributionList, int index, Context context) {
|
||||
CommonsApplication.isPaused = false;
|
||||
if (index >= contributionList.size()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -154,6 +156,7 @@ public class PendingUploadsPresenter implements UserActionListener {
|
|||
}
|
||||
|
||||
public void restartUpload(List<Contribution> contributionList, int index, Context context) {
|
||||
CommonsApplication.isPaused = false;
|
||||
if (index >= contributionList.size()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@ class UploadClient @Inject constructor(
|
|||
contributionDao.getContribution(contribution.pageId) == null -> {
|
||||
return Observable.just(StashUploadResult(StashUploadState.CANCELLED, null, "Upload cancelled"))
|
||||
}
|
||||
contributionDao.getContribution(contribution.pageId).state == Contribution.STATE_PAUSED -> {
|
||||
contributionDao.getContribution(contribution.pageId).state == Contribution.STATE_PAUSED
|
||||
|| CommonsApplication.isPaused -> {
|
||||
Timber.d("Upload stash paused %s", contribution.pageId)
|
||||
Observable.just(StashUploadResult(StashUploadState.PAUSED, null, null))
|
||||
}
|
||||
|
|
@ -273,7 +274,7 @@ private fun canProcess(
|
|||
// As long as the contribution hasn't been paused and there are no errors,
|
||||
// we can process the current chunk.
|
||||
return !(contributionDao.getContribution(contribution.pageId).state == Contribution.STATE_PAUSED
|
||||
|| failures.get())
|
||||
|| failures.get() || CommonsApplication.isPaused)
|
||||
}
|
||||
|
||||
private fun shouldSkip(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue