@Override
 public void onScroll(
     AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
   if (externalListener != null) {
     externalListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
   }
 }
  public void onScroll(
      AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

    if (mOnScrollListener != null) {
      mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
    }

    if (mOnLoadMoreListener != null) {

      if (visibleItemCount == totalItemCount) {
        mProgressBarLoadMore.setVisibility(View.GONE);
        // mLabLoadMore.setVisibility(View.GONE);
        return;
      }

      boolean loadMore = firstVisibleItem + visibleItemCount >= totalItemCount;

      if (!mIsLoadingMore && loadMore && mCurrentScrollState != SCROLL_STATE_IDLE) {
        mProgressBarLoadMore.setVisibility(View.VISIBLE);
        // mLabLoadMore.setVisibility(View.VISIBLE);
        mIsLoadingMore = true;
        //                setSelection(getPositionForView(mFooterView));
        //                smoothScrollToPosition(mFooterView.getBottom());
        onLoadMore();
      }
    }
  }
示例#3
0
 @Override
 public void onScroll(
     AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
   // send to user's listener
   if (mScrollListener != null) {
     mScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
   }
 }
  @Override
  public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (mScrollListener != null) {
      mScrollListener.onScrollStateChanged(view, scrollState);
    }

    mScrollState = scrollState;
  }
示例#5
0
 @Override
 public void onScroll(
     AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
   // 发送到用户的监听器
   mTotalItemCount = totalItemCount;
   if (mScrollListener != null) {
     mScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
   }
 }
 @Override
 public void onScroll(
     AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
   if (scrollListener != null) {
     scrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
   }
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
     scrollChanged(firstVisibleItem);
   }
 }
 @Override
 public void onScroll(
     AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
   if (totalItemCount > 0) {
     refreshHeader();
   }
   if (mScrollListener != null) {
     mScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
   }
 }
  public void onScrollStateChanged(AbsListView view, int scrollState) {
    mCurrentScrollState = scrollState;

    if (mCurrentScrollState == SCROLL_STATE_IDLE) {
      mBounceHack = false;
    }

    if (mOnScrollListener != null) {
      mOnScrollListener.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);
    }
  }
  @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();
      }
    }
  }
  public void onScrollStateChanged(AbsListView view, int scrollState) {

    // bug fix: listview was not clickable after scroll
    if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
      view.invalidateViews();
    }

    mCurrentScrollState = scrollState;

    if (mOnScrollListener != null) {
      mOnScrollListener.onScrollStateChanged(view, scrollState);
    }
  }
