Skip to content

Commit 9b69b67

Browse files
author
Chris Banes
committed
Fix Footer randomly appearing on PtRListView
1 parent 6a8c29a commit 9b69b67

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

library/src/com/handmark/pulltorefresh/library/PullToRefreshListView.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,38 +138,44 @@ void onRefreshing(final boolean doScroll) {
138138

139139
super.onRefreshing(false);
140140

141-
final LoadingLayout originalLoadingLayout, listViewLoadingLayout;
141+
final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
142142
final int selection, scrollToY;
143143

144144
switch (getCurrentMode()) {
145145
case MANUAL_REFRESH_ONLY:
146146
case PULL_FROM_END:
147-
originalLoadingLayout = getFooterLayout();
148-
listViewLoadingLayout = mFooterLoadingView;
147+
origLoadingView = getFooterLayout();
148+
listViewLoadingView = mFooterLoadingView;
149+
oppositeListViewLoadingView = mHeaderLoadingView;
149150
selection = mRefreshableView.getCount() - 1;
150151
scrollToY = getScrollY() - getFooterHeight();
151152
break;
152153
case PULL_FROM_START:
153154
default:
154-
originalLoadingLayout = getHeaderLayout();
155-
listViewLoadingLayout = mHeaderLoadingView;
155+
origLoadingView = getHeaderLayout();
156+
listViewLoadingView = mHeaderLoadingView;
157+
oppositeListViewLoadingView = mFooterLoadingView;
156158
selection = 0;
157159
scrollToY = getScrollY() + getHeaderHeight();
158160
break;
159161
}
160162

161163
// Hide our original Loading View
162-
originalLoadingLayout.setVisibility(View.INVISIBLE);
164+
origLoadingView.setVisibility(View.INVISIBLE);
165+
166+
// Make sure the opposite end is hidden too
167+
oppositeListViewLoadingView.setVisibility(View.GONE);
163168

164169
// Show the ListView Loading View and set it to refresh. If it has a 0
165170
// height, then we need to set it to WRAP_CONTENT
166-
if (listViewLoadingLayout.getHeight() == 0) {
167-
ViewGroup.LayoutParams lp = listViewLoadingLayout.getLayoutParams();
171+
if (listViewLoadingView.getHeight() == 0) {
172+
ViewGroup.LayoutParams lp = listViewLoadingView.getLayoutParams();
168173
lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
169-
listViewLoadingLayout.setLayoutParams(lp);
174+
listViewLoadingView.setLayoutParams(lp);
170175
}
171-
listViewLoadingLayout.setVisibility(View.VISIBLE);
172-
listViewLoadingLayout.refreshing();
176+
listViewLoadingView.setVisibility(View.VISIBLE);
177+
178+
listViewLoadingView.refreshing();
173179

174180
if (doScroll) {
175181
// We scroll slightly so that the ListView's header/footer is at the
@@ -253,7 +259,7 @@ protected ListView createRefreshableView(Context context, AttributeSet attrs) {
253259
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PullToRefresh);
254260

255261
// We use a 0 height (instead of View.GONE) for now so that it's still
256-
// layed out
262+
// measured and laid out
257263
final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, 0,
258264
Gravity.CENTER_HORIZONTAL);
259265

0 commit comments

Comments
 (0)