Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.lang.reflect.Method;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -56,6 +57,7 @@ public class PullToRefreshListView extends ListView implements OnScrollListener
private int mRefreshViewHeight;
private int mRefreshOriginalTopPadding;
private int mLastMotionY;
private int mHeight = -1;

private boolean mBounceHack;

Expand Down Expand Up @@ -116,6 +118,22 @@ private void init(Context context) {
measureView(mRefreshView);
mRefreshViewHeight = mRefreshView.getMeasuredHeight();
}

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mHeight == -1) { // do it only once
mHeight = getHeight(); // getHeight only returns useful data after first onDraw()
int scrollRange = this.computeVerticalScrollRange();
if (scrollRange < mHeight) {
TextView footerView = new TextView(this.getContext());
footerView.setText(" ");
footerView.setHeight(mHeight - scrollRange + mRefreshViewHeight + 1);
addFooterView(footerView);
}
}

}

@Override
protected void onAttachedToWindow() {
Expand Down