Firebase Tasks whenAll not working as expected, skipping OnCompleteListener

339 views Asked by At

This is the flow of my program:

  1. 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.

  2. So in one session, it can contains a video and/or file(s) and/or question(s).

  3. 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 add onCompleteListener to the final task, where I finally save the session to database.

  4. 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 my Session class, I have videoUrl field that will contain the url of the video. In order to get the url of the video, I must add onCompleteListener to my UploadTask, 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 the onCompleteListener 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?

0

There are 0 answers