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