Java 类android.widget.AbsListView.OnScrollListener 实例源码
项目:GitHub
文件:PauseOnScrollListener.java
@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);
}
}
项目:Hotspot-master-devp
文件:PauseOnScrollListener.java
@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);
}
}
项目:Hotspot-master-devp
文件: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) {
if (isLoadAvailable()) {
setLoadAvailable(false);
mOnLastItemVisibleListener.onLastItemVisible();
}
}
if (null != mOnScrollListener) {
mOnScrollListener.onScrollStateChanged(view, state);
}
}
项目:GifImageLoader
文件:PauseOnScrollListener.java
@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);
}
}
项目:LoadMoreHelper
文件:MultiScrollListener.java
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);
}
}
项目:LoadMoreHelper
文件:MultiScrollListener.java
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);
}
}
}
}
项目:android-project-gallery
文件:PauseOnScrollListener.java
@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);
}
}
项目:aarLibrary
文件:XRefreshContentView.java
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!");
}
}
项目:sctalk
文件:ImageGridActivity.java
@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;
}
}
项目:ImageLoaderSupportGif
文件:PauseOnScrollListener.java
@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);
}
}
项目:magic_imageloader_network
文件:PauseOnScrollListener.java
@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);
}
}
项目:magic_imageloader_network
文件:PauseOnScrollListener.java
@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);
}
}
项目:Android-Application-ZJB
文件:PauseOnScrollListener.java
@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);
}
}
项目:XListView
文件:PullToRefreshListView.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 (mListView instanceof SlideListView)
((SlideListView) mListView).onScrollStateChanged(view, scrollState);
if (null != mScrollListener) {
mScrollListener.onScrollStateChanged(view, scrollState);
}
}
项目:AyoSunny
文件:PauseOnScrollListener.java
@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);
}
}
项目: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;
}
项目:BigApp_Discuz_Android
文件:PauseOnScrollListener.java
@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);
}
}
项目:android-open-project-demo-master
文件:PauseOnScrollListener.java
@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);
}
}
项目:lr_dialer
文件:Common.java
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;
}
}
项目:BigApp_WordPress_Android
文件:PauseOnScrollListener.java
@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);
}
}
项目:BigApp_WordPress_Android
文件: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);
}
}
项目:msb-android
文件: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 (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);
}
}
项目:GitHub
文件:XListView.java
@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();
}
}
}
项目:ultrasonic
文件: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);
}
}
项目:CustomListView
文件: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);
}
}
项目:ywApplication
文件: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);
}
}
项目: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);
}
项目:AssistantBySDK
文件: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;
}
}
项目:Tribe
文件: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);
}
}
项目:CustomAndroidOneSheeld
文件: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);
}
}
项目:boohee_v5.6
文件:PauseOnScrollListener.java
public PauseOnScrollListener(ImageLoader imageLoader, boolean pauseOnScroll, boolean
pauseOnFling, OnScrollListener customListener) {
this.imageLoader = imageLoader;
this.pauseOnScroll = pauseOnScroll;
this.pauseOnFling = pauseOnFling;
this.externalListener = customListener;
}
项目:boohee_v5.6
文件:PinnedSectionListView.java
public void setOnScrollListener(OnScrollListener listener) {
if (listener == this.mOnScrollListener) {
super.setOnScrollListener(listener);
} else {
this.mDelegateOnScrollListener = listener;
}
}
项目:EducationalAdministrationSystem
文件:XListView.java
@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();
}
}
}
项目:react-native-udesk
文件:UDPullGetMoreListView.java
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;
}
}
项目:aarLibrary
文件:XRefreshContentView.java
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);
}
项目:aarLibrary
文件:XRefreshContentView.java
@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);
}
}
项目: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);
}
}
项目:PersianAndroidDateTimePicker
文件: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;
}
}
项目:IIFYM
文件:DayPickerView.java
public void postSetSelection(final int position) {
clearFocus();
post(new Runnable() {
@Override
public void run() {
setSelection(position);
}
});
onScrollStateChanged(this, OnScrollListener.SCROLL_STATE_IDLE);
}
项目:IIFYM
文件: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;
}
}