Last active
December 15, 2015 04:19
-
-
Save robhinds/5200181 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
protected void onPostExecute(final List<Article> articles) { | |
Log.e("ASYNC", "POST EXECUTE"); | |
articleListFrag.getActivity().runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
for (Article a : articles){ | |
Log.d("DB", "Searching DB for GUID: " + a.getGuid()); | |
DbAdapter dba = new DbAdapter(articleListFrag.getActivity()); | |
dba.openToRead(); | |
Article fetchedArticle = dba.getBlogListing(a.getGuid()); | |
dba.close(); | |
if (fetchedArticle == null){ | |
Log.d("DB", "Found entry for first time: " + a.getTitle()); | |
dba = new DbAdapter(articleListFrag.getActivity()); | |
dba.openToWrite(); | |
dba.insertBlogListing(a.getGuid()); | |
dba.close(); | |
}else{ | |
a.setDbId(fetchedArticle.getDbId()); | |
a.setOffline(fetchedArticle.isOffline()); | |
a.setRead(fetchedArticle.isRead()); | |
} | |
} | |
ArticleListAdapter adapter = new ArticleListAdapter(articleListFrag.getActivity(), articles); | |
articleListFrag.setListAdapter(adapter); | |
adapter.notifyDataSetChanged(); | |
} | |
}); | |
progress.dismiss(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment