Skip to content

Commit

Permalink
Fix #186
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Banes committed Dec 29, 2012
1 parent c25adb0 commit 8b1aef2
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListAdapter;

import com.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor;
Expand All @@ -38,6 +39,22 @@
public abstract class PullToRefreshAdapterViewBase<T extends AbsListView> extends PullToRefreshBase<T> implements
OnScrollListener {

private static FrameLayout.LayoutParams convertEmptyViewLayoutParams(ViewGroup.LayoutParams lp) {
FrameLayout.LayoutParams newLp = null;

if (null != lp) {
newLp = new FrameLayout.LayoutParams(lp);

if (lp instanceof LinearLayout.LayoutParams) {
newLp.gravity = ((LinearLayout.LayoutParams) lp).gravity;
} else {
newLp.gravity = Gravity.CENTER;
}
}

return newLp;
}

private int mSavedLastVisibleIndex = -1;
private OnScrollListener mOnScrollListener;
private OnLastItemVisibleListener mOnLastItemVisibleListener;
Expand Down Expand Up @@ -172,7 +189,9 @@ public final void setEmptyView(View newEmptyView) {
((ViewGroup) newEmptyViewParent).removeView(newEmptyView);
}

refreshableViewWrapper.addView(newEmptyView);
// We need to convert any LayoutParams so that it works in our
// FrameLayout
refreshableViewWrapper.addView(newEmptyView, convertEmptyViewLayoutParams(newEmptyView.getLayoutParams()));
}

if (mRefreshableView instanceof EmptyViewMethodAccessor) {
Expand Down

0 comments on commit 8b1aef2

Please sign in to comment.