android.widget.ListAdapter#isEmpty ( )源码实例Demo

下面列出了android.widget.ListAdapter#isEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
    protected void onRefreshing(final boolean doScroll) {
        /**
         * If we're not showing the Refreshing view, or the list is empty, the
         * the header/footer views won't show so we use the normal method.
         */
        ListAdapter adapter = mRefreshableView.getAdapter();
        if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
            super.onRefreshing(doScroll);
            return;
        }
//
        super.onRefreshing(false);
//
        final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
        final int selection, scrollToY;

        switch (getCurrentMode()) {
            case MANUAL_REFRESH_ONLY:
            case PULL_FROM_END:
                origLoadingView = getFooterLayout();
                listViewLoadingView = mFooterLoadingView;
                oppositeListViewLoadingView = mHeaderLoadingView;
                selection = mRefreshableView.getCount() - 1;
                scrollToY = getScrollY() - getFooterSize();
//				smoothScrollTo(0);
                smoothScrollTo(getFooterSize());
                break;
            case PULL_FROM_START:
            default:
                origLoadingView = getHeaderLayout();
                listViewLoadingView = mHeaderLoadingView;
                oppositeListViewLoadingView = mFooterLoadingView;
                selection = 0;
                scrollToY = (int) (getScrollY() + getHeaderSize() * LoadingLayout.SCALE_REFRESHING);
                smoothScrollTo((int) (-getHeaderSize() * LoadingLayout.SCALE_REFRESHING));
                break;
        }
        oppositeListViewLoadingView.setVisibility(View.GONE);
    }
 
源代码2 项目: letv   文件: PullToRefreshListView.java
protected void setRefreshingInternal(boolean doScroll) {
    ListAdapter adapter = ((ListView) this.mRefreshableView).getAdapter();
    if (adapter == null || adapter.isEmpty()) {
        super.setRefreshingInternal(doScroll);
        return;
    }
    PullToRefreshHeaderView originalLoadingLayout;
    PullToRefreshHeaderView listViewLoadingLayout;
    int selection;
    int scrollToY;
    super.setRefreshingInternal(false);
    switch (getCurrentMode()) {
        case 2:
            originalLoadingLayout = getFooterLayout();
            listViewLoadingLayout = this.mFooterLoadingView;
            selection = ((ListView) this.mRefreshableView).getCount() - 1;
            scrollToY = getScrollY() - getHeaderHeight();
            break;
        default:
            originalLoadingLayout = getHeaderLayout();
            listViewLoadingLayout = this.mHeaderLoadingView;
            selection = 0;
            scrollToY = getScrollY() + getHeaderHeight();
            break;
    }
    if (doScroll) {
        setHeaderScroll(scrollToY);
    }
    originalLoadingLayout.setVisibility(4);
    listViewLoadingLayout.setVisibility(0);
    listViewLoadingLayout.setParams(this.objs);
    listViewLoadingLayout.refreshing();
    if (doScroll) {
        ((ListView) this.mRefreshableView).setSelection(selection);
        smoothScrollTo(0);
    }
}
 
源代码3 项目: letv   文件: PullToRefreshExpandableListView.java
protected void setRefreshingInternal(boolean doScroll) {
    ListAdapter adapter = ((ExpandableListView) this.mRefreshableView).getAdapter();
    if (adapter == null || adapter.isEmpty()) {
        super.setRefreshingInternal(doScroll);
        return;
    }
    PullToRefreshHeaderView originalLoadingLayout;
    PullToRefreshHeaderView listViewLoadingLayout;
    int selection;
    int scrollToY;
    super.setRefreshingInternal(false);
    switch (getCurrentMode()) {
        case 2:
            originalLoadingLayout = getFooterLayout();
            listViewLoadingLayout = this.mFooterLoadingView;
            selection = ((ExpandableListView) this.mRefreshableView).getCount() - 1;
            scrollToY = getScrollY() - getHeaderHeight();
            break;
        default:
            originalLoadingLayout = getHeaderLayout();
            listViewLoadingLayout = this.mHeaderLoadingView;
            selection = 0;
            scrollToY = getScrollY() + getHeaderHeight();
            break;
    }
    if (doScroll) {
        setHeaderScroll(scrollToY);
    }
    originalLoadingLayout.setVisibility(4);
    listViewLoadingLayout.setParams(this.objs);
    listViewLoadingLayout.setVisibility(0);
    listViewLoadingLayout.refreshing();
    if (doScroll) {
        ((ExpandableListView) this.mRefreshableView).setSelection(selection);
        smoothScrollTo(0);
    }
}
 
