mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 15:05:44 +03:00
simplify worker call
Co-authored-by: Álvaro Brey <alvaro.brey@nextcloud.com> Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
8717314531
commit
3d0f154d7d
1 changed files with 6 additions and 15 deletions
|
@ -1356,28 +1356,19 @@ class ChatController(args: Bundle) :
|
|||
REQUEST_CODE_SELECT_REMOTE_FILES -> {
|
||||
val pathList = intent?.getStringArrayListExtra(RemoteFileBrowserActivity.EXTRA_SELECTED_PATHS)
|
||||
if (pathList?.size!! >= 1) {
|
||||
var paths: MutableList<String?> = ArrayList()
|
||||
var data: Data
|
||||
var shareWorker: OneTimeWorkRequest
|
||||
val iterator = pathList.iterator()
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
val path = iterator.next()
|
||||
paths.add(path)
|
||||
iterator.remove()
|
||||
if (paths.size == 10 || !iterator.hasNext()) {
|
||||
data = Data.Builder()
|
||||
pathList
|
||||
.chunked(10)
|
||||
.forEach { paths ->
|
||||
val data = Data.Builder()
|
||||
.putLong(KEY_INTERNAL_USER_ID, conversationUser!!.id)
|
||||
.putString(KEY_ROOM_TOKEN, roomToken)
|
||||
.putStringArray(KEY_FILE_PATHS, paths.toTypedArray())
|
||||
.build()
|
||||
shareWorker = OneTimeWorkRequest.Builder(ShareOperationWorker::class.java)
|
||||
val worker = OneTimeWorkRequest.Builder(ShareOperationWorker::class.java)
|
||||
.setInputData(data)
|
||||
.build()
|
||||
WorkManager.getInstance().enqueue(shareWorker)
|
||||
paths = java.util.ArrayList()
|
||||
WorkManager.getInstance().enqueue(worker)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_CHOOSE_FILE -> {
|
||||
|
|
Loading…
Reference in a new issue