Search in sources :

Example 1 with LoadingLayout

use of com.rongseal.widget.pulltorefresh.internal.LoadingLayout in project SeaStar by 13120241790.

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.rongseal.widget.pulltorefresh.internal.LoadingLayout)

Example 2 with LoadingLayout

use of com.rongseal.widget.pulltorefresh.internal.LoadingLayout in project SeaStar by 13120241790.

the class PullToRefreshListView method onReset.

@Override
protected void onReset() {
    /**
		 * If the extras are not enabled, just call up to super and return.
		 */
    if (!mListViewExtrasEnabled) {
        super.onReset();
        return;
    }
    final LoadingLayout originalLoadingLayout, listViewLoadingLayout;
    final int scrollToHeight, selection;
    final boolean scrollLvToEdge;
    switch(getCurrentMode()) {
        case MANUAL_REFRESH_ONLY:
        case PULL_FROM_END:
            originalLoadingLayout = getFooterLayout();
            listViewLoadingLayout = mFooterLoadingView;
            selection = mRefreshableView.getCount() - 1;
            scrollToHeight = getFooterSize();
            scrollLvToEdge = Math.abs(mRefreshableView.getLastVisiblePosition() - selection) <= 1;
            break;
        case PULL_FROM_START:
        default:
            originalLoadingLayout = getHeaderLayout();
            listViewLoadingLayout = mHeaderLoadingView;
            scrollToHeight = -getHeaderSize();
            selection = 0;
            scrollLvToEdge = Math.abs(mRefreshableView.getFirstVisiblePosition() - selection) <= 1;
            break;
    }
    // flip so that the original one is showing instead
    if (listViewLoadingLayout.getVisibility() == View.VISIBLE) {
        // Set our Original View to Visible
        originalLoadingLayout.showInvisibleViews();
        // Hide the ListView Header/Footer
        listViewLoadingLayout.setVisibility(View.GONE);
        /**
			 * Scroll so the View is at the same Y as the ListView
			 * header/footer, but only scroll if: we've pulled to refresh, it's
			 * positioned correctly
			 */
        if (scrollLvToEdge && getState() != State.MANUAL_REFRESHING) {
            mRefreshableView.setSelection(selection);
            setHeaderScroll(scrollToHeight);
        }
    }
    // Finally, call up to super
    super.onReset();
}
Also used : LoadingLayout(com.rongseal.widget.pulltorefresh.internal.LoadingLayout)

Example 3 with LoadingLayout

use of com.rongseal.widget.pulltorefresh.internal.LoadingLayout in project SeaStar by 13120241790.

the class PullToRefreshBase method createLoadingLayout.

protected LoadingLayout createLoadingLayout(Context context, Mode mode, TypedArray attrs) {
    LoadingLayout layout = mLoadingAnimationStyle.createLoadingLayout(context, mode, getPullToRefreshScrollDirection(), attrs);
    layout.setVisibility(View.INVISIBLE);
    return layout;
}
Also used : LoadingLayout(com.rongseal.widget.pulltorefresh.internal.LoadingLayout) FlipLoadingLayout(com.rongseal.widget.pulltorefresh.internal.FlipLoadingLayout) RotateLoadingLayout(com.rongseal.widget.pulltorefresh.internal.RotateLoadingLayout)

Aggregations

LoadingLayout (com.rongseal.widget.pulltorefresh.internal.LoadingLayout)3 ListAdapter (android.widget.ListAdapter)1 FlipLoadingLayout (com.rongseal.widget.pulltorefresh.internal.FlipLoadingLayout)1 RotateLoadingLayout (com.rongseal.widget.pulltorefresh.internal.RotateLoadingLayout)1