Created
December 10, 2015 22:15
-
-
Save akuafif/c05f50b528a15bf9924e to your computer and use it in GitHub Desktop.
[Java/Android] BaasBox - BaasQuery, fetchAll and store result in List<BaasDocument>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What to retrive? | |
// | |
// All the Documents in the 'note' Collection | |
// WHERE Document _author is the current logged in user | |
// ORDERBY _creation_date descending | |
// List to hold the notes | |
List<BaasDocument> noteList = new ArrayList<BaasDocument>(); | |
// using pagination and selection | |
// .whereParams doesn't work for me. | |
BaasQuery.Criteria filter = BaasQuery.builder().pagination(0, 20) | |
.orderBy("_creation_date desc") | |
.where("_author='" + BaasUser.current().getName() + "'") | |
.criteria(); | |
BaasDocument.fetchAll("note", filter, | |
new BaasHandler<List<BaasDocument>>() { | |
@Override | |
public void handle(BaasResult<List<BaasDocument>> res) { | |
for (BaasDocument item : res.value()) { | |
noteList.add(item); | |
} | |
// Log.d(TAG, "Result:" + res.toString()); | |
Log.d(TAG, "note fetched: " + noteList.size()); | |
// Notify the adapter that the data has changed. | |
// This is needed if using RecyclerView | |
mAdapter.notifyDataSetChanged(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment