Skip to content

Commit

Permalink
Avoid flickers when the view size changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cameoh committed Dec 31, 2016
1 parent 3bd8ef6 commit 72ea022
Showing 1 changed file with 6 additions and 15 deletions.
Expand Up @@ -840,30 +840,23 @@ protected final Parcelable onSaveInstanceState() {
return bundle;
}

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
mRefreshableViewWrapper.layout(0, 0, r - l, b - t);
}

@Override
protected final void onSizeChanged(int w, int h, int oldw, int oldh) {
if (DEBUG) {
Log.d(LOG_TAG, String.format("onSizeChanged. W: %d, H: %d", w, h));
}

super.onSizeChanged(w, h, oldw, oldh);

// We need to update the header/footer when our size changes
refreshLoadingViewsSize();

// Update the Refreshable View layout
refreshRefreshableViewSize(w, h);

/**
* As we're currently in a Layout Pass, we need to schedule another one
* to layout any changes we've made here
*/
post(new Runnable() {
@Override
public void run() {
requestLayout();
}
});
}

/**
Expand Down Expand Up @@ -927,13 +920,11 @@ protected final void refreshRefreshableViewSize(int width, int height) {
case HORIZONTAL:
if (lp.width != width) {
lp.width = width;
mRefreshableViewWrapper.requestLayout();
}
break;
case VERTICAL:
if (lp.height != height) {
lp.height = height;
mRefreshableViewWrapper.requestLayout();
}
break;
}
Expand Down

0 comments on commit 72ea022

Please sign in to comment.