mirror of
https://github.com/nextcloud/android.git
synced 2024-12-17 22:41:54 +03:00
Added 'event' to notify activities when new uploads are added to the queue of pending uploads, so that the uploads list is better refreshed when several retries are triggered
This commit is contained in:
parent
d9bb808308
commit
4f962aeb2d
2 changed files with 27 additions and 6 deletions
|
@ -93,6 +93,7 @@ public class FileUploader extends Service
|
|||
|
||||
private static final String TAG = FileUploader.class.getSimpleName();
|
||||
|
||||
private static final String UPLOADS_ADDED_MESSAGE = "UPLOADS_ADDED";
|
||||
private static final String UPLOAD_START_MESSAGE = "UPLOAD_START";
|
||||
private static final String UPLOAD_FINISH_MESSAGE = "UPLOAD_FINISH";
|
||||
public static final String EXTRA_UPLOAD_RESULT = "RESULT";
|
||||
|
@ -126,10 +127,6 @@ public class FileUploader extends Service
|
|||
*/
|
||||
public static final String KEY_ACCOUNT = "ACCOUNT";
|
||||
|
||||
/**
|
||||
* Set whether single file or multiple files are to be uploaded. SINGLE_FILES = 0, MULTIPLE_FILEs = 1.
|
||||
*/
|
||||
public static final String KEY_UPLOAD_TYPE = "UPLOAD_TYPE";
|
||||
/**
|
||||
* Set to true if remote file is to be overwritten. Default action is to upload with different name.
|
||||
*/
|
||||
|
@ -174,6 +171,10 @@ public class FileUploader extends Service
|
|||
private NotificationCompat.Builder mNotificationBuilder;
|
||||
private int mLastPercent;
|
||||
|
||||
public static String getUploadsAddedMessage() {
|
||||
return FileUploader.class.getName() + UPLOADS_ADDED_MESSAGE;
|
||||
}
|
||||
|
||||
public static String getUploadStartMessage() {
|
||||
return FileUploader.class.getName() + UPLOAD_START_MESSAGE;
|
||||
}
|
||||
|
@ -535,6 +536,7 @@ public class FileUploader extends Service
|
|||
msg.arg1 = startId;
|
||||
msg.obj = requestedUploads;
|
||||
mServiceHandler.sendMessage(msg);
|
||||
sendBroadcastUploadsAdded();
|
||||
}
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
|
@ -845,6 +847,8 @@ public class FileUploader extends Service
|
|||
|
||||
notifyUploadStart(mCurrentUpload);
|
||||
|
||||
sendBroadcastUploadStarted(mCurrentUpload);
|
||||
|
||||
RemoteOperationResult uploadResult = null;
|
||||
|
||||
try {
|
||||
|
@ -964,8 +968,6 @@ public class FileUploader extends Service
|
|||
|
||||
mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build());
|
||||
|
||||
// TODO really needed?
|
||||
sendBroadcastUploadStarted(mCurrentUpload);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1074,10 +1076,26 @@ public class FileUploader extends Service
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends a broadcast in order to the interested activities can update their
|
||||
* view
|
||||
*
|
||||
* TODO - no more broadcasts, replace with a callback to subscribed listeners
|
||||
*/
|
||||
private void sendBroadcastUploadsAdded() {
|
||||
Intent start = new Intent(getUploadsAddedMessage());
|
||||
// nothing else needed right now
|
||||
sendStickyBroadcast(start);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends a broadcast in order to the interested activities can update their
|
||||
* view
|
||||
*
|
||||
* TODO - no more broadcasts, replace with a callback to subscribed listeners
|
||||
*
|
||||
* @param upload Finished upload operation
|
||||
*/
|
||||
private void sendBroadcastUploadStarted(
|
||||
|
@ -1095,6 +1113,8 @@ public class FileUploader extends Service
|
|||
* Sends a broadcast in order to the interested activities can update their
|
||||
* view
|
||||
*
|
||||
* TODO - no more broadcasts, replace with a callback to subscribed listeners
|
||||
*
|
||||
* @param upload Finished upload operation
|
||||
* @param uploadResult Result of the upload operation
|
||||
* @param unlinkedFromRemotePath Path in the uploads tree where the upload was unlinked from
|
||||
|
|
|
@ -104,6 +104,7 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
|
|||
// Listen for upload messages
|
||||
mUploadMessagesReceiver = new UploadMessagesReceiver();
|
||||
IntentFilter uploadIntentFilter = new IntentFilter();
|
||||
uploadIntentFilter.addAction(FileUploader.getUploadsAddedMessage());
|
||||
uploadIntentFilter.addAction(FileUploader.getUploadStartMessage());
|
||||
uploadIntentFilter.addAction(FileUploader.getUploadFinishMessage());
|
||||
registerReceiver(mUploadMessagesReceiver, uploadIntentFilter);
|
||||
|
|
Loading…
Reference in a new issue