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);
}
}
}
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();
}
}
}
}
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));
}
});
}
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));
}
});
}
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;
}
Aggregations