chrisbanes/Android-PullToRefresh — pull request #65 by smpete (2012-04-21 00:08:49+00:00)
Title: Adding subheader support for last updated times

This was originally made to have the ability to show the last updated time underneath the the pull to refresh label. I decided to just make it a generic string for this pull request so the app can deal with formatting the date (or displaying something else). Here's the date code I was using just in case it would be preferable to restrict the user to a date:

public void setUpdateTime(Date date) {
if (date == null) {
headerUpdateText.setVisibility(View.GONE);
} else {
headerUpdateText.setVisibility(View.VISIBLE);
SimpleDateFormat df;
Calendar currentCal = Calendar.getInstance();
Calendar cal = Calendar.getInstance();
cal.setTime(date);
if (cal.get(Calendar.YEAR) == currentCal.get(Calendar.YEAR)
&& cal.get(Calendar.DAY_OF_YEAR) == currentCal.get(Calendar.DAY_OF_YEAR)) {
df = new SimpleDateFormat("'LAST UPDATED TODAY AT' hh:mm a");
} else {
df = new SimpleDateFormat("'LAST UPDATED' M/d/yy 'AT' hh:mm a");
}

headerUpdateText.setText(Html.fromHtml(df.format(date)));
}
}

I also changed all the `TextView.setText(String s)` calls in the LoadingLayout to call `Html.fromHtml(String s)` on the text passed. This will allow part of the string to be bold, italic, etc.

Both of these additions should have no different effect if they are not used, it should behave as normal.