类android.widget.AbsListView.OnScrollListener源码实例Demo

下面列出了怎么用android.widget.AbsListView.OnScrollListener的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Auie   文件: UIFlexListView.java
@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;
	}
}
 
源代码2 项目: BigApp_Discuz_Android   文件: ReboundListView1.java
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;
}
 
@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);
    }
}
 
@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);
	}
}
 
源代码5 项目: endpoints-codelab-android   文件: TodoTxtTouch.java
@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;
	}
}
 
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);
    }
}
 
/**
 * 当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);
	}
}
 
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);
	}
}
 
源代码9 项目: PersianDateRangePicker   文件: DayPickerView.java
public void postSetSelection(final int position) {
  clearFocus();
  post(new Runnable() {

    @Override
    public void run() {
      setSelection(position);
    }
  });
  onScrollStateChanged(this, OnScrollListener.SCROLL_STATE_IDLE);
}
 
源代码10 项目: PersianDateRangePicker   文件: DayPickerView.java
@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;
  }
}
 
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);
	}
}
 
源代码12 项目: AssistantBySDK   文件: DayPickerView.java
public void postSetSelection(final int position) {
    clearFocus();
    post(new Runnable() {

        @Override
        public void run() {
            setSelection(position);
        }
    });
    onScrollStateChanged(this, OnScrollListener.SCROLL_STATE_IDLE);
}
 
源代码13 项目: MaterialDateRangePicker   文件: DayPickerView.java
@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;
    }
}
 
源代码14 项目: Social   文件: PullToRefreshAdapterViewBase.java
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);
	}
}
 
源代码15 项目: sctalk   文件: PullToRefreshAdapterViewBase.java
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);
	}
}
 
源代码16 项目: narrate-android   文件: DayPickerView.java
public void postSetSelection(final int position) {
    clearFocus();
    post(new Runnable() {

        @Override
        public void run() {
            setSelection(position);
        }
    });
    onScrollStateChanged(this, OnScrollListener.SCROLL_STATE_IDLE);
}
 
源代码17 项目: KJFrameForAndroid   文件: PullToRefreshList.java
@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);
    }
}
 
源代码18 项目: android-discourse   文件: TopicsListFragment.java
@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();
    }
}
 
源代码19 项目: AlarmOn   文件: DayPickerView.java
@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;
    }
}
 
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;
}
 
@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();
	}
}
 
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);
	}
}
 
源代码23 项目: BottomSheetPickers   文件: DayPickerView.java
@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;
    }
}
 
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);
	}
}
 
源代码25 项目: StyleableDateTimePicker   文件: DayPickerView.java
public void postSetSelection(final int position) {
    clearFocus();
    post(new Runnable() {

        @Override
        public void run() {
            setSelection(position);
        }
    });
    onScrollStateChanged(this, OnScrollListener.SCROLL_STATE_IDLE);
}
 
源代码26 项目: BaseProject   文件: BaseCommonAdapter.java
@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);
    }
}
 
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);
	}
}
 
源代码28 项目: FanXin-based-HuanXin   文件: AutoListView.java
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) {
	}
}
 
源代码29 项目: ButtonMenu   文件: ScrollAnimatorTest.java
@Test
public void shouldNotifyAdditionalScrollListenerOnScrollStateChanged() {
	OnScrollListener mockedScrollListener = mock(OnScrollListener.class);
	scrollAnimator.setAdditionalScrollListener(mockedScrollListener);
	scrollAnimator.configureListView(listView);

	doAnyScrollAction();

	verify(mockedScrollListener).onScrollStateChanged(listView, ANY_SCROLL_ACTION);
}
 
源代码30 项目: FimiX8-RE   文件: StickyListHeadersListView.java
public void setOnScrollListener(OnScrollListener l) {
    this.mOnScrollListenerDelegate = l;
}
 
 类所在包
 同包方法