示例#12
0
  @Override
  public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (isDropDownStyle) {
      currentScrollState = scrollState;

      if (currentScrollState == SCROLL_STATE_IDLE) {
        hasReachedTop = false;
      }
    }

    if (onScrollListener != null) {
      onScrollListener.onScrollStateChanged(view, scrollState);
    }
  }
  @Override
  public final void onScroll(
      final AbsListView view,
      final int firstVisibleItem,
      final int visibleItemCount,
      final int totalItemCount) {

    if (DEBUG) {
      Log.d(
          LOG_TAG,
          "First Visible: "
              + firstVisibleItem
              + ". Visible Count: "
              + visibleItemCount
              + ". Total Items: "
              + totalItemCount);
    }

    // If we have a OnItemVisibleListener, do check...
    if (null != mOnLastItemVisibleListener) {

      // Detect whether the last visible item has changed
      final int lastVisibleItemIndex = firstVisibleItem + visibleItemCount;

      /**
       * Check that the last item has changed, we have any items, and that the last item is visible.
       * lastVisibleItemIndex is a zero-based index, so we add one to it to check against
       * totalItemCount.
       */
      if (visibleItemCount > 0 && lastVisibleItemIndex + 1 == totalItemCount) {
        if (lastVisibleItemIndex != mSavedLastVisibleIndex) {
          mSavedLastVisibleIndex = lastVisibleItemIndex;
          mOnLastItemVisibleListener.onLastItemVisible();
        }
      }
    }

    // If we're showing the indicator, check positions...
    if (getShowIndicatorInternal()) {
      updateIndicatorViewsVisibility();
    }

    // Finally call OnScrollListener if we have one
    if (null != mOnScrollListener) {
      mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
    }
  }
  @Override
  public void onScroll(
      AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    // When the refresh view is completely visible, change the text to say
    // "Release to refresh..." and flip the arrow drawable.
    if (refreshOn) {

      if (mCurrentScrollState == SCROLL_STATE_TOUCH_SCROLL && mRefreshState != REFRESHING) {
        if (firstVisibleItem == 0) {
          mRefreshViewImage.setVisibility(View.VISIBLE);
          if ((mRefreshView.getBottom() >= mRefreshViewHeight + 20 || mRefreshView.getTop() >= 0)
              && mRefreshState != RELEASE_TO_REFRESH) {
            mRefreshViewText.setText("Release to refresh...");
            mRefreshViewImage.clearAnimation();
            mRefreshViewImage.startAnimation(mFlipAnimation);
            mRefreshState = RELEASE_TO_REFRESH;
          } else if (mRefreshView.getBottom() < mRefreshViewHeight + 20
              && mRefreshState != PULL_TO_REFRESH) {
            mRefreshViewText.setText("Pull to refresh...");
            if (mRefreshState != TAP_TO_REFRESH) {
              mRefreshViewImage.clearAnimation();
              mRefreshViewImage.startAnimation(mReverseFlipAnimation);
            }
            mRefreshState = PULL_TO_REFRESH;
          }
        } else {
          mRefreshViewImage.setVisibility(View.GONE);
          resetHeader();
        }
      } else if (mCurrentScrollState == SCROLL_STATE_FLING
          && firstVisibleItem == 0
          && mRefreshState != REFRESHING) {
        setSelection(1);
        mBounceHack = true;
      } else if (mBounceHack && mCurrentScrollState == SCROLL_STATE_FLING) {
        setSelection(1);
      }
    }

    if (mOnScrollListener != null) {
      mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
    }
  }
  public final void onScroll(
      final AbsListView view,
      final int firstVisibleItem,
      final int visibleItemCount,
      final int totalItemCount) {

    if (null != mOnLastItemVisibleListener) {
      // detect if last item is visible
      if (visibleItemCount > 0 && (firstVisibleItem + visibleItemCount == totalItemCount)) {
        // only process first event
        if (firstVisibleItem != mLastSavedFirstVisibleItem) {
          mLastSavedFirstVisibleItem = firstVisibleItem;
          mOnLastItemVisibleListener.onLastItemVisible();
        }
      }
    }

    if (null != mOnScrollListener) {
      mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
    }
  }
 @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);
   }
 }
  public final void onScroll(
      final AbsListView view,
      final int firstVisibleItem,
      final int visibleItemCount,
      final int totalItemCount) {

    if (DEBUG) {
      Log.d(
          LOG_TAG,
          "First Visible: "
              + firstVisibleItem
              + ". Visible Count: "
              + visibleItemCount
              + ". Total Items:"
              + totalItemCount);
    }

    /**
     * Set whether the Last Item is Visible. lastVisibleItemIndex is a zero-based index, so we minus
     * one totalItemCount to check
     */
    if (null != mOnLastItemVisibleListener) {
      mLastItemVisible =
          (totalItemCount > 0) && (firstVisibleItem + visibleItemCount >= totalItemCount - 1);
    }

    // If we're showing the indicator, check positions...
    if (getShowIndicatorInternal()) {
      updateIndicatorViewsVisibility();
    }

    // Finally call OnScrollListener if we have one
    if (null != mOnScrollListener) {
      mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
    }
  }
