Java Code Examples for android.widget.AbsListView.OnScrollListener

The following are top voted examples for showing how to use android.widget.AbsListView.OnScrollListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	switch (scrollState) {
		case OnScrollListener.SCROLL_STATE_IDLE:
			imageLoader.resume();
			break;
		case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
			if (pauseOnScroll) {
				imageLoader.pause();
			}
			break;
		case OnScrollListener.SCROLL_STATE_FLING:
			if (pauseOnFling) {
				imageLoader.pause();
			}
			break;
	}
	if (externalListener != null) {
		externalListener.onScrollStateChanged(view, scrollState);
	}
}
 
Example 2
Project: Hotspot-master-devp   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case OnScrollListener.SCROLL_STATE_IDLE:
            bitmapUtils.resumeTasks();
            LogUtils.i("当前ListView停止滚动,加载图片开始......................");
            break;
        case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
            if (pauseOnScroll) {
                bitmapUtils.pauseTasks();
                LogUtils.i("当前ListView被触摸滚动,暂停加载......................");
            }
            break;
        case OnScrollListener.SCROLL_STATE_FLING:
            if (pauseOnFling) {
                bitmapUtils.pauseTasks();
                LogUtils.i("当前ListView被手势离开滚动,暂停加载......................");
            }
            break;
    }
    if (externalListener != null) {
        externalListener.onScrollStateChanged(view, scrollState);
    }
}
 
Example 3
Project: Hotspot-master-devp   File: PullToRefreshAdapterViewBase.java   View source code 6 votes vote down vote up
public final void onScrollStateChanged(final AbsListView view, final int state) {
	/**
	 * Check that the scrolling has stopped, and that the last item is
	 * visible.
	 */
	if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) {
		if (isLoadAvailable()) {
			setLoadAvailable(false);
			mOnLastItemVisibleListener.onLastItemVisible();
		}
	}

	if (null != mOnScrollListener) {
		mOnScrollListener.onScrollStateChanged(view, state);
	}
}
 
Example 4
Project: GifImageLoader   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	switch (scrollState) {
		case OnScrollListener.SCROLL_STATE_IDLE:
			imageLoader.resume();
			break;
		case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
			if (pauseOnScroll) {
				imageLoader.pause();
			}
			break;
		case OnScrollListener.SCROLL_STATE_FLING:
			if (pauseOnFling) {
				imageLoader.pause();
			}
			break;
	}
	if (externalListener != null) {
		externalListener.onScrollStateChanged(view, scrollState);
	}
}
 
Example 5
Project: LoadMoreHelper   File: MultiScrollListener.java   View source code 6 votes vote down vote up
public static void addScrollListener(ListView listview, OnScrollListener listener){
    if (listview == null || listener == null)  {
        return;
    }
    OnScrollListener originListener = getScrollListenerFromListView(listview);
    if (originListener instanceof MultiScrollListener) {
        (((MultiScrollListener)originListener)).addListener(listener);
    } else {
        MultiScrollListener multiScrollListener = new MultiScrollListener();
        if (originListener != null) {
            multiScrollListener.addListener(originListener);
        }
        multiScrollListener.addListener(listener);
        listview.setOnScrollListener(multiScrollListener);
    }
}
 
Example 6
Project: LoadMoreHelper   File: MultiScrollListener.java   View source code 6 votes vote down vote up
public static void removeScrollListener(ListView listview, OnScrollListener listener) {
    if (listview == null || listener == null) {
        return;
    }
    OnScrollListener originListener = getScrollListenerFromListView(listview);
    if (originListener == listener) {
        listview.setOnScrollListener(null);
    } else {
        if (originListener instanceof MultiScrollListener) {
            MultiScrollListener multiScrollListener = (MultiScrollListener)originListener;
            multiScrollListener.removeListener(listener);
            if (multiScrollListener.isEmpty()) {
                listview.setOnScrollListener(null);
            }
        }
    }
}
 
Example 7
Project: android-project-gallery   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	switch (scrollState) {
		case OnScrollListener.SCROLL_STATE_IDLE:
			imageLoader.resume();
			break;
		case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
			if (pauseOnScroll) {
				imageLoader.pause();
			}
			break;
		case OnScrollListener.SCROLL_STATE_FLING:
			if (pauseOnFling) {
				imageLoader.pause();
			}
			break;
	}
	if (externalListener != null) {
		externalListener.onScrollStateChanged(view, scrollState);
	}
}
 
