This is the flow of my program:
I can create a learning session where in this session, user can stream video, and/or download attached file(s), and/or answering question in multiple choice format.
So in one session, it can contains a video and/or file(s) and/or question(s).
In the process of creating session, I must finish all upload task for video and/or file(s) and also finish all database task saving the question(s) for that session, before I save the session in database. In this case, I use something like this
Tasks.whenAll(listTask)
, where I addonCompleteListener
to the final task, where I finally save the session to database.Almost all is working as expected, question(s) saved, video uploaded, but there is a problem with the
UploadTask
that returned from uploading the video. In mySession
class, I havevideoUrl
field that will contain the url of the video. In order to get the url of the video, I must addonCompleteListener
to myUploadTask
, get the url from task's result and save the url in my class instance. But, the video url is never saved to database, because theonCompleteListener
of final task is called first.
My question is, how to execute Tasks.whenAll(listTask), when all task in listTask are completed, with their onCompleteListener completed too?