mirror of
https://github.com/nextcloud/android.git
synced 2024-12-19 23:42:03 +03:00
sendSyncWorkerCompletionBroadcast
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
fe30406964
commit
a474948118
2 changed files with 24 additions and 1 deletions
|
@ -32,6 +32,8 @@ class SyncWorker(
|
|||
|
||||
const val FILE_PATHS = "FILE_PATHS"
|
||||
const val TOP_PARENT_PATH = "TOP_PARENT_PATH"
|
||||
|
||||
const val SYNC_WORKER_COMPLETION_BROADCAST = "SYNC_WORKER_COMPLETION_BROADCAST"
|
||||
const val FILE_DOWNLOAD_COMPLETION_BROADCAST = "FILE_DOWNLOAD_COMPLETION_BROADCAST"
|
||||
const val FILE_PATH = "FILE_PATH"
|
||||
|
||||
|
@ -94,13 +96,13 @@ class SyncWorker(
|
|||
}
|
||||
}
|
||||
|
||||
// TODO add cancel only one file download
|
||||
withContext(Dispatchers.Main) {
|
||||
notificationManager.showCompletionMessage(result)
|
||||
}
|
||||
|
||||
if (result) {
|
||||
downloadingFilePaths.remove(topParentPath)
|
||||
sendSyncWorkerCompletionBroadcast()
|
||||
Log_OC.d(TAG, "SyncWorker completed")
|
||||
Result.success()
|
||||
} else {
|
||||
|
@ -117,4 +119,9 @@ class SyncWorker(
|
|||
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent)
|
||||
}
|
||||
|
||||
private fun sendSyncWorkerCompletionBroadcast() {
|
||||
val intent = Intent(SYNC_WORKER_COMPLETION_BROADCAST)
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,12 +200,28 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
|
||||
setHasStableIds(true);
|
||||
|
||||
registerSyncWorkerCompletionReceiver();
|
||||
registerFileDownloadCompletionReceiver();
|
||||
|
||||
// initialise thumbnails cache on background thread
|
||||
new ThumbnailsCacheManager.InitDiskCacheTask().execute();
|
||||
}
|
||||
|
||||
private void registerSyncWorkerCompletionReceiver() {
|
||||
LocalBroadcastManager
|
||||
.getInstance(activity)
|
||||
.registerReceiver(syncWorkerCompletionReceiver, new IntentFilter(SyncWorker.SYNC_WORKER_COMPLETION_BROADCAST));
|
||||
}
|
||||
|
||||
private final BroadcastReceiver syncWorkerCompletionReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (activity instanceof FileDisplayActivity fda) {
|
||||
fda.refreshList();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void registerFileDownloadCompletionReceiver() {
|
||||
LocalBroadcastManager
|
||||
.getInstance(activity)
|
||||
|
|
Loading…
Reference in a new issue