源代码4 项目: letv   文件: PullToRefreshExpandableListView.java
protected void resetHeader(boolean immediately) {
    ListAdapter adapter = ((ExpandableListView) this.mRefreshableView).getAdapter();
    if (adapter == null || adapter.isEmpty()) {
        super.resetHeader(immediately);
        return;
    }
    PullToRefreshHeaderView originalLoadingLayout;
    PullToRefreshHeaderView listViewLoadingLayout;
    boolean doScroll;
    int scrollToHeight = getHeaderHeight();
    switch (getCurrentMode()) {
        case 2:
            originalLoadingLayout = getFooterLayout();
            listViewLoadingLayout = this.mFooterLoadingView;
            doScroll = isReadyForPullUp();
            break;
        default:
            originalLoadingLayout = getHeaderLayout();
            listViewLoadingLayout = this.mHeaderLoadingView;
            scrollToHeight *= -1;
            doScroll = isReadyForPullDown();
            break;
    }
    originalLoadingLayout.setVisibility(0);
    if (doScroll) {
        setHeaderScroll(scrollToHeight);
    }
    listViewLoadingLayout.setVisibility(8);
    super.resetHeader(immediately);
}
 
源代码5 项目: Qiitanium   文件: LoadMoreHelper.java
public boolean onNext(int currentItemCount, int totalItemCount) {

    final ListAdapter adapter = listView.getAdapter();
    if (adapter == null || adapter.isEmpty()) {
      return false;
    }

    return ((totalItemCount - currentItemCount) <= leftoverCount);
  }
 
源代码6 项目: Travel-Mate   文件: NestedListView.java
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int newHeight = 0;
    final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);
    if (heightMode != MeasureSpec.EXACTLY) {
        ListAdapter listAdapter = getAdapter();
        if (listAdapter != null && !listAdapter.isEmpty()) {
            int listPosition;
            for (listPosition = 0; listPosition < listAdapter.getCount()
                    && listPosition < MAXIMUM_LIST_ITEMS_VIEWABLE; listPosition++) {
                View listItem = listAdapter.getView(listPosition, null, this);
                //now it will not throw a NPE if listItem is a ViewGroup instance
                if (listItem instanceof ViewGroup) {
                    listItem.setLayoutParams(
                            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                                    ViewGroup.LayoutParams.WRAP_CONTENT));
                }
                listItem.measure(widthMeasureSpec, heightMeasureSpec);
                newHeight += listItem.getMeasuredHeight();
            }
            newHeight += getDividerHeight() * listPosition;
        }
        if ((heightMode == MeasureSpec.AT_MOST) && (newHeight > heightSize)) {
            newHeight = heightSize;
        }
    } else {
        newHeight = getMeasuredHeight();
    }
    setMeasuredDimension(getMeasuredWidth(), newHeight);
}
 
