android.widget.AbsListView.OnScrollListener#SCROLL_STATE_IDLE源码实例Demo

下面列出了android.widget.AbsListView.OnScrollListener#SCROLL_STATE_IDLE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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);
    }
}
 
源代码2 项目: bither-bitmap-sample   文件: TopAnimHandler.java
@Override
        public void run() {
            if (cells.size() == 0) {
                return;
            }
//            for (CellHolder cell : cells) {
//                if (cell.isToAnimate() && !animCells.contains(cell)) {
//                    animCells.add(cell);
//                }
//                if (!cell.isToAnimate() && animCells.contains(cell)) {
//                    animCells.remove(cell);
//                }
//                if (!cell.isReadyForAnimation()) {
//                    return;
//                }
//            }
            if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
                startAnimQueue();
            }
        }
 
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);
    }
}
 
@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);
	}
}
 
@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);
	}
}
 
源代码6 项目: 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;
  }
}
 
源代码7 项目: bither-bitmap-sample   文件: TopAnimHandler.java
private void check() {
    if (scrollState != OnScrollListener.SCROLL_STATE_IDLE) {
        return;
    }
    removeCallbacks(reset);
    removeCallbacks(check);
    postDelayed(check, AnimDelay);
}
 
源代码8 项目: StyleableDateTimePicker   文件: 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;
    }
}
 
源代码9 项目: 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);
	}
}
 
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);
	}
}
 
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);
	}
}
 
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;
}
 
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);
	}
}
 
源代码14 项目: 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);
	}
}
 
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);
	}
}
 
@Override
public void onScrollStateChanged(AbsListView view, int scrollState)
{
	// 滑到底部后自动加载,判断listview已经停止滚动并且最后可视的条目等于adapter的条目
	if (scrollState == OnScrollListener.SCROLL_STATE_IDLE && lastVisibleIndex >= videoListAdapter.getCount())
	{
           progressBar.setVisibility(View.VISIBLE);
           loadingTip.setVisibility(View.VISIBLE);
           loadVideo();
	}
}
 
源代码18 项目: 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);
    }
}
 
源代码19 项目: Klyph   文件: KlyphFragment2.java
public void onScrollStateChanged(AbsListView view, int scrollState)
{
	userScroll = scrollState != OnScrollListener.SCROLL_STATE_IDLE;
}
 
源代码20 项目: narrate-android   文件: DayPickerView.java
@Override
public void run() {
    mCurrentScrollState = mNewState;
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG,
                "new scroll state: " + mNewState + " old state: " + mPreviousScrollState);
    }

    if (mHideTitles) {
        mHandler.removeCallbacks(mTitleAlphaRunnable);
        mHandler.postDelayed(mTitleAlphaRunnable, 50);
    }

    // Fix the position after a scroll or a fling ends
    if (mNewState == OnScrollListener.SCROLL_STATE_IDLE) {
        if (mPreviousScrollState != OnScrollListener.SCROLL_STATE_IDLE) {
            mPreviousScrollState = mNewState;

            mHandler.removeCallbacks(mSelectionUpdateRunnable);

            int i = 0;
            MonthView child = (MonthView) getChildAt(i);
            while (child != null && child.getBottom() <= 0) {
                child = (MonthView) 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) {
                if ((top < LIST_TOP_OFFSET && child.getNumRows() < 6) ||
                        (child.getNumRows() == 6 && (top + child.getRowHeight() / 2) < LIST_TOP_OFFSET)) {
                    if (bottom > midpoint) {
                        if (mHideTitles && child.getNumRows() == 6) {
                            smoothScrollBy(top + child.getRowHeight() / 2, GOTO_SCROLL_DURATION);
                        } else {
                            smoothScrollBy(top, GOTO_SCROLL_DURATION);
                        }
                    } else {
                        if (mHideTitles && ((MonthView) getChildAt(i + 1)).getNumRows() == 6) {
                            smoothScrollBy(bottom + child.getRowHeight() / 2, GOTO_SCROLL_DURATION);
                        } else {
                            smoothScrollBy(bottom, GOTO_SCROLL_DURATION);
                        }
                    }
                }

                if (mListener != null || mStickySelectedDate) {
                    MonthView newChild = child;
                    if ( bottom < midpoint ) {
                        newChild = (MonthView) getChildAt(i + 1);
                    }

                    if (newChild.getMonth() != mSelectedDay.month ||
                            newChild.getYear() != mSelectedDay.year) {

                        final CalendarDay day = new CalendarDay(newChild.getYear(), newChild.getMonth(), 1);
                        mSelectionUpdateRunnable.processChange(day);
                    }
                }
            }

        }
    } else {
        mPreviousScrollState = mNewState;
    }
}