示例#18
0
  @Override
  public void onScroll(
      AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if (null != positionChangedListener && null != scrollBarPanel) {

      // Don't do anything if there is no itemviews
      if (totalItemCount > 0) {
        /*
         * from android source code (ScrollBarDrawable.java)
         */
        final int thickness = getVerticalScrollbarWidth();
        int height =
            Math.round(
                (float) getMeasuredHeight()
                    * computeVerticalScrollExtent()
                    / computeVerticalScrollRange());
        int thumbOffset =
            Math.round(
                (float) (getMeasuredHeight() - height)
                    * computeVerticalScrollOffset()
                    / (computeVerticalScrollRange() - computeVerticalScrollExtent()));
        final int minLength = thickness * 2;
        if (height < minLength) {
          height = minLength;
        }
        thumbOffset += height / 2;

        /*
         * find out which itemviews the center of thumb is on
         */
        final int count = getChildCount() - getFooterViewsCount();
        for (int i = 0; i < count; ++i) {
          final View childView = getChildAt(i);
          if (childView != null) {
            if (thumbOffset > childView.getTop() && thumbOffset < childView.getBottom()) {
              if (lastPosition != firstVisibleItem + i) {
                lastPosition = firstVisibleItem + i;

                positionChangedListener.onPositionChanged(this, lastPosition, scrollBarPanel);

                measureChild(scrollBarPanel, widthMeasureSpec, heightMeasureSpec);
              }
              break;
            }
          }
        }

        scrollBarPanelPosition = thumbOffset - scrollBarPanel.getMeasuredHeight() / 2;
        final int x =
            getMeasuredWidth() - scrollBarPanel.getMeasuredWidth() - getVerticalScrollbarWidth();
        scrollBarPanel.layout(
            x,
            scrollBarPanelPosition,
            x + scrollBarPanel.getMeasuredWidth(),
            scrollBarPanelPosition + scrollBarPanel.getMeasuredHeight());
      }
    }

    if (onScrollListener != null) {
      onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
    }
  }
 @Override
 public final void onScrollStateChanged(final AbsListView view, final int scrollState) {
   if (null != mOnScrollListener) {
     mOnScrollListener.onScrollStateChanged(view, scrollState);
   }
 }
示例#20
0
  @Override
  public void onScroll(
      AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if (isDropDownStyle) {
      if (currentScrollState == SCROLL_STATE_TOUCH_SCROLL
          && currentHeaderStatus != HEADER_STATUS_LOADING) {
        /**
         * when state of ListView is SCROLL_STATE_TOUCH_SCROLL(ListView is scrolling and finger is
         * on screen) and header status is not HEADER_STATUS_LOADING
         *
         * <ul>
         *   if header layout is visiable,
         *   <li>if height of header is higher than a fixed value, then set header status to
         *       HEADER_STATUS_RELEASE_TO_LOAD.
         *   <li>else set header status to HEADER_STATUS_DROP_DOWN_TO_LOAD.
         * </ul>
         *
         * <ul>
         *   if header layout is not visiable,
         *   <li>set header status to HEADER_STATUS_CLICK_TO_LOAD.
         * </ul>
         */
        if (firstVisibleItem == 0) {
          headerImage.setVisibility(View.VISIBLE);
          int pointBottom = headerOriginalHeight + headerReleaseMinDistance;
          if (headerLayout.getBottom() >= pointBottom) {
            setHeaderStatusReleaseToLoad();
          } else if (headerLayout.getBottom() < pointBottom) {
            setHeaderStatusDropDownToLoad();
          }
        } else {
          setHeaderStatusClickToLoad();
        }
      } else if (currentScrollState == SCROLL_STATE_FLING
          && firstVisibleItem == 0
          && currentHeaderStatus != HEADER_STATUS_LOADING) {
        /**
         * when state of ListView is SCROLL_STATE_FLING(ListView is scrolling but finger has leave
         * screen) and first item(header layout) is visible and header status is not
         * HEADER_STATUS_LOADING, then hide first item, set second item visible and set
         * hasReachedTop true.
         */
        setSecondPositionVisible();
        hasReachedTop = true;
      } else if (currentScrollState == SCROLL_STATE_FLING && hasReachedTop) {
        /**
         * when state of ListView is SCROLL_STATE_FLING(ListView is scrolling but finger has leave
         * screen) and hasReachedTop is true(it's because flick back), then hide first item, set
         * second item visible.
         */
        setSecondPositionVisible();
      }
    }

    // if isOnBottomStyle and isAutoLoadOnBottom and hasMore, then call
    // onBottom function auto
    if (isOnBottomStyle && isAutoLoadOnBottom && hasMore) {
      if (firstVisibleItem > 0
          && totalItemCount > 0
          && (firstVisibleItem + visibleItemCount == totalItemCount)) {
        onBottom();
      }
    }
    if (onScrollListener != null) {
      onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
    }
  }