public boolean isEmpty() {
    ListView listView = getRefreshableView();
    if (listView == null) {
        return true;
    }
    ListAdapter adapter = listView.getAdapter();
    if (adapter == null) {
        return true;
    }
    return adapter.isEmpty();
}
 
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(View.GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(View.VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}
 
源代码9 项目: zen4android   文件: PullToRefreshListView.java
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(View.GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(View.VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}
 
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(View.GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(View.VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}
 
源代码11 项目: SweetMusicPlayer   文件: PullToRefreshListView.java
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(View.GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(View.VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}
 
@Override
protected void onRefreshing(final boolean doScroll) {
    SwipeMenuListView listView = getRefreshableView();
    listView.smoothCloseMenu();
    /**
     * If we're not showing the Refreshing view, or the list is empty, the
     * the header/footer views won't show so we use the normal method.
     */
    ListAdapter adapter = mRefreshableView.getAdapter();
    if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
        super.onRefreshing(doScroll);
        return;
    }

    super.onRefreshing(false);

    final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
    final int selection, scrollToY;

    switch (getCurrentMode()) {
        case MANUAL_REFRESH_ONLY:
        case PULL_FROM_END:
            origLoadingView = getFooterLayout();
            listViewLoadingView = mFooterLoadingView;
            oppositeListViewLoadingView = mHeaderLoadingView;
            selection = mRefreshableView.getCount() - 1;
            scrollToY = getScrollY() - getFooterSize();
            break;
        case PULL_FROM_START:
        default:
            origLoadingView = getHeaderLayout();
            listViewLoadingView = mHeaderLoadingView;
            oppositeListViewLoadingView = mFooterLoadingView;
            selection = 0;
            scrollToY = getScrollY() + getHeaderSize();
            break;
    }

    // Hide our original Loading View
    origLoadingView.reset();
    origLoadingView.hideAllViews();

    // Make sure the opposite end is hidden too
    oppositeListViewLoadingView.setVisibility(View.GONE);

    // Show the ListView Loading View and set it to refresh.
    listViewLoadingView.setVisibility(View.VISIBLE);
    listViewLoadingView.refreshing();

    if (doScroll) {
        // We need to disable the automatic visibility changes for now
        disableLoadingLayoutVisibilityChanges();

        // We scroll slightly so that the ListView's header/footer is at the
        // same Y position as our normal header/footer
        setHeaderScroll(scrollToY);

        // Make sure the ListView is scrolled to show the loading
        // header/footer
        mRefreshableView.setSelection(selection);

        // Smooth scroll as normal
        smoothScrollTo(0);
    }
}
 
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(View.GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(View.VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}
 
源代码14 项目: ONE-Unofficial   文件: PullToRefreshListView.java
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(View.GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(View.VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}
 
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(View.GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(View.VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}
 
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(View.GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(View.VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}
 
@Override
protected void onRefreshing(final boolean doScroll)
{
    /**
     * If we're not showing the Refreshing view, or the list is empty, the
     * the header/footer views won't show so we use the normal method.
     */
    ListAdapter adapter = mRefreshableView.getAdapter();
    if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing()
            || null == adapter || adapter.isEmpty())
    {
        super.onRefreshing(doScroll);
        return;
    }

    super.onRefreshing(false);

    final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
    final int selection, scrollToY;

    switch (getCurrentMode())
    {
        case MANUAL_REFRESH_ONLY:
        case PULL_FROM_END:
            origLoadingView = getFooterLayout();
            listViewLoadingView = mFooterLoadingView;
            oppositeListViewLoadingView = mHeaderLoadingView;
            selection = mRefreshableView.getCount() - 1;
            scrollToY = getScrollY() - getFooterSize();
            break;
        case PULL_FROM_START:
        default:
            origLoadingView = getHeaderLayout();
            listViewLoadingView = mHeaderLoadingView;
            oppositeListViewLoadingView = mFooterLoadingView;
            selection = 0;
            scrollToY = getScrollY() + getHeaderSize();
            break;
    }

    // Hide our original Loading View
    origLoadingView.reset();
    origLoadingView.hideAllViews();

    // Make sure the opposite end is hidden too
    oppositeListViewLoadingView.setVisibility(GONE);

    // Show the ListView Loading View and set it to refresh.
    listViewLoadingView.setVisibility(VISIBLE);
    listViewLoadingView.refreshing();

    if (doScroll)
    {
        // We need to disable the automatic visibility changes for now
        disableLoadingLayoutVisibilityChanges();

        // We scroll slightly so that the ListView's header/footer is at the
        // same Y position as our normal header/footer
        setHeaderScroll(scrollToY);

        // Make sure the ListView is scrolled to show the loading
        // header/footer
        mRefreshableView.setSelection(selection);

        // Smooth scroll as normal
        smoothScrollTo(0);
    }
}
 
源代码18 项目: AndroidBase   文件: PullToRefreshListView.java
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}
 
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(View.GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(View.VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}
 
源代码20 项目: iSCAU-Android   文件: PullToRefreshListView.java
@Override
protected void onRefreshing(final boolean doScroll) {
	/**
	 * If we're not showing the Refreshing view, or the list is empty, the
	 * the header/footer views won't show so we use the normal method.
	 */
	ListAdapter adapter = mRefreshableView.getAdapter();
	if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
		super.onRefreshing(doScroll);
		return;
	}

	super.onRefreshing(false);

	final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
	final int selection, scrollToY;

	switch (getCurrentMode()) {
		case MANUAL_REFRESH_ONLY:
		case PULL_FROM_END:
			origLoadingView = getFooterLayout();
			listViewLoadingView = mFooterLoadingView;
			oppositeListViewLoadingView = mHeaderLoadingView;
			selection = mRefreshableView.getCount() - 1;
			scrollToY = getScrollY() - getFooterSize();
			break;
		case PULL_FROM_START:
		default:
			origLoadingView = getHeaderLayout();
			listViewLoadingView = mHeaderLoadingView;
			oppositeListViewLoadingView = mFooterLoadingView;
			selection = 0;
			scrollToY = getScrollY() + getHeaderSize();
			break;
	}

	// Hide our original Loading View
	origLoadingView.reset();
	origLoadingView.hideAllViews();

	// Make sure the opposite end is hidden too
	oppositeListViewLoadingView.setVisibility(View.GONE);

	// Show the ListView Loading View and set it to refresh.
	listViewLoadingView.setVisibility(View.VISIBLE);
	listViewLoadingView.refreshing();

	if (doScroll) {
		// We need to disable the automatic visibility changes for now
		disableLoadingLayoutVisibilityChanges();

		// We scroll slightly so that the ListView's header/footer is at the
		// same Y position as our normal header/footer
		setHeaderScroll(scrollToY);

		// Make sure the ListView is scrolled to show the loading
		// header/footer
		mRefreshableView.setSelection(selection);

		// Smooth scroll as normal
		smoothScrollTo(0);
	}
}