Search in sources :

Example 36 with AbsListView

use of android.widget.AbsListView in project SmoothRefreshLayout by dkzwm.

the class HorizontalBoundaryUtil method isVerticalView.

private static boolean isVerticalView(View view) {
    if (view instanceof AbsListView || view instanceof ScrollView || view instanceof NestedScrollView || view instanceof WebView) {
        return true;
    }
    try {
        if (view instanceof RecyclerView) {
            RecyclerView recyclerView = (RecyclerView) view;
            RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
            if (manager != null) {
                if (manager instanceof LinearLayoutManager) {
                    LinearLayoutManager linearManager = ((LinearLayoutManager) manager);
                    if (linearManager.getOrientation() == LinearLayoutManager.VERTICAL)
                        return true;
                } else if (manager instanceof StaggeredGridLayoutManager) {
                    StaggeredGridLayoutManager gridLayoutManager = (StaggeredGridLayoutManager) manager;
                    if (gridLayoutManager.getOrientation() == StaggeredGridLayoutManager.VERTICAL)
                        return true;
                }
            }
        }
    } catch (NoClassDefFoundError e) {
        e.printStackTrace();
    }
    return false;
}
Also used : ScrollView(android.widget.ScrollView) NestedScrollView(android.support.v4.widget.NestedScrollView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) NestedScrollView(android.support.v4.widget.NestedScrollView) WebView(android.webkit.WebView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 37 with AbsListView

use of android.widget.AbsListView in project SmoothRefreshLayout by dkzwm.

the class ScrollCompat method scrollCompat.

public static boolean scrollCompat(View view, float deltaY) {
    if (view != null) {
        if (view instanceof AbsListView) {
            final AbsListView listView = (AbsListView) view;
            if (Build.VERSION.SDK_INT >= 19) {
                listView.scrollListBy((int) deltaY);
                return true;
            } else {
                try {
                    @SuppressLint("PrivateApi") Method method = AbsListView.class.getDeclaredMethod("trackMotionScroll", int.class, int.class);
                    if (method != null) {
                        method.setAccessible(true);
                        method.invoke(listView, -(int) deltaY, -(int) deltaY);
                    }
                } catch (Exception e) {
                    return false;
                }
            }
            return true;
        } else if ((view instanceof WebView) || (view instanceof ScrollView) || (view instanceof NestedScrollView)) {
            view.scrollBy(0, (int) deltaY);
        } else {
            try {
                if (view instanceof RecyclerView) {
                    view.scrollBy(0, (int) deltaY);
                    return true;
                }
            } catch (NoClassDefFoundError e) {
            // ignore exception
            }
        }
    }
    return false;
}
Also used : ScrollView(android.widget.ScrollView) NestedScrollView(android.support.v4.widget.NestedScrollView) AbsListView(android.widget.AbsListView) SuppressLint(android.annotation.SuppressLint) RecyclerView(android.support.v7.widget.RecyclerView) Method(java.lang.reflect.Method) WebView(android.webkit.WebView) NestedScrollView(android.support.v4.widget.NestedScrollView)

Example 38 with AbsListView

use of android.widget.AbsListView in project SmoothRefreshLayout by dkzwm.

the class ScrollCompat method canAutoLoadMore.

public static boolean canAutoLoadMore(View view) {
    if (view instanceof AbsListView) {
        AbsListView listView = (AbsListView) view;
        final int lastVisiblePosition = listView.getLastVisiblePosition();
        final Adapter adapter = listView.getAdapter();
        return adapter != null && lastVisiblePosition > 0 && lastVisiblePosition >= adapter.getCount() - 1;
    } else {
        try {
            if (view instanceof RecyclerView) {
                RecyclerView recyclerView = (RecyclerView) view;
                RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
                if (manager == null)
                    return false;
                int lastVisiblePosition = 0;
                if (manager instanceof LinearLayoutManager) {
                    LinearLayoutManager linearManager = ((LinearLayoutManager) manager);
                    lastVisiblePosition = linearManager.findLastVisibleItemPosition();
                } else if (manager instanceof StaggeredGridLayoutManager) {
                    StaggeredGridLayoutManager gridLayoutManager = (StaggeredGridLayoutManager) manager;
                    int[] lastPositions = new int[gridLayoutManager.getSpanCount()];
                    gridLayoutManager.findLastVisibleItemPositions(lastPositions);
                    lastVisiblePosition = lastPositions[0];
                    for (int value : lastPositions) {
                        if (value > lastVisiblePosition) {
                            lastVisiblePosition = value;
                        }
                    }
                }
                RecyclerView.Adapter adapter = recyclerView.getAdapter();
                return adapter != null && lastVisiblePosition > 0 && lastVisiblePosition >= adapter.getItemCount() - 1;
            }
        } catch (NoClassDefFoundError e) {
            e.printStackTrace();
        }
        return false;
    }
}
Also used : AbsListView(android.widget.AbsListView) Adapter(android.widget.Adapter) RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SuppressLint(android.annotation.SuppressLint)

Example 39 with AbsListView

use of android.widget.AbsListView in project android_frameworks_base by crdroidandroid.

the class ChooserActivity method onPrepareAdapterView.

@Override
public void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, boolean alwaysUseOption) {
    final ListView listView = adapterView instanceof ListView ? (ListView) adapterView : null;
    mChooserListAdapter = (ChooserListAdapter) adapter;
    if (mCallerChooserTargets != null && mCallerChooserTargets.length > 0) {
        mChooserListAdapter.addServiceResults(null, Lists.newArrayList(mCallerChooserTargets));
    }
    mChooserRowAdapter = new ChooserRowAdapter(mChooserListAdapter);
    mChooserRowAdapter.registerDataSetObserver(new OffsetDataSetObserver(adapterView));
    adapterView.setAdapter(mChooserRowAdapter);
    if (listView != null) {
        listView.setItemsCanFocus(true);
    }
}
Also used : ListView(android.widget.ListView) AbsListView(android.widget.AbsListView)

