Example usage for android.support.v4.view ScrollingView computeVerticalScrollExtent

List of usage examples for android.support.v4.view ScrollingView computeVerticalScrollExtent

Introduction

In this page you can find the example usage for android.support.v4.view ScrollingView computeVerticalScrollExtent.

Prototype

int computeVerticalScrollExtent();

Source Link

Document

Compute the vertical extent of the vertical scrollbar's thumb within the vertical range.

Usage

From source file:com.callba.phone.widget.refreshlayout.RefreshLayout.java

/**
 * @return {@code true} if child view almost scroll to bottom.
 *///  w ww. j av a  2  s. c  o  m
public boolean isAlmostBottom() {
    if (mTarget instanceof AbsListView) {
        final AbsListView absListView = (AbsListView) mTarget;
        return absListView.getLastVisiblePosition() >= absListView.getCount() - 1;
    } else if (mTarget instanceof ScrollingView) {
        final ScrollingView scrollingView = (ScrollingView) mTarget;
        final int offset = scrollingView.computeVerticalScrollOffset();
        final int range = scrollingView.computeVerticalScrollRange()
                - scrollingView.computeVerticalScrollExtent();
        return offset >= range;
    } else {
        return !ViewCompat.canScrollVertically(mTarget, 1);
    }
}

From source file:com.hippo.refreshlayout.RefreshLayout.java

/**
 * @return {@code true} if child view almost scroll to bottom.
 */// w w  w.j  av  a  2 s.  c  o m
public boolean isAlmostBottom() {
    if (null == mTarget) {
        return false;
    }

    if (mTarget instanceof AbsListView) {
        final AbsListView absListView = (AbsListView) mTarget;
        return absListView.getLastVisiblePosition() >= absListView.getCount() - 1;
    } else if (mTarget instanceof ScrollingView) {
        final ScrollingView scrollingView = (ScrollingView) mTarget;
        final int offset = scrollingView.computeVerticalScrollOffset();
        final int range = scrollingView.computeVerticalScrollRange()
                - scrollingView.computeVerticalScrollExtent();
        return offset >= range;
    } else {
        return !ViewCompat.canScrollVertically(mTarget, 1);
    }
}