Firebase Add Callback when OnCompleteListener finished [duplicate]










0
















This question already has an answer here:



  • How to return a DocumentSnapShot as a result of a method?

    1 answer



  • Wait until Firestore data is retrieved to launch an activity

    1 answer



I am working on a project using Firebase and I have some issue concerning the OnCompleteListener function.
I want put integer inside a List. These integers are corresponding to number of documents inside a collection.



I have made inside my activity a method called getListWorkmatesJoining().
This method is using a list of "result".



My method :



private void getListWorkmatesJoining()
for (int i=0 ; i<restaurant_list.size(); i++)
RestaurantHelper.getWorkmatesJoining(restaurant_list.get(i).getPlaceId(), DateUtility.getDateTime())
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task)
if (task.isSuccessful())
if (task.getResult().getDocuments().isEmpty())
workmates_list.add(0);
else
workmates_list.add(task.getResult().getDocuments().size());



);




I am adding to my workmates_list an integer. This integer is 0 if the number of document is 0 or the number of document.
How am I able to launch another method when this one is completely finished ?
Is there a callback or something ?



Thanks for your help.










share|improve this question













marked as duplicate by Alex Mamo android
Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 12:27


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Please check the duplicate to see why do you have this behaviour and how can you solve this using a custom callback.

    – Alex Mamo
    Nov 14 '18 at 12:28











  • Thanks. The thing which is not that easy in my case is that I am making a loop with multiple addOnCompleteListener. To be sure that one is one it is easy but all of them it is not the same right ?

    – Nicolas DUBOSCQ
    Nov 15 '18 at 1:40











  • Should be the same but in this case, you should post another question and create a MCVE with this specific issue.

    – Alex Mamo
    Nov 15 '18 at 7:20
















0
















This question already has an answer here:



  • How to return a DocumentSnapShot as a result of a method?

    1 answer



  • Wait until Firestore data is retrieved to launch an activity

    1 answer



I am working on a project using Firebase and I have some issue concerning the OnCompleteListener function.
I want put integer inside a List. These integers are corresponding to number of documents inside a collection.



I have made inside my activity a method called getListWorkmatesJoining().
This method is using a list of "result".



My method :



private void getListWorkmatesJoining()
for (int i=0 ; i<restaurant_list.size(); i++)
RestaurantHelper.getWorkmatesJoining(restaurant_list.get(i).getPlaceId(), DateUtility.getDateTime())
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task)
if (task.isSuccessful())
if (task.getResult().getDocuments().isEmpty())
workmates_list.add(0);
else
workmates_list.add(task.getResult().getDocuments().size());



);




I am adding to my workmates_list an integer. This integer is 0 if the number of document is 0 or the number of document.
How am I able to launch another method when this one is completely finished ?
Is there a callback or something ?



Thanks for your help.










share|improve this question













marked as duplicate by Alex Mamo android
Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 12:27


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Please check the duplicate to see why do you have this behaviour and how can you solve this using a custom callback.

    – Alex Mamo
    Nov 14 '18 at 12:28











  • Thanks. The thing which is not that easy in my case is that I am making a loop with multiple addOnCompleteListener. To be sure that one is one it is easy but all of them it is not the same right ?

    – Nicolas DUBOSCQ
    Nov 15 '18 at 1:40











  • Should be the same but in this case, you should post another question and create a MCVE with this specific issue.

    – Alex Mamo
    Nov 15 '18 at 7:20














0












0








0









This question already has an answer here:



  • How to return a DocumentSnapShot as a result of a method?

    1 answer



  • Wait until Firestore data is retrieved to launch an activity

    1 answer



I am working on a project using Firebase and I have some issue concerning the OnCompleteListener function.
I want put integer inside a List. These integers are corresponding to number of documents inside a collection.



I have made inside my activity a method called getListWorkmatesJoining().
This method is using a list of "result".



My method :



private void getListWorkmatesJoining()
for (int i=0 ; i<restaurant_list.size(); i++)
RestaurantHelper.getWorkmatesJoining(restaurant_list.get(i).getPlaceId(), DateUtility.getDateTime())
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task)
if (task.isSuccessful())
if (task.getResult().getDocuments().isEmpty())
workmates_list.add(0);
else
workmates_list.add(task.getResult().getDocuments().size());



);