Example 8
Project: aarLibrary   File: XRefreshContentView.java   View source code 6 votes vote down vote up
private void setScrollViewScrollListener() {
    if (child instanceof XScrollView) {
        XScrollView scrollView = (XScrollView) child;
        scrollView.setOnScrollListener(mParent, new XScrollView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(ScrollView view, int scrollState, boolean arriveBottom) {
                if (scrollState == SCROLL_STATE_IDLE && arriveBottom) {
                    if (mSilenceLoadMore) {
                        if (mRefreshViewListener != null) {
                            mRefreshViewListener.onLoadMore(true);
                        }
                    } else if (mContainer != null && !hasLoadCompleted()) {
                        mContainer.invokeLoadMore();
                    }
                }
            }

            @Override
            public void onScroll(int l, int t, int oldl, int oldt) {

            }
        });
    } else {
        throw new RuntimeException("please use XScrollView instead of ScrollView!");
    }
}
 
Example 9
Project: sctalk   File: ImageGridActivity.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case OnScrollListener.SCROLL_STATE_FLING:
            adapter.lock();
            break;
        case OnScrollListener.SCROLL_STATE_IDLE:
            adapter.unlock();
            break;
        case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
            adapter.lock();
            break;
        default:
            break;
    }
}
 
Example 10
Project: ImageLoaderSupportGif   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	switch (scrollState) {
		case OnScrollListener.SCROLL_STATE_IDLE:
			imageLoader.resume();
			break;
		case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
			if (pauseOnScroll) {
				imageLoader.pause();
			}
			break;
		case OnScrollListener.SCROLL_STATE_FLING:
			if (pauseOnFling) {
				imageLoader.pause();
			}
			break;
	}
	if (externalListener != null) {
		externalListener.onScrollStateChanged(view, scrollState);
	}
}
 
Example 11
Project: magic_imageloader_network   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case OnScrollListener.SCROLL_STATE_IDLE:
            magic.magicEngine.resume();
            break;
        case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
            if (pauseOnScroll) {
                magic.magicEngine.pause();
            }
            break;
        case OnScrollListener.SCROLL_STATE_FLING:
            if (pauseOnFling) {
                magic.magicEngine.pause();
            }
            break;
    }
    if (externalListener != null) {
        externalListener.onScrollStateChanged(view, scrollState);
    }
}
 
Example 12
Project: magic_imageloader_network   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case OnScrollListener.SCROLL_STATE_IDLE:
            magic.magicEngine.resume();
            break;
        case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
            if (pauseOnScroll) {
                magic.magicEngine.pause();
            }
            break;
        case OnScrollListener.SCROLL_STATE_FLING:
            if (pauseOnFling) {
                magic.magicEngine.pause();
            }
            break;
    }
    if (externalListener != null) {
        externalListener.onScrollStateChanged(view, scrollState);
    }
}
 
Example 13
Project: Android-Application-ZJB   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	switch (scrollState) {
		case OnScrollListener.SCROLL_STATE_IDLE:
			imageLoader.resume();
			break;
		case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
			if (pauseOnScroll) {
				imageLoader.pause();
			}
			break;
		case OnScrollListener.SCROLL_STATE_FLING:
			if (pauseOnFling) {
				imageLoader.pause();
			}
			break;
	}
	if (externalListener != null) {
		externalListener.onScrollStateChanged(view, scrollState);
	}
}
 
Example 14
Project: XListView   File: PullToRefreshListView.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	if (isScrollLoadEnabled() && hasMoreData()) {
		if (scrollState == OnScrollListener.SCROLL_STATE_IDLE
				|| scrollState == OnScrollListener.SCROLL_STATE_FLING) {
			if (isReadyForPullUp()) {
				startLoading();
			}
		}
	}

	if (mListView instanceof SlideListView)
		((SlideListView) mListView).onScrollStateChanged(view, scrollState);

	if (null != mScrollListener) {
		mScrollListener.onScrollStateChanged(view, scrollState);
	}
}
 
Example 15
Project: AyoSunny   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	switch (scrollState) {
		case OnScrollListener.SCROLL_STATE_IDLE:
			imageLoader.resume();
			break;
		case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
			if (pauseOnScroll) {
				imageLoader.pause();
			}
			break;
		case OnScrollListener.SCROLL_STATE_FLING:
			if (pauseOnFling) {
				imageLoader.pause();
			}
			break;
	}
	if (externalListener != null) {
		externalListener.onScrollStateChanged(view, scrollState);
	}
}
 
Example 16
Project: BigApp_Discuz_Android   File: ReboundListView1.java   View source code 6 votes vote down vote up
private String getScrollStateString(int flag) {
	String str = "";
	switch (flag) {
	case OnScrollListener.SCROLL_STATE_IDLE:
		str = "SCROLL_STATE_IDLE";
		break;
	case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
		str = "SCROLL_STATE_TOUCH_SCROLL";
		break;
	case OnScrollListener.SCROLL_STATE_FLING:
		str = "SCROLL_STATE_FLING";
		break;
	default:
		str = "wrong state";
	}

	return str;
}
 
Example 17
Project: BigApp_Discuz_Android   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case OnScrollListener.SCROLL_STATE_IDLE:
            taskHandler.resume();
            break;
        case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
            if (pauseOnScroll) {
                taskHandler.pause();
            }
            break;
        case OnScrollListener.SCROLL_STATE_FLING:
            if (pauseOnFling) {
                taskHandler.pause();
            }
            break;
    }
    if (externalListener != null) {
        externalListener.onScrollStateChanged(view, scrollState);
    }
}
 
Example 18
Project: android-open-project-demo-master   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case OnScrollListener.SCROLL_STATE_IDLE:
            taskHandler.resume();
            break;
        case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
            if (pauseOnScroll) {
                taskHandler.pause();
            }
            break;
        case OnScrollListener.SCROLL_STATE_FLING:
            if (pauseOnFling) {
                taskHandler.pause();
            }
            break;
    }
    if (externalListener != null) {
        externalListener.onScrollStateChanged(view, scrollState);
    }
}
 
Example 19
Project: lr_dialer   File: Common.java   View source code 6 votes vote down vote up
private void checkScrolledBottom(AbsListView view, int scrollState)
{
	int cc = view.getCount();
	int last = view.getLastVisiblePosition();
	if (scrollState == OnScrollListener.SCROLL_STATE_IDLE && cc == last + 1)
	{
		if (last != lastBottom)
		{
			lastBottom = last;
			invoke(view, scrollState);
		}
	}
	else
	{
		lastBottom = -1;
	}
}
 
Example 20
Project: BigApp_WordPress_Android   File: PauseOnScrollListener.java   View source code 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	switch (scrollState) {
		case OnScrollListener.SCROLL_STATE_IDLE:
			imageLoader.resume();
			break;
		case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
			if (pauseOnScroll) {
				imageLoader.pause();
			}
			break;
		case OnScrollListener.SCROLL_STATE_FLING:
			if (pauseOnFling) {
				imageLoader.pause();
			}
			break;
	}
	if (externalListener != null) {
		externalListener.onScrollStateChanged(view, scrollState);
	}
}
 
Example 21
Project: BigApp_WordPress_Android   File: PullToRefreshAdapterViewBase.java   View source code 6 votes vote down vote up
public final void onScrollStateChanged(final AbsListView view, final int state)
{
    /**
     * Check that the scrolling has stopped, and that the last item is
     * visible.
     */
    if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible)
    {
        mOnLastItemVisibleListener.onLastItemVisible();
    }

    if (null != mOnScrollListener)
    {
        mOnScrollListener.onScrollStateChanged(view, state);
    }
}
 
Example 22
Project: msb-android   File: PullToRefreshAdapterViewBase.java   View source code 6 votes vote down vote up
public final void onScrollStateChanged(final AbsListView view, final int state) {
	/**
	 * Check that the scrolling has stopped, and that the last item is
	 * visible.
	 */
	if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) {
		mOnLastItemVisibleListener.onLastItemVisible();
	}
	
	if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLoadMoreListener) {
		int lastPosition = getRefreshableView().getLastVisiblePosition();
		int total = getRefreshableView().getCount() - 1;
		if (total - lastPosition < mLoadMoreRemainCount) {
			mOnLoadMoreListener.onLoadMore();
		}
	}

	if (null != mOnScrollListener) {
		mOnScrollListener.onScrollStateChanged(view, state);
	}
}
 
Example 23
Project: GitHub   File: XListView.java   View source code 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (mScrollListener != null) {
        mScrollListener.onScrollStateChanged(view, scrollState);
    }

    if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
        if (mEnableAutoLoad && getLastVisiblePosition() == getCount() - 1) {
            startLoadMore();
        }
    }
}
 
Example 24
Project: ultrasonic   File: PullToRefreshAdapterViewBase.java   View source code 5 votes vote down vote up
public final void onScrollStateChanged(final AbsListView view, final int state) {
	/**
	 * Check that the scrolling has stopped, and that the last item is
	 * visible.
	 */
	if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) {
		mOnLastItemVisibleListener.onLastItemVisible();
	}

	if (null != mOnScrollListener) {
		mOnScrollListener.onScrollStateChanged(view, state);
	}
}
 
Example 25
Project: CustomListView   File: PullToRefreshAdapterViewBase.java   View source code 5 votes vote down vote up
public final void onScrollStateChanged(final AbsListView view, final int state) {
	/**
	 * Check that the scrolling has stopped, and that the last item is
	 * visible.
	 */
	if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) {
		mOnLastItemVisibleListener.onLastItemVisible();
	}

	if (null != mOnScrollListener) {
		mOnScrollListener.onScrollStateChanged(view, state);
	}
}
 
Example 26
Project: ywApplication   File: PullToRefreshAdapterViewBase.java   View source code 5 votes vote down vote up
public final void onScrollStateChanged(final AbsListView view, final int state) {
	/**
	 * Check that the scrolling has stopped, and that the last item is
	 * visible.
	 */
	if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) {
		mOnLastItemVisibleListener.onLastItemVisible();
	}

	if (null != mOnScrollListener) {
		mOnScrollListener.onScrollStateChanged(view, state);
	}
}
 
Example 27
Project: AssistantBySDK   File: DayPickerView.java   View source code 5 votes vote down vote up
public void postSetSelection(final int position) {
    clearFocus();
    post(new Runnable() {

        @Override
        public void run() {
            setSelection(position);
        }
    });
    onScrollStateChanged(this, OnScrollListener.SCROLL_STATE_IDLE);
}
 
Example 28
Project: AssistantBySDK   File: DayPickerView.java   View source code 5 votes vote down vote up
@Override
public void run() {
    mCurrentScrollState = mNewState;
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG,
                "new scroll state: " + mNewState + " old state: " + mPreviousScrollState);
    }
    // Fix the position after a scroll or a fling ends
    if (mNewState == OnScrollListener.SCROLL_STATE_IDLE
            && mPreviousScrollState != OnScrollListener.SCROLL_STATE_IDLE
            && mPreviousScrollState != OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
        mPreviousScrollState = mNewState;
        int i = 0;
        View child = getChildAt(i);
        while (child != null && child.getBottom() <= 0) {
            child = getChildAt(++i);
        }
        if (child == null) {
            // The view is no longer visible, just return
            return;
        }
        int firstPosition = getFirstVisiblePosition();
        int lastPosition = getLastVisiblePosition();
        boolean scroll = firstPosition != 0 && lastPosition != getCount() - 1;
        final int top = child.getTop();
        final int bottom = child.getBottom();
        final int midpoint = getHeight() / 2;
        if (scroll && top < LIST_TOP_OFFSET) {
            if (bottom > midpoint) {
                smoothScrollBy(top, GOTO_SCROLL_DURATION);
            } else {
                smoothScrollBy(bottom, GOTO_SCROLL_DURATION);
            }
        }
    } else {
        mPreviousScrollState = mNewState;
    }
}
 
Example 29
Project: Tribe   File: PullToRefreshAdapterViewBase.java   View source code 5 votes vote down vote up
public final void onScrollStateChanged(final AbsListView view, final int state) {
	/**
	 * Check that the scrolling has stopped, and that the last item is
	 * visible.
	 */
	if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) {
		mOnLastItemVisibleListener.onLastItemVisible();
	}

	if (null != mOnScrollListener) {
		mOnScrollListener.onScrollStateChanged(view, state);
	}
}
 
Example 30
Project: CustomAndroidOneSheeld   File: PullToRefreshAdapterViewBase.java   View source code 5 votes vote down vote up
public final void onScrollStateChanged(final AbsListView view, final int state) {
	/**
	 * Check that the scrolling has stopped, and that the last item is
	 * visible.
	 */
	if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) {
		mOnLastItemVisibleListener.onLastItemVisible();
	}

	if (null != mOnScrollListener) {
		mOnScrollListener.onScrollStateChanged(view, state);
	}
}
 
Example 31
Project: boohee_v5.6   File: PauseOnScrollListener.java   View source code 5 votes vote down vote up
public PauseOnScrollListener(ImageLoader imageLoader, boolean pauseOnScroll, boolean
        pauseOnFling, OnScrollListener customListener) {
    this.imageLoader = imageLoader;
    this.pauseOnScroll = pauseOnScroll;
    this.pauseOnFling = pauseOnFling;
    this.externalListener = customListener;
}
 
Example 32
Project: boohee_v5.6   File: PinnedSectionListView.java   View source code 5 votes vote down vote up
public void setOnScrollListener(OnScrollListener listener) {
    if (listener == this.mOnScrollListener) {
        super.setOnScrollListener(listener);
    } else {
        this.mDelegateOnScrollListener = listener;
    }
}
 
Example 33
Project: EducationalAdministrationSystem   File: XListView.java   View source code 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (mScrollListener != null) {
        mScrollListener.onScrollStateChanged(view, scrollState);
    }

    if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
        if (mEnableAutoLoad && getLastVisiblePosition() == getCount() - 1) {
            startLoadMore();
        }
    }
}
 
Example 34
Project: react-native-udesk   File: UDPullGetMoreListView.java   View source code 5 votes vote down vote up
public void onScrollStateChanged(AbsListView arg0, int arg1) {

        switch(arg1){
            case AbsListView.OnScrollListener.SCROLL_STATE_IDLE://空闲状态
                UdeskUtil.imageResume();
                break;
            case AbsListView.OnScrollListener.SCROLL_STATE_FLING://滚动状态
                UdeskUtil.imagePause();
                break;
            case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL://触摸后滚动
                break;
        }
    }
 
Example 35
Project: aarLibrary   File: XRefreshContentView.java   View source code 5 votes vote down vote up
private void setRecyclerViewScrollListener() {
        layoutManagerType = null;
        final RecyclerView recyclerView = (RecyclerView) child;
        if (recyclerView.getAdapter() == null) {
            return;
        }
        if (!(recyclerView.getAdapter() instanceof BaseRecyclerAdapter)) {
//            throw new RuntimeException("Recylerview的adapter请继承 BaseRecyclerAdapter");
            LogUtils.w(RECYCLERVIEW_ADAPTER_WARIN);
            return;
        }
        final BaseRecyclerAdapter adapter = (BaseRecyclerAdapter) recyclerView.getAdapter();
        adapter.insideEnableFooter(mParent.getPullLoadEnable());
        recyclerView.removeOnScrollListener(mOnScrollListener);
        mOnScrollListener = new RecyclerView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                if (mRecyclerViewScrollListener != null) {
                    mRecyclerViewScrollListener.onScrollStateChanged(recyclerView, newState);
                }
            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                onRecyclerViewScrolled(recyclerView, adapter, dx, dy, false);
            }
        };
        recyclerView.addOnScrollListener(mOnScrollListener);

        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
        if (layoutManager != null && layoutManager instanceof GridLayoutManager) {
            GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
            gridLayoutManager.setSpanSizeLookup(new XSpanSizeLookup(adapter, gridLayoutManager.getSpanCount()));
        }
        initFooterCallBack(adapter, mParent);
    }
 
Example 36
Project: aarLibrary   File: XRefreshContentView.java   View source code 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    /******解决abslistview数据不满一屏的时候,会重复加载更多的问题 start ******/
    if (mParent.isStopLoadMore() && scrollState == OnScrollListener.SCROLL_STATE_FLING) {
        isForbidLoadMore = true;
    }
    if (isForbidLoadMore) {
        if (!mParent.isStopLoadMore() && scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
            isForbidLoadMore = false;
        }
        return;
    }
    /******解决abslistview数据不满一屏的时候,会重复加载更多的问题 end ******/
    if (mSilenceLoadMore) {
        if (mRefreshViewListener != null && !hasLoadCompleted() && !mIsLoadingMore && mTotalItemCount - 1 <= view.getLastVisiblePosition() + mPreLoadCount) {
            mRefreshViewListener.onLoadMore(true);
            mIsLoadingMore = true;
        }
    } else if (mContainer != null && !hasLoadCompleted()
            && scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
        if (mPreLoadCount == 0) {
            if (isBottom()) {
                if (!mIsLoadingMore) {
                    mIsLoadingMore = mContainer.invokeLoadMore();
                }
            }
        } else {
            if (mTotalItemCount - 1 <= view.getLastVisiblePosition() + mPreLoadCount) {
                if (!mIsLoadingMore) {
                    mIsLoadingMore = mContainer.invokeLoadMore();
                }
            }
        }
    }
    if (mAbsListViewScrollListener != null) {
        mAbsListViewScrollListener.onScrollStateChanged(view, scrollState);
    }
}
 
