Search in sources :

Example 56 with ScrollView

use of android.widget.ScrollView in project Shuttle by timusus.

the class ScrollableViewHelper method getScrollableViewScrollPosition.

/**
     * Returns the current scroll position of the scrollable view. If this method returns zero or
     * less, it means at the scrollable view is in a position such as the panel should handle
     * scrolling. If the method returns anything above zero, then the panel will let the scrollable
     * view handle the scrolling
     *
     * @param scrollableView the scrollable view
     * @param isSlidingUp    whether or not the panel is sliding up or down
     * @return the scroll position
     */
public int getScrollableViewScrollPosition(View scrollableView, boolean isSlidingUp) {
    if (scrollableView == null)
        return 0;
    if (scrollableView instanceof ScrollView) {
        if (isSlidingUp) {
            return scrollableView.getScrollY();
        } else {
            ScrollView sv = ((ScrollView) scrollableView);
            View child = sv.getChildAt(0);
            return (child.getBottom() - (sv.getHeight() + sv.getScrollY()));
        }
    } else if (scrollableView instanceof ListView && ((ListView) scrollableView).getChildCount() > 0) {
        ListView lv = ((ListView) scrollableView);
        if (lv.getAdapter() == null)
            return 0;
        if (isSlidingUp) {
            View firstChild = lv.getChildAt(0);
            // Approximate the scroll position based on the top child and the first visible item
            return lv.getFirstVisiblePosition() * firstChild.getHeight() - firstChild.getTop();
        } else {
            View lastChild = lv.getChildAt(lv.getChildCount() - 1);
            // Approximate the scroll position based on the bottom child and the last visible item
            return (lv.getAdapter().getCount() - lv.getLastVisiblePosition() - 1) * lastChild.getHeight() + lastChild.getBottom() - lv.getBottom();
        }
    } else if (scrollableView instanceof RecyclerView && ((RecyclerView) scrollableView).getChildCount() > 0) {
        RecyclerView rv = ((RecyclerView) scrollableView);
        //return a value > 0
        if (rv instanceof NestedScrollBlocker) {
            if (!((NestedScrollBlocker) rv).getBlockScroll()) {
                return 1;
            }
        }
        RecyclerView.LayoutManager lm = rv.getLayoutManager();
        if (rv.getAdapter() == null)
            return 0;
        if (isSlidingUp) {
            View firstChild = rv.getChildAt(0);
            // Approximate the scroll position based on the top child and the first visible item
            return rv.getChildLayoutPosition(firstChild) * lm.getDecoratedMeasuredHeight(firstChild) - lm.getDecoratedTop(firstChild);
        } else {
            View lastChild = rv.getChildAt(rv.getChildCount() - 1);
            // Approximate the scroll position based on the bottom child and the last visible item
            return (rv.getAdapter().getItemCount() - 1) * lm.getDecoratedMeasuredHeight(lastChild) + lm.getDecoratedBottom(lastChild) - rv.getBottom();
        }
    } else {
        return 0;
    }
}
Also used : ListView(android.widget.ListView) ScrollView(android.widget.ScrollView) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) View(android.view.View) ListView(android.widget.ListView)

Example 57 with ScrollView

use of android.widget.ScrollView in project glitch-hq-android by tinyspeck.

the class EncyclopediaLocationHubsFragment method scrollToTop.

@Override
protected void scrollToTop() {
    ScrollView sv = (ScrollView) m_root.findViewById(R.id.EncyclopediaLocationHubsScrollView);
    sv.smoothScrollTo(0, 0);
}
Also used : ScrollView(android.widget.ScrollView)

Example 58 with ScrollView

use of android.widget.ScrollView in project glitch-hq-android by tinyspeck.

the class EncyclopediaLocationStreetFragment method scrollToTop.

@Override
protected void scrollToTop() {
    ScrollView sv = (ScrollView) m_root.findViewById(R.id.EncyclopediaLocationStreetsScrollView);
    sv.smoothScrollTo(0, 0);
}
Also used : ScrollView(android.widget.ScrollView)

Example 59 with ScrollView

use of android.widget.ScrollView in project glitch-hq-android by tinyspeck.

the class EncyclopediaGiantDetailFragment method scrollToTop.

@Override
protected void scrollToTop() {
    ScrollView sv = (ScrollView) m_root.findViewById(R.id.EncyclopediaGiantDetailScrollView);
    sv.smoothScrollTo(0, 0);
}
Also used : ScrollView(android.widget.ScrollView)

Example 60 with ScrollView

use of android.widget.ScrollView in project glitch-hq-android by tinyspeck.

the class EncyclopediaGiantsListFragment method scrollToTop.

@Override
protected void scrollToTop() {
    ScrollView sv = (ScrollView) m_root.findViewById(R.id.EncyclopediaGiantsListScrollView);
    sv.smoothScrollTo(0, 0);
}
Also used : ScrollView(android.widget.ScrollView)

Aggregations

ScrollView (android.widget.ScrollView)363 View (android.view.View)173 TextView (android.widget.TextView)149 LinearLayout (android.widget.LinearLayout)93 ImageView (android.widget.ImageView)65 ViewGroup (android.view.ViewGroup)53 Button (android.widget.Button)36 EditText (android.widget.EditText)36 ListView (android.widget.ListView)29 RecyclerView (android.support.v7.widget.RecyclerView)25 Intent (android.content.Intent)24 AbsListView (android.widget.AbsListView)24 AdapterView (android.widget.AdapterView)24 GridLayout (android.widget.GridLayout)24 ArrayList (java.util.ArrayList)21 SuppressLint (android.annotation.SuppressLint)20 WebView (android.webkit.WebView)19 FrameLayout (android.widget.FrameLayout)19 Dialog (android.app.Dialog)17 DialogInterface (android.content.DialogInterface)16