use of com.ferg.awfulapp.task.AnnouncementsRequest in project Awful.apk by Awful.
the class AnnouncementsFragment method showAnnouncements.
/**
* Fire off the network request to get and show the current announcements.
* Not caching these in the DB! Maybe later! Probably not!!
*/
private void showAnnouncements() {
Context context = getContext().getApplicationContext();
statusFrog.setStatusText(R.string.announcements_status_fetching).showSpinner(true);
queueRequest(new AnnouncementsRequest(context).build(this, new AwfulRequest.AwfulResultCallback<List<AwfulPost>>() {
@Override
public void success(List<AwfulPost> result) {
AnnouncementsManager.getInstance().markAllRead();
// update the status frog if there are no announcements, otherwise hide it and display them
if (result.size() < 1) {
statusFrog.setStatusText(R.string.announcements_status_none).showSpinner(false);
} else {
webView.setVisibility(View.VISIBLE);
// these page params don't mean anything in the context of the announcement page
// we just want it to a) display ok, and b) not let the user click anything bad
bodyHtml = ThreadDisplay.getHtml(result, AwfulPreferences.getInstance(), 1, 1);
if (webView != null) {
webView.refreshPageContents(true);
}
statusFrog.setVisibility(View.INVISIBLE);
}
}
@Override
public void failure(VolleyError error) {
statusFrog.setStatusText(R.string.announcements_status_failed).showSpinner(false);
Timber.w("Announcement get failed!\n" + error.getMessage());
}
}));
}
Aggregations