List of usage examples for android.widget ScrollView getScrollY
public final int getScrollY()
From source file:com.miku.framelite.widget.SwipeRefreshLayout.java
/** * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. *//*from w w w . j av a 2s.c om*/ public boolean canChildScrollDown() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return absListView.getChildCount() > 0 && (absListView.getLastVisiblePosition() < absListView.getCount() - 1 || absListView.getChildAt(absListView.getChildCount() - 1) .getBottom() > absListView.getHeight() - absListView.getPaddingBottom()); } else if (mTarget instanceof ScrollView) { final ScrollView scrollView = (ScrollView) mTarget; return scrollView.getChildAt(0).getMeasuredHeight() > scrollView.getHeight() + scrollView.getScrollY(); } else { throw new IllegalStateException( "SwipeRefreshLayout swipe down can host child (AbsListView and scrollView)"); } } else { return ViewCompat.canScrollVertically(mTarget, 1); } }
From source file:com.google.reviewit.ReviewChangesFragment.java
private void init() { SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) v(R.id.swipeRefreshLayout); swipeRefreshLayout.setColorSchemeColors(widgetUtil.color(R.color.progressBar)); swipeRefreshLayout.setRefreshing(true); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override/*from w w w . jav a 2 s.c o m*/ public void onRefresh() { getApp().getQueryHandler().reset(); loadAndDisplay(true); } }); v(R.id.reloadButton).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { reloadQuery(); } }); final View nextPageProgress = v(R.id.nextPageProgress); final ScrollView scrollView = (ScrollView) v(R.id.scrollView); scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { if (isAdded() && getApp().getQueryHandler().hasNext() && nextPageProgress.getVisibility() == View.GONE) { View lastChild = scrollView.getChildAt(scrollView.getChildCount() - 1); if ((lastChild.getBottom() - (scrollView.getHeight() + scrollView.getScrollY())) == 0) { setVisible(nextPageProgress); scrollView.post(new Runnable() { @Override public void run() { scrollView.fullScroll(View.FOCUS_DOWN); loadAndDisplay(); } }); } } } }); }