From 1669f287d4926e65dfe82bde5591222fcf81e8dc Mon Sep 17 00:00:00 2001 From: Chris Banes Date: Wed, 19 Dec 2012 11:40:11 +0000 Subject: [PATCH] Fix Refreshing on ListView when using a Header Background --- .../library/PullToRefreshListView.java | 5 ++-- .../library/internal/LoadingLayout.java | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/library/src/com/handmark/pulltorefresh/library/PullToRefreshListView.java b/library/src/com/handmark/pulltorefresh/library/PullToRefreshListView.java index 17c1d7771..a94275f33 100644 --- a/library/src/com/handmark/pulltorefresh/library/PullToRefreshListView.java +++ b/library/src/com/handmark/pulltorefresh/library/PullToRefreshListView.java @@ -105,7 +105,8 @@ void onRefreshing(final boolean doScroll) { } // Hide our original Loading View - origLoadingView.setVisibility(View.INVISIBLE); + origLoadingView.reset(); + origLoadingView.hideAllViews(); // Make sure the opposite end is hidden too oppositeListViewLoadingView.setVisibility(View.GONE); @@ -169,7 +170,7 @@ void onReset() { if (listViewLoadingLayout.getVisibility() == View.VISIBLE) { // Set our Original View to Visible - originalLoadingLayout.setVisibility(View.VISIBLE); + originalLoadingLayout.showInvisibleViews(); // Hide the ListView Header/Footer listViewLoadingLayout.setVisibility(View.GONE); diff --git a/library/src/com/handmark/pulltorefresh/library/internal/LoadingLayout.java b/library/src/com/handmark/pulltorefresh/library/internal/LoadingLayout.java index 3c7d4541b..6a509bfda 100644 --- a/library/src/com/handmark/pulltorefresh/library/internal/LoadingLayout.java +++ b/library/src/com/handmark/pulltorefresh/library/internal/LoadingLayout.java @@ -192,6 +192,36 @@ public final void adjustWidthUsingRightPadding(final int width) { getPaddingBottom()); } + public final void hideAllViews() { + if (View.VISIBLE == mHeaderText.getVisibility()) { + mHeaderText.setVisibility(View.INVISIBLE); + } + if (View.VISIBLE == mHeaderProgress.getVisibility()) { + mHeaderProgress.setVisibility(View.INVISIBLE); + } + if (View.VISIBLE == mHeaderImage.getVisibility()) { + mHeaderImage.setVisibility(View.INVISIBLE); + } + if (View.VISIBLE == mSubHeaderText.getVisibility()) { + mSubHeaderText.setVisibility(View.INVISIBLE); + } + } + + public final void showInvisibleViews() { + if (View.INVISIBLE == mHeaderText.getVisibility()) { + mHeaderText.setVisibility(View.VISIBLE); + } + if (View.INVISIBLE == mHeaderProgress.getVisibility()) { + mHeaderProgress.setVisibility(View.VISIBLE); + } + if (View.INVISIBLE == mHeaderImage.getVisibility()) { + mHeaderImage.setVisibility(View.VISIBLE); + } + if (View.INVISIBLE == mSubHeaderText.getVisibility()) { + mSubHeaderText.setVisibility(View.VISIBLE); + } + } + public final void onPull(float scaleOfLayout) { if (!mUseIntrinsicAnimation) { onPullImpl(scaleOfLayout);