Java Code Examples for androidx.recyclerview.widget.RecyclerView#HORIZONTAL
The following examples show how to use
androidx.recyclerview.widget.RecyclerView#HORIZONTAL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HorizontalScrollCompat.java From SmoothRefreshLayout with MIT License | 6 votes |
public static boolean isScrollingView(View view) { if (ViewCatcherUtil.isViewPager(view) || view instanceof HorizontalScrollView || view instanceof WebView) { return true; } else if (ViewCatcherUtil.isRecyclerView(view)) { RecyclerView recyclerView = (RecyclerView) view; RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); if (manager != null) { if (manager instanceof LinearLayoutManager) { LinearLayoutManager linearManager = ((LinearLayoutManager) manager); return linearManager.getOrientation() == RecyclerView.HORIZONTAL; } else if (manager instanceof StaggeredGridLayoutManager) { StaggeredGridLayoutManager gridLayoutManager = (StaggeredGridLayoutManager) manager; return gridLayoutManager.getOrientation() == RecyclerView.HORIZONTAL; } } } return false; }
Example 2
Source File: SimilarAppcAppsViewHolder.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
public SimilarAppcAppsViewHolder(View view, DecimalFormat oneDecimalFormat, PublishSubject<SimilarAppClickEvent> similarAppClick) { super(view); this.oneDecimalFormat = oneDecimalFormat; this.similarAppClick = similarAppClick; similarAppcApps = view.findViewById(R.id.similar_appc_list); similarAppcApps.setNestedScrollingEnabled(false); HorizontalHeaderItemDecoration similarAppcHeaderItemDecoration = new HorizontalHeaderItemDecoration(view.getContext(), similarAppcApps, R.layout.appview_appc_similar_header, AptoideUtils.ScreenU.getPixelsForDip(112, view.getResources()), AptoideUtils.ScreenU.getPixelsForDip(5, view.getResources())); similarAppcApps.addItemDecoration(similarAppcHeaderItemDecoration); LinearLayoutManager similarAppcLayout = new LinearLayoutManager(view.getContext(), RecyclerView.HORIZONTAL, false); similarAppcApps.setLayoutManager(similarAppcLayout); SnapHelper similarSnap = new SnapToStartHelper(); similarSnap.attachToRecyclerView(similarAppcApps); similarAppcApps.setAdapter(getSimilarAdapter()); }
Example 3
Source File: ModeView.java From mapwize-ui-android with MIT License | 5 votes |
private void initialize(@NonNull Context context) { inflate(context, R.layout.mapwize_mode_view, this); recyclerView = findViewById(R.id.mapwize_mode_recycler_view); LinearLayoutManager lm = new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false); recyclerView.setLayoutManager(lm); modeViewAdapter = new ModeViewAdapter(); modeViewAdapter.setListener(this); recyclerView.setAdapter(modeViewAdapter); }
Example 4
Source File: HorizontalScrollCompat.java From SmoothRefreshLayout with MIT License | 5 votes |
public static boolean canAutoLoadMore(View view) { if (ViewCatcherUtil.isRecyclerView(view)) { 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); if (linearManager.getOrientation() != RecyclerView.HORIZONTAL) { return false; } lastVisiblePosition = linearManager.findLastVisibleItemPosition(); } else if (manager instanceof StaggeredGridLayoutManager) { StaggeredGridLayoutManager gridLayoutManager = (StaggeredGridLayoutManager) manager; if (gridLayoutManager.getOrientation() != RecyclerView.HORIZONTAL) { return false; } int[] lastPositions = new int[gridLayoutManager.getSpanCount()]; gridLayoutManager.findLastVisibleItemPositions(lastPositions); for (int value : lastPositions) { if (value > lastVisiblePosition) { lastVisiblePosition = value; } } } RecyclerView.Adapter adapter = recyclerView.getAdapter(); return adapter != null && adapter.getItemCount() > 0 && lastVisiblePosition >= 0 && lastVisiblePosition >= adapter.getItemCount() - 1; } return false; }
Example 5
Source File: HorizontalScrollCompat.java From SmoothRefreshLayout with MIT License | 5 votes |
public static boolean canAutoRefresh(View view) { if (ViewCatcherUtil.isRecyclerView(view)) { RecyclerView recyclerView = (RecyclerView) view; RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); if (manager == null) { return false; } int firstVisiblePosition = -1; if (manager instanceof LinearLayoutManager) { LinearLayoutManager linearManager = ((LinearLayoutManager) manager); if (linearManager.getOrientation() != RecyclerView.HORIZONTAL) { return false; } firstVisiblePosition = linearManager.findFirstVisibleItemPosition(); } else if (manager instanceof StaggeredGridLayoutManager) { StaggeredGridLayoutManager gridLayoutManager = (StaggeredGridLayoutManager) manager; if (gridLayoutManager.getOrientation() != RecyclerView.HORIZONTAL) { return false; } int[] firstPositions = new int[gridLayoutManager.getSpanCount()]; gridLayoutManager.findFirstVisibleItemPositions(firstPositions); for (int value : firstPositions) { if (value == 0) { firstVisiblePosition = 0; break; } } } RecyclerView.Adapter adapter = recyclerView.getAdapter(); return adapter != null && firstVisiblePosition == 0; } return false; }
Example 6
Source File: ViewPagerLayoutManager.java From OmegaRecyclerView with MIT License | 5 votes |
public void setOrientation(int orientation) { switch (orientation) { case RecyclerView.HORIZONTAL: mOrientationHelper = new HorizontalHelper(); break; case RecyclerView.VERTICAL: mOrientationHelper = new VerticalHelper(); break; default: throw new IllegalArgumentException("Unknown orientation " + orientation); } mOrientation = orientation; removeAllViews(); requestLayout(); }
Example 7
Source File: BothDirectionsScrollLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
@Override public int computeHorizontalScrollExtent(RecyclerView.State state) { if (getOrientation() == RecyclerView.HORIZONTAL) { return super.computeHorizontalScrollExtent(state); } return computeHorizontalScrollExtent(); }
Example 8
Source File: BothDirectionsScrollLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
/** * 计算水平滚动边界 * * @return 滚动边界 */ protected int computeHorizontalScrollExtent() { if (getOrientation() == RecyclerView.HORIZONTAL) { final RecyclerView view = getRecyclerView(); return view == null ? 0 : view.computeHorizontalScrollExtent(); } return getMeasuredWidth() - getPaddingLeft() - getPaddingRight(); }
Example 9
Source File: BothDirectionsScrollLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
/** * 计算水平滚动范围 * * @return 滚动范围 */ protected int computeHorizontalScrollRange() { if (getOrientation() == RecyclerView.HORIZONTAL) { final RecyclerView view = getRecyclerView(); return view == null ? 0 : view.computeHorizontalScrollRange(); } return getChildMaxWidth(mChildMaxWidth) + mLeftDecorationMaxWidthOfChildMaxWidth + mRightDecorationMaxWidthOfChildMaxWidth; }
Example 10
Source File: BothDirectionsScrollLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
/** * 判断另一方向是否能够滚动 * * @return 是否能够 */ public boolean canScrollAnotherDirection() { if (getOrientation() == RecyclerView.HORIZONTAL) { return canScrollVertically(); } else { return canScrollHorizontally(); } }
Example 11
Source File: BothDirectionsScrollLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
@Override public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) { if (getOrientation() == RecyclerView.HORIZONTAL) { return super.scrollHorizontallyBy(dx, recycler, state); } return scrollBy(dx); }
Example 12
Source File: CenterLinearLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
@Override public void layoutDecoratedWithMargins(@NonNull View child, int left, int top, int right, int bottom) { if (!mCenter) { super.layoutDecoratedWithMargins(child, left, top, right, bottom); return; } final RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) child.getLayoutParams(); final int leftDecorationWidth = getLeftDecorationWidth(child); final int topDecorationHeight = getTopDecorationHeight(child); final int rightDecorationWidth = getRightDecorationWidth(child); final int bottomDecorationHeight = getBottomDecorationHeight(child); final ViewGroup parent = (ViewGroup) child.getParent(); final int offset; if (getOrientation() == RecyclerView.HORIZONTAL) { final int contentHeight = parent.getMeasuredHeight() - parent.getPaddingTop() - parent.getPaddingBottom(); offset = (contentHeight - (bottom - top)) / 2; child.layout(left + leftDecorationWidth + lp.leftMargin, top + topDecorationHeight + lp.topMargin + offset, right - rightDecorationWidth - lp.rightMargin, bottom - bottomDecorationHeight - lp.bottomMargin + offset); } else { final int contentWidth = parent.getMeasuredWidth() - parent.getPaddingLeft() - parent.getPaddingRight(); offset = (contentWidth - (right - left)) / 2; child.layout(left + leftDecorationWidth + offset + lp.leftMargin, top + topDecorationHeight + lp.topMargin, right - rightDecorationWidth - lp.rightMargin + offset, bottom - bottomDecorationHeight - lp.bottomMargin); } }
Example 13
Source File: DayPickerView.java From MaterialDateTimePicker with Apache License 2.0 | 5 votes |
public void init(Context context, DatePickerDialog.ScrollOrientation scrollOrientation) { @RecyclerView.Orientation int layoutOrientation = scrollOrientation == DatePickerDialog.ScrollOrientation.VERTICAL ? RecyclerView.VERTICAL : RecyclerView.HORIZONTAL; LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, layoutOrientation, false); setLayoutManager(linearLayoutManager); setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); setVerticalScrollBarEnabled(false); setHorizontalScrollBarEnabled(false); setClipChildren(false); mContext = context; setUpRecyclerView(scrollOrientation); }
Example 14
Source File: TrendHorizontalLinearLayoutManager.java From GeometricWeather with GNU Lesser General Public License v3.0 | 4 votes |
public TrendHorizontalLinearLayoutManager(Context context, int fillCount) { super(context, RecyclerView.HORIZONTAL, false); this.context = context; this.fillCount = fillCount; }