I am adding to my workmates_list an integer. This integer is 0 if the number of document is 0 or the number of document.
How am I able to launch another method when this one is completely finished ?
Is there a callback or something ?



Thanks for your help.










share|improve this question















This question already has an answer here:



  • How to return a DocumentSnapShot as a result of a method?

    1 answer



  • Wait until Firestore data is retrieved to launch an activity

    1 answer



I am working on a project using Firebase and I have some issue concerning the OnCompleteListener function.
I want put integer inside a List. These integers are corresponding to number of documents inside a collection.



I have made inside my activity a method called getListWorkmatesJoining().
This method is using a list of "result".



My method :



private void getListWorkmatesJoining()
for (int i=0 ; i<restaurant_list.size(); i++)
RestaurantHelper.getWorkmatesJoining(restaurant_list.get(i).getPlaceId(), DateUtility.getDateTime())
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task)
if (task.isSuccessful())
if (task.getResult().getDocuments().isEmpty())
workmates_list.add(0);
else
workmates_list.add(task.getResult().getDocuments().size());



);




I am adding to my workmates_list an integer. This integer is 0 if the number of document is 0 or the number of document.
How am I able to launch another method when this one is completely finished ?
Is there a callback or something ?



Thanks for your help.





This question already has an answer here:



  • How to return a DocumentSnapShot as a result of a method?

    1 answer



  • Wait until Firestore data is retrieved to launch an activity

    1 answer







android firebase firebase-realtime-database






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 22:05









Nicolas DUBOSCQNicolas DUBOSCQ

1




1




marked as duplicate by Alex Mamo android
Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 12:27


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Alex Mamo android
Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 12:27


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Please check the duplicate to see why do you have this behaviour and how can you solve this using a custom callback.

    – Alex Mamo
    Nov 14 '18 at 12:28











  • Thanks. The thing which is not that easy in my case is that I am making a loop with multiple addOnCompleteListener. To be sure that one is one it is easy but all of them it is not the same right ?

    – Nicolas DUBOSCQ
    Nov 15 '18 at 1:40











  • Should be the same but in this case, you should post another question and create a MCVE with this specific issue.

    – Alex Mamo
    Nov 15 '18 at 7:20


















  • Please check the duplicate to see why do you have this behaviour and how can you solve this using a custom callback.

    – Alex Mamo
    Nov 14 '18 at 12:28











  • Thanks. The thing which is not that easy in my case is that I am making a loop with multiple addOnCompleteListener. To be sure that one is one it is easy but all of them it is not the same right ?

    – Nicolas DUBOSCQ
    Nov 15 '18 at 1:40











  • Should be the same but in this case, you should post another question and create a MCVE with this specific issue.

    – Alex Mamo
    Nov 15 '18 at 7:20

















Please check the duplicate to see why do you have this behaviour and how can you solve this using a custom callback.

– Alex Mamo
Nov 14 '18 at 12:28





Please check the duplicate to see why do you have this behaviour and how can you solve this using a custom callback.

– Alex Mamo
Nov 14 '18 at 12:28













Thanks. The thing which is not that easy in my case is that I am making a loop with multiple addOnCompleteListener. To be sure that one is one it is easy but all of them it is not the same right ?

– Nicolas DUBOSCQ
Nov 15 '18 at 1:40





Thanks. The thing which is not that easy in my case is that I am making a loop with multiple addOnCompleteListener. To be sure that one is one it is easy but all of them it is not the same right ?

– Nicolas DUBOSCQ
Nov 15 '18 at 1:40













Should be the same but in this case, you should post another question and create a MCVE with this specific issue.

– Alex Mamo
Nov 15 '18 at 7:20






Should be the same but in this case, you should post another question and create a MCVE with this specific issue.

– Alex Mamo
Nov 15 '18 at 7:20













0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

這個網誌中的熱門文章

What does pagestruct do in Eviews?

Dutch intervention in Lombok and Karangasem

Channel Islands