Example 40 with AbsListView

use of android.widget.AbsListView in project android_frameworks_base by crdroidandroid.

the class ResolverDrawerLayout method getHeightUsed.

private int getHeightUsed(View child) {
    // This method exists because we're taking a fast path at measuring ListViews that
    // lets us get away with not doing the more expensive wrap_content measurement which
    // imposes double child view measurement costs. If we're looking at a ListView, we can
    // check against the lowest child view plus padding and margin instead of the actual
    // measured height of the ListView. This lets the ListView hang off the edge when
    // all of the content would fit on-screen.
    int heightUsed = child.getMeasuredHeight();
    if (child instanceof AbsListView) {
        final AbsListView lv = (AbsListView) child;
        final int lvPaddingBottom = lv.getPaddingBottom();
        int lowest = 0;
        for (int i = 0, N = lv.getChildCount(); i < N; i++) {
            final int bottom = lv.getChildAt(i).getBottom() + lvPaddingBottom;
            if (bottom > lowest) {
                lowest = bottom;
            }
        }
        if (lowest < heightUsed) {
            heightUsed = lowest;
        }
    }
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    return lp.topMargin + heightUsed + lp.bottomMargin;
}
Also used : AbsListView(android.widget.AbsListView)

Aggregations

AbsListView (android.widget.AbsListView)218 View (android.view.View)126 ListView (android.widget.ListView)80 AdapterView (android.widget.AdapterView)54 TextView (android.widget.TextView)46 ViewGroup (android.view.ViewGroup)33 ImageView (android.widget.ImageView)29 RecyclerView (android.support.v7.widget.RecyclerView)21 GridView (android.widget.GridView)21 SuppressLint (android.annotation.SuppressLint)20 ScrollView (android.widget.ScrollView)20 OnScrollListener (android.widget.AbsListView.OnScrollListener)19 Intent (android.content.Intent)17 ArrayList (java.util.ArrayList)16 Context (android.content.Context)12 Point (android.graphics.Point)12 Handler (android.os.Handler)12 ExpandableListView (android.widget.ExpandableListView)12 ArrayListLoader (com.klinker.android.twitter.adapters.ArrayListLoader)10 ItemManager (org.lucasr.smoothie.ItemManager)10