Search in sources :

Example 71 with AbsListView

use of android.widget.AbsListView in project AgentWebX5 by Justson.

the class ScrollingUtil method scrollAViewBy.

public static void scrollAViewBy(View view, int height) {
    if (view instanceof RecyclerView)
        ((RecyclerView) view).scrollBy(0, height);
    else if (view instanceof ScrollView)
        ((ScrollView) view).smoothScrollBy(0, height);
    else if (view instanceof AbsListView)
        ((AbsListView) view).smoothScrollBy(height, 0);
    else {
        try {
            Method method = view.getClass().getDeclaredMethod("smoothScrollBy", Integer.class, Integer.class);
            method.invoke(view, 0, height);
        } catch (Exception e) {
            view.scrollBy(0, height);
        }
    }
}
Also used : ScrollView(android.widget.ScrollView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) Method(java.lang.reflect.Method)

Example 72 with AbsListView

use of android.widget.AbsListView in project MultipleTheme by dersoncheng.

the class ColorUiUtil method changeTheme.

/**
 * 切换应用主题
 *
 * @param rootView
 */
public static void changeTheme(View rootView, Resources.Theme theme) {
    if (rootView instanceof ColorUiInterface) {
        ((ColorUiInterface) rootView).setTheme(theme);
        if (rootView instanceof ViewGroup) {
            int count = ((ViewGroup) rootView).getChildCount();
            for (int i = 0; i < count; i++) {
                changeTheme(((ViewGroup) rootView).getChildAt(i), theme);
            }
        }
        if (rootView instanceof AbsListView) {
            try {
                Field localField = AbsListView.class.getDeclaredField("mRecycler");
                localField.setAccessible(true);
                Method localMethod = Class.forName("android.widget.AbsListView$RecycleBin").getDeclaredMethod("clear", new Class[0]);
                localMethod.setAccessible(true);
                localMethod.invoke(localField.get(rootView), new Object[0]);
            } catch (NoSuchFieldException e1) {
                e1.printStackTrace();
            } catch (ClassNotFoundException e2) {
                e2.printStackTrace();
            } catch (NoSuchMethodException e3) {
                e3.printStackTrace();
            } catch (IllegalAccessException e4) {
                e4.printStackTrace();
            } catch (InvocationTargetException e5) {
                e5.printStackTrace();
            }
        }
    } else {
        if (rootView instanceof ViewGroup) {
            int count = ((ViewGroup) rootView).getChildCount();
            for (int i = 0; i < count; i++) {
                changeTheme(((ViewGroup) rootView).getChildAt(i), theme);
            }
        }
        if (rootView instanceof AbsListView) {
            try {
                Field localField = AbsListView.class.getDeclaredField("mRecycler");
                localField.setAccessible(true);
                Method localMethod = Class.forName("android.widget.AbsListView$RecycleBin").getDeclaredMethod("clear", new Class[0]);
                localMethod.setAccessible(true);
                localMethod.invoke(localField.get(rootView), new Object[0]);
            } catch (NoSuchFieldException e1) {
                e1.printStackTrace();
            } catch (ClassNotFoundException e2) {
                e2.printStackTrace();
            } catch (NoSuchMethodException e3) {
                e3.printStackTrace();
            } catch (IllegalAccessException e4) {
                e4.printStackTrace();
            } catch (InvocationTargetException e5) {
                e5.printStackTrace();
            }
        }
    }
}
Also used : ColorUiInterface(derson.com.multipletheme.colorUi.ColorUiInterface) Field(java.lang.reflect.Field) ViewGroup(android.view.ViewGroup) AbsListView(android.widget.AbsListView) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 73 with AbsListView

use of android.widget.AbsListView in project DragTopLayout by chenupt.

the class ListViewFragment method initView.

private void initView() {
    listView = (ListView) getView().findViewById(R.id.list_view);
    adapter = new ModelListAdapter(getActivity(), DataService.getInstance().getModelManager());
    listView.setAdapter(adapter);
    adapter.setList(DataService.getInstance().getList());
    adapter.notifyDataSetChanged();
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(getActivity(), "Clicked " + position, Toast.LENGTH_SHORT).show();
        }
    });
    // attach top
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            EventBus.getDefault().post(AttachUtil.isAdapterViewAttach(view));
        }
    });
}
Also used : ModelListAdapter(github.chenupt.multiplemodel.ModelListAdapter) AbsListView(android.widget.AbsListView) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 74 with AbsListView

use of android.widget.AbsListView in project DragTopLayout by chenupt.

the class GridViewFragment method initView.

private void initView() {
    gridView = (GridView) getView().findViewById(R.id.grid_view);
    adapter = new ModelListAdapter(getActivity(), DataService.getInstance().getModelManager());
    gridView.setAdapter(adapter);
    adapter.setList(DataService.getInstance().getList());
    adapter.notifyDataSetChanged();
    // attach top
    gridView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            EventBus.getDefault().post(AttachUtil.isAdapterViewAttach(view));
        }
    });
}
Also used : ModelListAdapter(github.chenupt.multiplemodel.ModelListAdapter) AbsListView(android.widget.AbsListView)

Example 75 with AbsListView

use of android.widget.AbsListView in project QuickReturn by lawloretienne.

the class QuickReturnUtils method getScrollY.

public static int getScrollY(AbsListView lv) {
    View c = lv.getChildAt(0);
    if (c == null) {
        return 0;
    }
    int firstVisiblePosition = lv.getFirstVisiblePosition();
    int scrollY = -(c.getTop());
    // int scrollY = 0;
    sListViewItemHeights.put(lv.getFirstVisiblePosition(), c.getHeight());
    if (scrollY < 0)
        scrollY = 0;
    for (int i = 0; i < firstVisiblePosition; ++i) {
        if (// (this is a sanity check)
        sListViewItemHeights.get(i) != null)
            // add all heights of the views that are gone
            scrollY += sListViewItemHeights.get(i);
    }
    return scrollY;
}
Also used : AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) ListView(android.widget.ListView)

Aggregations

AbsListView (android.widget.AbsListView)223 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 ScrollView (android.widget.ScrollView)23 RecyclerView (android.support.v7.widget.RecyclerView)21 GridView (android.widget.GridView)21 SuppressLint (android.annotation.SuppressLint)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 WebView (android.webkit.WebView)12 ExpandableListView (android.widget.ExpandableListView)12 ArrayListLoader (com.klinker.android.twitter.adapters.ArrayListLoader)10