Search in sources :

Example 1 with LoadingLayout

use of com.handmark.pulltorefresh.library.internal.LoadingLayout in project PullToRefresh-PinnedSection-ListView by tongcpp.

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.handmark.pulltorefresh.library.internal.LoadingLayout) RotateLoadingLayout(com.handmark.pulltorefresh.library.internal.RotateLoadingLayout) FlipLoadingLayout(com.handmark.pulltorefresh.library.internal.FlipLoadingLayout)

Example 2 with LoadingLayout

use of com.handmark.pulltorefresh.library.internal.LoadingLayout in project PullToRefresh-PinnedSection-ListView by tongcpp.

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)

Example 3 with LoadingLayout

use of com.handmark.pulltorefresh.library.internal.LoadingLayout in project PullToRefresh-PinnedSection-ListView by tongcpp.

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.handmark.pulltorefresh.library.internal.LoadingLayout)

Example 4 with LoadingLayout

use of com.handmark.pulltorefresh.library.internal.LoadingLayout in project PullToRefreshLibrary by harichen.

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)

Example 5 with LoadingLayout

use of com.handmark.pulltorefresh.library.internal.LoadingLayout in project Android-PullToRefresh by chrisbanes.

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.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