Skip to content

Commit 3429998

Browse files
author
Chris Banes
committed
Finally, got an optimised layout routine
1 parent df078d7 commit 3429998

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,11 @@ protected final Parcelable onSaveInstanceState() {
843843
}
844844

845845
@Override
846-
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
846+
protected final void onSizeChanged(int w, int h, int oldw, int oldh) {
847847
super.onSizeChanged(w, h, oldw, oldh);
848+
848849
// We need to update the header/footer when our size changes
849-
// refreshLoadingViewsSize();
850+
refreshLoadingViewsSize();
850851

851852
// Update the Refreshable View layout
852853
refreshRefreshableViewSize(w, h);
@@ -868,36 +869,36 @@ protected final void refreshLoadingViewsSize() {
868869

869870
switch (getPullToRefreshScrollDirection()) {
870871
case HORIZONTAL:
871-
if (mMode.showHeaderLoadingLayout() && mHeaderLayout.getWidth() > 0) {
872+
if (mMode.showHeaderLoadingLayout()) {
872873
mHeaderDimension = mHeaderLayout.getContentWidth();
873874
mHeaderLayout.setWidth(maximumPullScroll);
874-
pLeft = -mHeaderLayout.getWidth();
875+
pLeft = -maximumPullScroll;
875876
} else {
876877
pLeft = 0;
877878
}
878879

879-
if (mMode.showFooterLoadingLayout() && mFooterLayout.getWidth() > 0) {
880+
if (mMode.showFooterLoadingLayout()) {
880881
mFooterDimension = mFooterLayout.getContentWidth();
881882
mFooterLayout.setWidth(maximumPullScroll);
882-
pRight = -mFooterLayout.getWidth();
883+
pRight = -maximumPullScroll;
883884
} else {
884885
pRight = 0;
885886
}
886887
break;
887888

888889
case VERTICAL:
889-
if (mMode.showHeaderLoadingLayout() && mHeaderLayout.getHeight() > 0) {
890+
if (mMode.showHeaderLoadingLayout()) {
890891
mHeaderDimension = mHeaderLayout.getContentHeight();
891892
mHeaderLayout.setHeight(maximumPullScroll);
892-
pTop = -mHeaderLayout.getHeight();
893+
pTop = -maximumPullScroll;
893894
} else {
894895
pTop = 0;
895896
}
896897

897-
if (mMode.showFooterLoadingLayout() && mFooterLayout.getHeight() > 0) {
898+
if (mMode.showFooterLoadingLayout()) {
898899
mFooterDimension = mFooterLayout.getContentHeight();
899900
mFooterLayout.setHeight(maximumPullScroll);
900-
pBottom = -mFooterLayout.getHeight();
901+
pBottom = -maximumPullScroll;
901902
} else {
902903
pBottom = 0;
903904
}
@@ -962,7 +963,7 @@ protected final void setHeaderScroll(final int value) {
962963
* all. We don't use them on the Header/Footer Views as they change
963964
* often, which would negate any HW layer performance boost.
964965
*/
965-
//ViewCompat.setLayerType(mRefreshableViewWrapper, value != 0 ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE);
966+
ViewCompat.setLayerType(mRefreshableViewWrapper, value != 0 ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE);
966967

967968
switch (getPullToRefreshScrollDirection()) {
968969
case VERTICAL:
@@ -1074,9 +1075,10 @@ private void init(Context context, AttributeSet attrs) {
10741075
mHeaderLayout = createLoadingLayout(context, Mode.PULL_FROM_START, a);
10751076
mFooterLayout = createLoadingLayout(context, Mode.PULL_FROM_END, a);
10761077

1077-
LoadingLayout.OnSizeChangedListener listener = new OnLoadingLayoutSizeChangedListener();
1078-
mHeaderLayout.setOnSizeChangedListener(listener);
1079-
mFooterLayout.setOnSizeChangedListener(listener);
1078+
// LoadingLayout.OnSizeChangedListener listener = new
1079+
// OnLoadingLayoutSizeChangedListener();
1080+
// mHeaderLayout.setOnSizeChangedListener(listener);
1081+
// mFooterLayout.setOnSizeChangedListener(listener);
10801082

10811083
/**
10821084
* Styleables from XML

0 commit comments

Comments
 (0)