Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract vote registration query to a method #5

Open
paulsmithkc opened this issue Feb 28, 2022 · 0 comments
Open

Extract vote registration query to a method #5

paulsmithkc opened this issue Feb 28, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@paulsmithkc
Copy link
Owner

// observe the votes collection
// FIXME: move to a separate method
// FIXME: extract user-visible strings
votesRegistration =
db.collection("movieVote")
.whereEqualTo("username", username)
.addSnapshotListener((QuerySnapshot querySnapshot, FirebaseFirestoreException error) -> {
if (error != null) {
Log.e(LOG_TAG, "Error getting votes.", error);
snackbarMessage.postValue("Error getting votes.");
} else if (querySnapshot != null) {
Log.i(LOG_TAG, "Votes update.");
//List<MovieVoteValue> newVotes = querySnapshot.toObjects(MovieVoteValue.class);
List<MovieVoteValue> newVotes = new ArrayList<>();
for (QueryDocumentSnapshot document : querySnapshot) {
String movieId = document.getString("movieId");
Long value = document.getLong("value");
if (movieId != null && value != null) {
newVotes.add(new MovieVoteValue(movieId, value.intValue()));
}
}
votes.postValue(newVotes);
// snackbarMessage.postValue("Votes Updated.");
}
});

@paulsmithkc paulsmithkc added enhancement New feature or request good first issue Good for newcomers labels Feb 28, 2022
@paulsmithkc paulsmithkc removed the good first issue Good for newcomers label Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant