android.widget.AbsListView.OnScrollListener Java Examples

The following examples show how to use android.widget.AbsListView.OnScrollListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UIFlexListView.java    From Auie with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	switch (scrollState) {
	case OnScrollListener.SCROLL_STATE_IDLE:
		//控制上拉加载更多
		if (isSuspend && view.getLastVisiblePosition() == (view.getCount() - 1)) {
               mListView.setType(UIListView.TYPE_ONLY_UP_LOADMORD);
		}else {
			mListView.setType(UIListView.TYPE_NONE);
		}
		break;

	default:
		break;
	}
}
 
Example #2
Source File: ReboundListView1.java    From BigApp_Discuz_Android with Apache License 2.0 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 #3
Source File: PauseOnScrollListener.java    From BigApp_Discuz_Android with Apache License 2.0 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 #4
Source File: PauseOnScrollListener.java    From mobile-manager-tool with MIT License 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
Source File: TodoTxtTouch.java    From endpoints-codelab-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	// Store the scrolling state of the listview
	Log.v(TAG, "Scrolling state: " + scrollState);

	switch (scrollState) {
	case OnScrollListener.SCROLL_STATE_IDLE:
		mListScrolling = false;

		break;
	case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
		// List is scrolling under the direct touch of the user
		mListScrolling = true;

		break;
	case OnScrollListener.SCROLL_STATE_FLING:
		// The user did a 'fling' on the list and it's still
		// scrolling
		mListScrolling = true;

		break;
	}
}
 
Example #6
Source File: PullToRefreshAdapterViewBase.java    From BigApp_WordPress_Android with Apache License 2.0 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 #7
Source File: PauseOnScrollListener.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 6 votes vote down vote up
/**
 * 当View在进行滚动的时候,回调的onScrollStateChanged方法,在其中根据滚动的事件相关类型判断,
 * 暂停和开启ImageLoader加载图片
 * @param view
 * @param scrollState
 */
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	switch (scrollState) {
		case OnScrollListener.SCROLL_STATE_IDLE:
			//恢复ImageLoader加载
			imageLoader.resume();
			break;
		case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
			//判断标记,是否暂停ImageLoader加载
			if (pauseOnScroll) {
				imageLoader.pause();
			}
			break;
		case OnScrollListener.SCROLL_STATE_FLING:
			//判断标记,是否暂停ImageLoader加载
			if (pauseOnFling) {
				imageLoader.pause();
			}
			break;
	}
	if (externalListener != null) {
		externalListener.onScrollStateChanged(view, scrollState);
	}
}
 
Example #8
Source File: PullToRefreshAdapterViewBase.java    From Alibaba-Android-Certification with MIT License 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 #9
Source File: PullToRefreshAdapterViewBase.java    From PullToRefreshLibrary with Apache License 2.0 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 #10
Source File: DayPickerView.java    From MaterialDateRangePicker with Apache License 2.0 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 #11
Source File: DayPickerView.java    From AssistantBySDK with Apache License 2.0 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 #12
Source File: DayPickerView.java    From PersianDateRangePicker with Apache License 2.0 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 #13
Source File: DayPickerView.java    From PersianDateRangePicker with Apache License 2.0 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 #14
Source File: EssayCommentActivity.java    From WeCenterMobile-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	// TODO Auto-generated method stub
	if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
		showImage(mFirstVisibleItem, mVisibleItemCount);
	} else {
		cancleTask();
	}
}
 
Example #15
Source File: PullToRefreshAdapterViewBase.java    From Social with Apache License 2.0 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 #16
Source File: PullToRefreshAdapterViewBase.java    From sctalk with Apache License 2.0 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 #17
Source File: DayPickerView.java    From narrate-android with Apache License 2.0 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 #18
Source File: PullToRefreshList.java    From KJFrameForAndroid with Apache License 2.0 5 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 (null != mScrollListener) {
        mScrollListener.onScrollStateChanged(view, scrollState);
    }
}
 
Example #19
Source File: TopicsListFragment.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    // Pause disk cache access to ensure smoother scrolling
    if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
        mImageLoader.stopProcessingQueue();
    } else {
        mImageLoader.startProcessingQueue();
    }
}
 
Example #20
Source File: DayPickerView.java    From AlarmOn with Apache License 2.0 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 #21
Source File: PullToRefreshAdapterViewBase.java    From MagicHeaderViewPager with Apache License 2.0 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);
    }
    canInvoke = true;
}
 
Example #22
Source File: ScrollAnimatorTest.java    From ButtonMenu with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotifyAdditionalScrollListenerOnScrollStateChanged() {
	OnScrollListener mockedScrollListener = mock(OnScrollListener.class);
	scrollAnimator.setAdditionalScrollListener(mockedScrollListener);
	scrollAnimator.configureListView(listView);

	doAnyScrollAction();

	verify(mockedScrollListener).onScrollStateChanged(listView, ANY_SCROLL_ACTION);
}
 
Example #23
Source File: PullToRefreshAdapterViewBase.java    From handmarkPulltorefreshLibrary with Apache License 2.0 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 #24
Source File: DayPickerView.java    From BottomSheetPickers with Apache License 2.0 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 #25
Source File: PullToRefreshAdapterViewBase.java    From android-project-wo2b with Apache License 2.0 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
Source File: DayPickerView.java    From StyleableDateTimePicker with MIT License 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 #27
Source File: BaseCommonAdapter.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    if(OnScrollListener.SCROLL_STATE_IDLE == scrollState){
        isScrolling = false;
        notifyDataSetChanged();
    }
    else{
        isScrolling = true;
    }
    if(outScrollListener != null){
        outScrollListener.onScrollStateChanged(view, scrollState);
    }
}
 
Example #28
Source File: PullToRefreshAdapterViewBase.java    From LbaizxfPulltoRefresh with Apache License 2.0 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 #29
Source File: AutoListView.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
private void ifNeedLoad(AbsListView view, int scrollState) {
	if (!loadEnable) {
		return;
	}
	try {
		if (scrollState == OnScrollListener.SCROLL_STATE_IDLE
				&& !isLoading
				&& view.getLastVisiblePosition() == view
						.getPositionForView(footer) && !isLoadFull) {
			onLoad();
			isLoading = true;
		}
	} catch (Exception e) {
	}
}
 
Example #30
Source File: PullToRefreshSwipeMenuListView.java    From Android-PullToRefresh-SwipeMenuListView-Sample with MIT License 4 votes vote down vote up
@Override
public void setOnScrollListener(OnScrollListener l) {
	mScrollListener = l;
}