Adding subheader support for last updated times #65

Merged
merged 2 commits into from Apr 24, 2012

Conversation

Projects
None yet
2 participants
@smpete

smpete commented Apr 21, 2012

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("'<b>LAST UPDATED</b> TODAY AT' hh:mm a");
        } else {
            df = new SimpleDateFormat("'<b>LAST UPDATED</b>' 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.

Peter Elliott added some commits Apr 20, 2012

chrisbanes added a commit that referenced this pull request Apr 24, 2012

Merge pull request #65 from doubleencore/subheader
Adding subheader support for last updated times

@chrisbanes chrisbanes merged commit e403f03 into chrisbanes:dev Apr 24, 2012

chrisbanes added a commit that referenced this pull request Apr 24, 2012

@chrisbanes

This comment has been minimized.

Show comment
Hide comment
@chrisbanes

chrisbanes Apr 24, 2012

Owner

Thanks for this. I tweaked your code a bit in 886b544, but it's working great.

Owner

chrisbanes commented Apr 24, 2012

Thanks for this. I tweaked your code a bit in 886b544, but it's working great.

ncoolz pushed a commit to naver/android-pull-to-refresh that referenced this pull request Dec 2, 2013

Merge pull request #65 from doubleencore/subheader
Adding subheader support for last updated times

ncoolz pushed a commit to naver/android-pull-to-refresh that referenced this pull request Dec 2, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment