firestore onSuccess listener isn't working
I am trying to download some Quiz objects from my database.
The following function is called from onCreate of a certain activity.
private void downloadQuizzesFromCloud(){
String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid();
final FirebaseFirestore db = FirebaseFirestore.getInstance();
String user_quizzes_path = "users/".concat(user_id).concat("/quizzes");
Query userQuizzes = db.collection(user_quizzes_path);
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
quizzes.clear();
for (QueryDocumentSnapshot document : task.getResult()) {
Quiz quizDownloaded = getQuizFromCloud(document.getId());
quizzes.add(quizDownloaded);
}
Toast.makeText(QuizzesActivity.this,"downloaded to list ".concat(String.valueOf(quizzes.size()).concat(" quizzes")), Toast.LENGTH_SHORT).show();
//TODO put in recycle adapter
} else { }
}
});
}
(user_quizzes_path contains the correct path to a collection of Quiz objects stored on the cloud)
I debugged this functions and found out that after the command:
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
The function finishes execution, that is the onComplete cases aren't checked and executed and all this code is just skipped.
I tried to find this on the documentation of firebase but didn't find anything.
Why is this happening and how can I fix this?
Would appreciate some help here, thanks!
android firebase google-cloud-firestore
add a comment |
I am trying to download some Quiz objects from my database.
The following function is called from onCreate of a certain activity.
private void downloadQuizzesFromCloud(){
String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid();
final FirebaseFirestore db = FirebaseFirestore.getInstance();
String user_quizzes_path = "users/".concat(user_id).concat("/quizzes");
Query userQuizzes = db.collection(user_quizzes_path);
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
quizzes.clear();
for (QueryDocumentSnapshot document : task.getResult()) {
Quiz quizDownloaded = getQuizFromCloud(document.getId());
quizzes.add(quizDownloaded);
}
Toast.makeText(QuizzesActivity.this,"downloaded to list ".concat(String.valueOf(quizzes.size()).concat(" quizzes")), Toast.LENGTH_SHORT).show();
//TODO put in recycle adapter
} else { }
}
});
}
(user_quizzes_path contains the correct path to a collection of Quiz objects stored on the cloud)
I debugged this functions and found out that after the command:
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
The function finishes execution, that is the onComplete cases aren't checked and executed and all this code is just skipped.
I tried to find this on the documentation of firebase but didn't find anything.
Why is this happening and how can I fix this?
Would appreciate some help here, thanks!
android firebase google-cloud-firestore
add a comment |
I am trying to download some Quiz objects from my database.
The following function is called from onCreate of a certain activity.
private void downloadQuizzesFromCloud(){
String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid();
final FirebaseFirestore db = FirebaseFirestore.getInstance();
String user_quizzes_path = "users/".concat(user_id).concat("/quizzes");
Query userQuizzes = db.collection(user_quizzes_path);
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
quizzes.clear();
for (QueryDocumentSnapshot document : task.getResult()) {
Quiz quizDownloaded = getQuizFromCloud(document.getId());
quizzes.add(quizDownloaded);
}
Toast.makeText(QuizzesActivity.this,"downloaded to list ".concat(String.valueOf(quizzes.size()).concat(" quizzes")), Toast.LENGTH_SHORT).show();
//TODO put in recycle adapter
} else { }
}
});
}
(user_quizzes_path contains the correct path to a collection of Quiz objects stored on the cloud)
I debugged this functions and found out that after the command:
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
The function finishes execution, that is the onComplete cases aren't checked and executed and all this code is just skipped.
I tried to find this on the documentation of firebase but didn't find anything.
Why is this happening and how can I fix this?
Would appreciate some help here, thanks!
android firebase google-cloud-firestore
I am trying to download some Quiz objects from my database.
The following function is called from onCreate of a certain activity.
private void downloadQuizzesFromCloud(){
String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid();
final FirebaseFirestore db = FirebaseFirestore.getInstance();
String user_quizzes_path = "users/".concat(user_id).concat("/quizzes");
Query userQuizzes = db.collection(user_quizzes_path);
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
quizzes.clear();
for (QueryDocumentSnapshot document : task.getResult()) {
Quiz quizDownloaded = getQuizFromCloud(document.getId());
quizzes.add(quizDownloaded);
}
Toast.makeText(QuizzesActivity.this,"downloaded to list ".concat(String.valueOf(quizzes.size()).concat(" quizzes")), Toast.LENGTH_SHORT).show();
//TODO put in recycle adapter
} else { }
}
});
}
(user_quizzes_path contains the correct path to a collection of Quiz objects stored on the cloud)
I debugged this functions and found out that after the command:
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
The function finishes execution, that is the onComplete cases aren't checked and executed and all this code is just skipped.
I tried to find this on the documentation of firebase but didn't find anything.
Why is this happening and how can I fix this?
Would appreciate some help here, thanks!
android firebase google-cloud-firestore
android firebase google-cloud-firestore
asked Dec 28 '18 at 18:10
genericnamegenericname
727
727
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The onComplete
is called when the read operation has completed from the Firestore servers. If it's not getting called, I can see two possible reasons:
- You're not connected to the server. Unless you've read the data before (and it's in the local database that the Firestore client maintains), this means the read never completes locally.
- You're not thinking asynchronously. Note that data is read from the server asynchronously, and there may be some time between when you call
get()
and whenonComplete
fires. To test if this is the case, put a breakpoint onif (task.isSuccessful()) {
and run the app in the debugger. The breakpoint will hit when the data is read from the server.
Thank you, the problem is indeed because I am not thinking asynchronously. How can I make sure that objects I change in my code will change only after the server data read is complete?
– genericname
Dec 29 '18 at 8:35
You do that by calling the code from withinonComplete
, since that is the method that fires after the data has loaded.
– Frank van Puffelen
Dec 29 '18 at 15:11
this would work however if I were to use the variable "quizzes" somewhere else in my code, (for example just before the function "downloadQuizzesFromCloud" is finished) It is not promised that the task has finished and I could have incorrect data in "quizzes" variable. Is there a way to solve this?
– genericname
Dec 29 '18 at 15:16
Any code that depends on the quizes that are loaded asynchronously from the database should be either inside theonComplete
(that is called when the data has loaded) or called from within that method. I commented the same on your previous question here: stackoverflow.com/questions/53970276/…
– Frank van Puffelen
Dec 29 '18 at 16:42
add a comment |
Use a callback interface. Just like this below.
private void downloadQuizzesFromCloud(Consumer listener) {
String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid();
final FirebaseFirestore db = FirebaseFirestore.getInstance();
String user_quizzes_path = "users/".concat(user_id).concat("/quizzes");
Query userQuizzes = db.collection(user_quizzes_path);
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
List<Quiz> quizzes = new ArrayList<>();
for (QueryDocumentSnapshot document : task.getResult()) {
Quiz quizDownloaded = getQuizFromCloud(document.getId());
quizzes.add(quizDownloaded);
}
listener.onGet(quizzes);
Toast.makeText(QuizzesActivity.this,"downloaded to list ".concat(String.valueOf(quizzes.size()).concat(" quizzes")), Toast.LENGTH_SHORT).show();
//TODO put in recycle adapter
} else { }
}
});
}
interface Consumer {
void onGet(List<Quiz> quizzes);
}
I want to acheive something like this: downloadQuizzesFromCloud(); print(quizzes); and I want that quizzes will be updated when I print them. How does can I do this with a callback interface?
– genericname
Dec 29 '18 at 10:21
CalldownloadQuizzesFromCloud(this::print)
and declare a functionprivate void print(List<Quiz> quizzes) { // do everything here. }
. If you're using JAVA-7 then do this following,downloadQuizzesFromCloud(this)
and implement theonGet(List<Quiz> quizzes)
function
– Abdullah Aftab
Dec 31 '18 at 4:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53962633%2ffirestore-onsuccess-listener-isnt-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The onComplete
is called when the read operation has completed from the Firestore servers. If it's not getting called, I can see two possible reasons:
- You're not connected to the server. Unless you've read the data before (and it's in the local database that the Firestore client maintains), this means the read never completes locally.
- You're not thinking asynchronously. Note that data is read from the server asynchronously, and there may be some time between when you call
get()
and whenonComplete
fires. To test if this is the case, put a breakpoint onif (task.isSuccessful()) {
and run the app in the debugger. The breakpoint will hit when the data is read from the server.
Thank you, the problem is indeed because I am not thinking asynchronously. How can I make sure that objects I change in my code will change only after the server data read is complete?
– genericname
Dec 29 '18 at 8:35
You do that by calling the code from withinonComplete
, since that is the method that fires after the data has loaded.
– Frank van Puffelen
Dec 29 '18 at 15:11
this would work however if I were to use the variable "quizzes" somewhere else in my code, (for example just before the function "downloadQuizzesFromCloud" is finished) It is not promised that the task has finished and I could have incorrect data in "quizzes" variable. Is there a way to solve this?
– genericname
Dec 29 '18 at 15:16
Any code that depends on the quizes that are loaded asynchronously from the database should be either inside theonComplete
(that is called when the data has loaded) or called from within that method. I commented the same on your previous question here: stackoverflow.com/questions/53970276/…
– Frank van Puffelen
Dec 29 '18 at 16:42
add a comment |
The onComplete
is called when the read operation has completed from the Firestore servers. If it's not getting called, I can see two possible reasons:
- You're not connected to the server. Unless you've read the data before (and it's in the local database that the Firestore client maintains), this means the read never completes locally.
- You're not thinking asynchronously. Note that data is read from the server asynchronously, and there may be some time between when you call
get()
and whenonComplete
fires. To test if this is the case, put a breakpoint onif (task.isSuccessful()) {
and run the app in the debugger. The breakpoint will hit when the data is read from the server.
Thank you, the problem is indeed because I am not thinking asynchronously. How can I make sure that objects I change in my code will change only after the server data read is complete?
– genericname
Dec 29 '18 at 8:35
You do that by calling the code from withinonComplete
, since that is the method that fires after the data has loaded.
– Frank van Puffelen
Dec 29 '18 at 15:11
this would work however if I were to use the variable "quizzes" somewhere else in my code, (for example just before the function "downloadQuizzesFromCloud" is finished) It is not promised that the task has finished and I could have incorrect data in "quizzes" variable. Is there a way to solve this?
– genericname
Dec 29 '18 at 15:16
Any code that depends on the quizes that are loaded asynchronously from the database should be either inside theonComplete
(that is called when the data has loaded) or called from within that method. I commented the same on your previous question here: stackoverflow.com/questions/53970276/…
– Frank van Puffelen
Dec 29 '18 at 16:42
add a comment |
The onComplete
is called when the read operation has completed from the Firestore servers. If it's not getting called, I can see two possible reasons:
- You're not connected to the server. Unless you've read the data before (and it's in the local database that the Firestore client maintains), this means the read never completes locally.
- You're not thinking asynchronously. Note that data is read from the server asynchronously, and there may be some time between when you call
get()
and whenonComplete
fires. To test if this is the case, put a breakpoint onif (task.isSuccessful()) {
and run the app in the debugger. The breakpoint will hit when the data is read from the server.
The onComplete
is called when the read operation has completed from the Firestore servers. If it's not getting called, I can see two possible reasons:
- You're not connected to the server. Unless you've read the data before (and it's in the local database that the Firestore client maintains), this means the read never completes locally.
- You're not thinking asynchronously. Note that data is read from the server asynchronously, and there may be some time between when you call
get()
and whenonComplete
fires. To test if this is the case, put a breakpoint onif (task.isSuccessful()) {
and run the app in the debugger. The breakpoint will hit when the data is read from the server.
answered Dec 29 '18 at 7:00
Frank van PuffelenFrank van Puffelen
229k28376400
229k28376400
Thank you, the problem is indeed because I am not thinking asynchronously. How can I make sure that objects I change in my code will change only after the server data read is complete?
– genericname
Dec 29 '18 at 8:35
You do that by calling the code from withinonComplete
, since that is the method that fires after the data has loaded.
– Frank van Puffelen
Dec 29 '18 at 15:11
this would work however if I were to use the variable "quizzes" somewhere else in my code, (for example just before the function "downloadQuizzesFromCloud" is finished) It is not promised that the task has finished and I could have incorrect data in "quizzes" variable. Is there a way to solve this?
– genericname
Dec 29 '18 at 15:16
Any code that depends on the quizes that are loaded asynchronously from the database should be either inside theonComplete
(that is called when the data has loaded) or called from within that method. I commented the same on your previous question here: stackoverflow.com/questions/53970276/…
– Frank van Puffelen
Dec 29 '18 at 16:42
add a comment |
Thank you, the problem is indeed because I am not thinking asynchronously. How can I make sure that objects I change in my code will change only after the server data read is complete?
– genericname
Dec 29 '18 at 8:35
You do that by calling the code from withinonComplete
, since that is the method that fires after the data has loaded.
– Frank van Puffelen
Dec 29 '18 at 15:11
this would work however if I were to use the variable "quizzes" somewhere else in my code, (for example just before the function "downloadQuizzesFromCloud" is finished) It is not promised that the task has finished and I could have incorrect data in "quizzes" variable. Is there a way to solve this?
– genericname
Dec 29 '18 at 15:16
Any code that depends on the quizes that are loaded asynchronously from the database should be either inside theonComplete
(that is called when the data has loaded) or called from within that method. I commented the same on your previous question here: stackoverflow.com/questions/53970276/…
– Frank van Puffelen
Dec 29 '18 at 16:42
Thank you, the problem is indeed because I am not thinking asynchronously. How can I make sure that objects I change in my code will change only after the server data read is complete?
– genericname
Dec 29 '18 at 8:35
Thank you, the problem is indeed because I am not thinking asynchronously. How can I make sure that objects I change in my code will change only after the server data read is complete?
– genericname
Dec 29 '18 at 8:35
You do that by calling the code from within
onComplete
, since that is the method that fires after the data has loaded.– Frank van Puffelen
Dec 29 '18 at 15:11
You do that by calling the code from within
onComplete
, since that is the method that fires after the data has loaded.– Frank van Puffelen
Dec 29 '18 at 15:11
this would work however if I were to use the variable "quizzes" somewhere else in my code, (for example just before the function "downloadQuizzesFromCloud" is finished) It is not promised that the task has finished and I could have incorrect data in "quizzes" variable. Is there a way to solve this?
– genericname
Dec 29 '18 at 15:16
this would work however if I were to use the variable "quizzes" somewhere else in my code, (for example just before the function "downloadQuizzesFromCloud" is finished) It is not promised that the task has finished and I could have incorrect data in "quizzes" variable. Is there a way to solve this?
– genericname
Dec 29 '18 at 15:16
Any code that depends on the quizes that are loaded asynchronously from the database should be either inside the
onComplete
(that is called when the data has loaded) or called from within that method. I commented the same on your previous question here: stackoverflow.com/questions/53970276/…– Frank van Puffelen
Dec 29 '18 at 16:42
Any code that depends on the quizes that are loaded asynchronously from the database should be either inside the
onComplete
(that is called when the data has loaded) or called from within that method. I commented the same on your previous question here: stackoverflow.com/questions/53970276/…– Frank van Puffelen
Dec 29 '18 at 16:42
add a comment |
Use a callback interface. Just like this below.
private void downloadQuizzesFromCloud(Consumer listener) {
String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid();
final FirebaseFirestore db = FirebaseFirestore.getInstance();
String user_quizzes_path = "users/".concat(user_id).concat("/quizzes");
Query userQuizzes = db.collection(user_quizzes_path);
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
List<Quiz> quizzes = new ArrayList<>();
for (QueryDocumentSnapshot document : task.getResult()) {
Quiz quizDownloaded = getQuizFromCloud(document.getId());
quizzes.add(quizDownloaded);
}
listener.onGet(quizzes);
Toast.makeText(QuizzesActivity.this,"downloaded to list ".concat(String.valueOf(quizzes.size()).concat(" quizzes")), Toast.LENGTH_SHORT).show();
//TODO put in recycle adapter
} else { }
}
});
}
interface Consumer {
void onGet(List<Quiz> quizzes);
}
I want to acheive something like this: downloadQuizzesFromCloud(); print(quizzes); and I want that quizzes will be updated when I print them. How does can I do this with a callback interface?
– genericname
Dec 29 '18 at 10:21
CalldownloadQuizzesFromCloud(this::print)
and declare a functionprivate void print(List<Quiz> quizzes) { // do everything here. }
. If you're using JAVA-7 then do this following,downloadQuizzesFromCloud(this)
and implement theonGet(List<Quiz> quizzes)
function
– Abdullah Aftab
Dec 31 '18 at 4:27
add a comment |
Use a callback interface. Just like this below.
private void downloadQuizzesFromCloud(Consumer listener) {
String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid();
final FirebaseFirestore db = FirebaseFirestore.getInstance();
String user_quizzes_path = "users/".concat(user_id).concat("/quizzes");
Query userQuizzes = db.collection(user_quizzes_path);
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
List<Quiz> quizzes = new ArrayList<>();
for (QueryDocumentSnapshot document : task.getResult()) {
Quiz quizDownloaded = getQuizFromCloud(document.getId());
quizzes.add(quizDownloaded);
}
listener.onGet(quizzes);
Toast.makeText(QuizzesActivity.this,"downloaded to list ".concat(String.valueOf(quizzes.size()).concat(" quizzes")), Toast.LENGTH_SHORT).show();
//TODO put in recycle adapter
} else { }
}
});
}
interface Consumer {
void onGet(List<Quiz> quizzes);
}
I want to acheive something like this: downloadQuizzesFromCloud(); print(quizzes); and I want that quizzes will be updated when I print them. How does can I do this with a callback interface?
– genericname
Dec 29 '18 at 10:21
CalldownloadQuizzesFromCloud(this::print)
and declare a functionprivate void print(List<Quiz> quizzes) { // do everything here. }
. If you're using JAVA-7 then do this following,downloadQuizzesFromCloud(this)
and implement theonGet(List<Quiz> quizzes)
function
– Abdullah Aftab
Dec 31 '18 at 4:27
add a comment |
Use a callback interface. Just like this below.
private void downloadQuizzesFromCloud(Consumer listener) {
String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid();
final FirebaseFirestore db = FirebaseFirestore.getInstance();
String user_quizzes_path = "users/".concat(user_id).concat("/quizzes");
Query userQuizzes = db.collection(user_quizzes_path);
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
List<Quiz> quizzes = new ArrayList<>();
for (QueryDocumentSnapshot document : task.getResult()) {
Quiz quizDownloaded = getQuizFromCloud(document.getId());
quizzes.add(quizDownloaded);
}
listener.onGet(quizzes);
Toast.makeText(QuizzesActivity.this,"downloaded to list ".concat(String.valueOf(quizzes.size()).concat(" quizzes")), Toast.LENGTH_SHORT).show();
//TODO put in recycle adapter
} else { }
}
});
}
interface Consumer {
void onGet(List<Quiz> quizzes);
}
Use a callback interface. Just like this below.
private void downloadQuizzesFromCloud(Consumer listener) {
String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid();
final FirebaseFirestore db = FirebaseFirestore.getInstance();
String user_quizzes_path = "users/".concat(user_id).concat("/quizzes");
Query userQuizzes = db.collection(user_quizzes_path);
userQuizzes.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
List<Quiz> quizzes = new ArrayList<>();
for (QueryDocumentSnapshot document : task.getResult()) {
Quiz quizDownloaded = getQuizFromCloud(document.getId());
quizzes.add(quizDownloaded);
}
listener.onGet(quizzes);
Toast.makeText(QuizzesActivity.this,"downloaded to list ".concat(String.valueOf(quizzes.size()).concat(" quizzes")), Toast.LENGTH_SHORT).show();
//TODO put in recycle adapter
} else { }
}
});
}
interface Consumer {
void onGet(List<Quiz> quizzes);
}
answered Dec 29 '18 at 10:07
Abdullah AftabAbdullah Aftab
3214
3214
I want to acheive something like this: downloadQuizzesFromCloud(); print(quizzes); and I want that quizzes will be updated when I print them. How does can I do this with a callback interface?
– genericname
Dec 29 '18 at 10:21
CalldownloadQuizzesFromCloud(this::print)
and declare a functionprivate void print(List<Quiz> quizzes) { // do everything here. }
. If you're using JAVA-7 then do this following,downloadQuizzesFromCloud(this)
and implement theonGet(List<Quiz> quizzes)
function
– Abdullah Aftab
Dec 31 '18 at 4:27
add a comment |
I want to acheive something like this: downloadQuizzesFromCloud(); print(quizzes); and I want that quizzes will be updated when I print them. How does can I do this with a callback interface?
– genericname
Dec 29 '18 at 10:21
CalldownloadQuizzesFromCloud(this::print)
and declare a functionprivate void print(List<Quiz> quizzes) { // do everything here. }
. If you're using JAVA-7 then do this following,downloadQuizzesFromCloud(this)
and implement theonGet(List<Quiz> quizzes)
function
– Abdullah Aftab
Dec 31 '18 at 4:27
I want to acheive something like this: downloadQuizzesFromCloud(); print(quizzes); and I want that quizzes will be updated when I print them. How does can I do this with a callback interface?
– genericname
Dec 29 '18 at 10:21
I want to acheive something like this: downloadQuizzesFromCloud(); print(quizzes); and I want that quizzes will be updated when I print them. How does can I do this with a callback interface?
– genericname
Dec 29 '18 at 10:21
Call
downloadQuizzesFromCloud(this::print)
and declare a function private void print(List<Quiz> quizzes) { // do everything here. }
. If you're using JAVA-7 then do this following, downloadQuizzesFromCloud(this)
and implement the onGet(List<Quiz> quizzes)
function– Abdullah Aftab
Dec 31 '18 at 4:27
Call
downloadQuizzesFromCloud(this::print)
and declare a function private void print(List<Quiz> quizzes) { // do everything here. }
. If you're using JAVA-7 then do this following, downloadQuizzesFromCloud(this)
and implement the onGet(List<Quiz> quizzes)
function– Abdullah Aftab
Dec 31 '18 at 4:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53962633%2ffirestore-onsuccess-listener-isnt-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown