Skip to content

Instantly share code, notes, and snippets.

@tpakis
Last active April 30, 2018 12:24
Show Gist options
  • Save tpakis/1dd3db18fbf31208ea568b2a9ab1e463 to your computer and use it in GitHub Desktop.
Save tpakis/1dd3db18fbf31208ea568b2a9ab1e463 to your computer and use it in GitHub Desktop.
Async call to load from
private void loadAllRecipesFromDB() {
Timber.d("loadAllRecipesFromDB");
new AsyncTask<Void, Void, List<Recipe>>() {
@Override
protected List<Recipe> doInBackground(Void...a) {
return recipesDAO.getAllEntries();
}
@Override
protected void onPostExecute(List<Recipe> results) {
//check if there are data in the db
if ((results != null)&&results.size()>0) {
setRecipesListObservableData(results, null);
}
}
}.execute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment