mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Only leave foreground lock when absolutely no more uploads to do
This *might* fix the service dying prematurely in low memory conditions.
This commit is contained in:
parent
6a99255a1e
commit
cce2932a5a
1 changed files with 7 additions and 4 deletions
|
|
@ -77,7 +77,8 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
} else {
|
||||
curProgressNotification.setProgress(100, (int) (((double) transferred / (double) total) * 100), false);
|
||||
}
|
||||
notificationManager.notify(NOTIFICATION_UPLOAD_IN_PROGRESS, curProgressNotification.build());
|
||||
startForeground(NOTIFICATION_UPLOAD_IN_PROGRESS, curProgressNotification.build());
|
||||
|
||||
contribution.setTransferred(transferred);
|
||||
contribution.save();
|
||||
}
|
||||
|
|
@ -125,7 +126,7 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
if (curProgressNotification != null && toUpload != 1) {
|
||||
curProgressNotification.setContentText(getResources().getQuantityString(R.plurals.uploads_pending_notification_indicator, toUpload, toUpload));
|
||||
Log.d("Commons", String.format("%d uploads left", toUpload));
|
||||
notificationManager.notify(NOTIFICATION_UPLOAD_IN_PROGRESS, curProgressNotification.build());
|
||||
this.startForeground(NOTIFICATION_UPLOAD_IN_PROGRESS, curProgressNotification.build());
|
||||
}
|
||||
|
||||
super.queue(what, contribution);
|
||||
|
|
@ -211,10 +212,13 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
return;
|
||||
} finally {
|
||||
toUpload--;
|
||||
if(toUpload == 0) {
|
||||
stopForeground(true);
|
||||
}
|
||||
}
|
||||
|
||||
Log.d("Commons", "Response is" + Utils.getStringFromDOM(result.getDocument()));
|
||||
stopForeground(true);
|
||||
|
||||
curProgressNotification = null;
|
||||
|
||||
|
||||
|
|
@ -249,7 +253,6 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
}
|
||||
|
||||
private void showFailedNotification(Contribution contribution) {
|
||||
stopForeground(true);
|
||||
Notification failureNotification = new NotificationCompat.Builder(this).setAutoCancel(true)
|
||||
.setSmallIcon(R.drawable.ic_launcher)
|
||||
.setAutoCancel(true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue