From 88d9f07f0b93667d51e41e977ef0cad438173c59 Mon Sep 17 00:00:00 2001 From: Comtu Date: Mon, 31 Aug 2015 15:51:17 +0800 Subject: [PATCH] Bug Fixes --- .../srain/cube/views/ptr/PtrFrameLayout.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java b/ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java index 882a0aa..25b752a 100755 --- a/ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java +++ b/ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java @@ -406,8 +406,10 @@ private void updatePos(int change) { PtrCLog.v(LOG_TAG, "updatePos: change: %s, current: %s last: %s, top: %s, headerHeight: %s", change, mPtrIndicator.getCurrentPosY(), mPtrIndicator.getLastPosY(), mContent.getTop(), mHeaderHeight); } + + if(mHeaderView!=null) + mHeaderView.offsetTopAndBottom(change); - mHeaderView.offsetTopAndBottom(change); if (!isPinContent()) { mContent.offsetTopAndBottom(change); } @@ -868,9 +870,19 @@ public View getHeaderView() { } public void setHeaderView(View header) { - if (mHeaderView != null && header != null && mHeaderView != header) { - removeView(mHeaderView); + if (header == null) { + if (mHeaderView != null) + removeView(mHeaderView); + mHeaderView = header; + return; } + + if (mHeaderView == header) + return; + + if (mHeaderView != null) + removeView(mHeaderView); + ViewGroup.LayoutParams lp = header.getLayoutParams(); if (lp == null) { lp = new LayoutParams(-1, -2);