Example 37
Project: sctalk   File: PullToRefreshAdapterViewBase.java   View source code 5 votes vote down vote up
public final void onScrollStateChanged(final AbsListView view, final int state) {
	/**
	 * Check that the scrolling has stopped, and that the last item is
	 * visible.
	 */
	if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) {
		mOnLastItemVisibleListener.onLastItemVisible();
	}

	if (null != mOnScrollListener) {
		mOnScrollListener.onScrollStateChanged(view, state);
	}
}
 
Example 38
Project: PersianAndroidDateTimePicker   File: DayPickerView.java   View source code 5 votes vote down vote up
@Override
public void run() {
    mCurrentScrollState = mNewState;
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG,
                "new scroll state: " + mNewState + " old state: " + mPreviousScrollState);
    }
    // Fix the position after a scroll or a fling ends
    if (mNewState == OnScrollListener.SCROLL_STATE_IDLE
            && mPreviousScrollState != OnScrollListener.SCROLL_STATE_IDLE
            && mPreviousScrollState != OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
        mPreviousScrollState = mNewState;
        int i = 0;
        View child = getChildAt(i);
        while (child != null && child.getBottom() <= 0) {
            child = getChildAt(++i);
        }
        if (child == null) {
            // The view is no longer visible, just return
            return;
        }
        int firstPosition = getFirstVisiblePosition();
        int lastPosition = getLastVisiblePosition();
        boolean scroll = firstPosition != 0 && lastPosition != getCount() - 1;
        final int top = child.getTop();
        final int bottom = child.getBottom();
        final int midpoint = getHeight() / 2;
        if (scroll && top < LIST_TOP_OFFSET) {
            if (bottom > midpoint) {
                smoothScrollBy(top, GOTO_SCROLL_DURATION);
            } else {
                smoothScrollBy(bottom, GOTO_SCROLL_DURATION);
            }
        }
    } else {
        mPreviousScrollState = mNewState;
    }
}
 
Example 39
Project: IIFYM   File: DayPickerView.java   View source code 5 votes vote down vote up
public void postSetSelection(final int position) {
    clearFocus();
    post(new Runnable() {

        @Override
        public void run() {
            setSelection(position);
        }
    });
    onScrollStateChanged(this, OnScrollListener.SCROLL_STATE_IDLE);
}
 
Example 40
Project: IIFYM   File: DayPickerView.java   View source code 5 votes vote down vote up
@Override
public void run() {
    mCurrentScrollState = mNewState;
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG,
                "new scroll state: " + mNewState + " old state: " + mPreviousScrollState);
    }
    // Fix the position after a scroll or a fling ends
    if (mNewState == OnScrollListener.SCROLL_STATE_IDLE
            && mPreviousScrollState != OnScrollListener.SCROLL_STATE_IDLE
            && mPreviousScrollState != OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
        mPreviousScrollState = mNewState;
        int i = 0;
        View child = getChildAt(i);
        while (child != null && child.getBottom() <= 0) {
            child = getChildAt(++i);
        }
        if (child == null) {
            // The view is no longer visible, just return
            return;
        }
        int firstPosition = getFirstVisiblePosition();
        int lastPosition = getLastVisiblePosition();
        boolean scroll = firstPosition != 0 && lastPosition != getCount() - 1;
        final int top = child.getTop();
        final int bottom = child.getBottom();
        final int midpoint = getHeight() / 2;
        if (scroll && top < LIST_TOP_OFFSET) {
            if (bottom > midpoint) {
                smoothScrollBy(top, GOTO_SCROLL_DURATION);
            } else {
                smoothScrollBy(bottom, GOTO_SCROLL_DURATION);
            }
        }
    } else {
        mPreviousScrollState = mNewState;
    }
}