chrisbanes/ActionBar-PullToRefresh — pull request #83 by sockeqwe (2013-08-16 11:37:12+00:00)
Title: Added HeaderViewListener

Hi,
I have added a HeaderViewListener to get a callback when the header view is animating in and out:

Don't ask me why, but eclipse has formatted your code (even if I can't see any difference) therfore the diff is not really helpful. Résumé: have added the following lines to `PullToRefreshAttacher`:
```java
/**
* A simple listener that gets notified when the pull to refresh actionbar
* header view is shown or has been removed
*
* @author Hannes Dorfmann
*
*/
public interface HeaderViewListener {

/**
* This method gets called to notify, that the actionbar header view is
* now visible on screen. To be more precise: The "show animation" has
* been started but, the animation could be running while this method
* has been called
*
*/
public void onBecomingVisible();

/**
* The method gets called to notify, that the actionbar header view is
* not visible anymore on screen. To be more precise: The hide animation
* has been started but, the animation could be running while this
* method has been called
*/
public void onHiding();

}

void onPullStarted(float y) {
if (DEBUG) {
Log.d(LOG_TAG, "onPullStarted");
}

// Notify HeaderViewListener
if (mHeaderViewListener != null)
mHeaderViewListener.onBecomingVisible();

// Show Header
if (mHeaderInAnimation != null) {
mHeaderView.startAnimation(mHeaderInAnimation);
}

mHeaderView.setVisibility(View.VISIBLE);
mPullBeginY = y;

}

private void reset(boolean fromTouch) {
// Update isRefreshing state
mIsRefreshing = false;

// Remove any minimize callbacks
mHandler.removeCallbacks(mRefreshMinimizeRunnable);

if (mHeaderView.getVisibility() != View.GONE) {
// Hide Header
if (mHeaderOutAnimation != null) {
mHeaderView.startAnimation(mHeaderOutAnimation);
// HeaderTransformer.onReset() is called once the animation has
// finished
} else {
// As we're not animating, hide the header + call the header
// transformer now
mHeaderView.setVisibility(View.GONE);
mHeaderTransformer.onReset();
}
}

// Notify HeaderViewListener
if (mHeaderViewListener != null)
mHeaderViewListener.onHiding();
}

/**
* Set the {@link HeaderViewListener}
*
* @param listener
*/
public void setHeaderViewListener(HeaderViewListener listener) {
mHeaderViewListener = listener;
}
```

I know I could retrieve that events in the HeaderViewTransformer.onPulled() and HeaderViewTransformer.onReset(), but it feels more like a workaround.

Where to use HeaderViewListener? I need such an Listener to start / stop a Timer that will update the timestamp of the last update, while the header view is visible (to display a text like: 1 second ago, 10 seconds ago, 1 hour ago, ...)