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