Search in sources :

Example 16 with LoadingLayout

use of com.handmark.pulltorefresh.library.internal.LoadingLayout in project RecyclerViewAnimator by dkmeteor.

the class PullToRefreshListView method onRefreshing.

@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);
    }
}
Also used : ListAdapter(android.widget.ListAdapter) LoadingLayout(com.handmark.pulltorefresh.library.internal.LoadingLayout)

Aggregations

LoadingLayout (com.handmark.pulltorefresh.library.internal.LoadingLayout)16 ListAdapter (android.widget.ListAdapter)6 FlipLoadingLayout (com.handmark.pulltorefresh.library.internal.FlipLoadingLayout)4 RotateLoadingLayout (com.handmark.pulltorefresh.library.internal.RotateLoadingLayout)4