Java Code Examples for androidx.recyclerview.widget.RecyclerView#VERTICAL
The following examples show how to use
androidx.recyclerview.widget.RecyclerView#VERTICAL .
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: DefaultItemDecoration.java From SwipeRecyclerView with Apache License 2.0 | 6 votes |
private boolean isLastColumn(int orientation, int position, int columnCount, int childCount) { if (orientation == RecyclerView.VERTICAL) { if (columnCount == 1) return true; return (position + 1) % columnCount == 0; } else { if (columnCount == 1) { return position + 1 == childCount; } else { int lastRawItemCount = childCount % columnCount; int rawCount = (childCount - lastRawItemCount) / columnCount + (lastRawItemCount > 0 ? 1 : 0); int rawPositionJudge = (position + 1) % columnCount; if (rawPositionJudge == 0) { int positionRaw = (position + 1) / columnCount; return rawCount == positionRaw; } else { int rawPosition = (position + 1 - rawPositionJudge) / columnCount + 1; return rawCount == rawPosition; } } } }
Example 2
Source File: BothDirectionsScrollLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
/** * 计算垂直滚动范围 * * @return 滚动范围 */ protected int computeVerticalScrollRange() { if (getOrientation() == RecyclerView.VERTICAL) { final RecyclerView view = getRecyclerView(); return view == null ? 0 : view.computeVerticalScrollRange(); } return getChildMaxHeight(mChildMaxHeight) + mTopDecorationMaxWidthOfChildMaxHeight + mBottomDecorationMaxWidthOfChildMaxHeight; }
Example 3
Source File: DefaultItemDecoration.java From SwipeRecyclerView with Apache License 2.0 | 5 votes |
private boolean isFirstColumn(int orientation, int position, int columnCount, int childCount) { if (orientation == RecyclerView.VERTICAL) { if (columnCount == 1) return true; return position % columnCount == 0; } else { return position < columnCount; } }
Example 4
Source File: AutoGridLayoutManager.java From EhViewer with Apache License 2.0 | 5 votes |
@Override public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { if (mColumnSizeChanged && mColumnSize > 0) { int totalSpace; if (getOrientation() == RecyclerView.VERTICAL) { totalSpace = getWidth() - getPaddingRight() - getPaddingLeft(); } else { totalSpace = getHeight() - getPaddingTop() - getPaddingBottom(); } int spanCount; switch (mStrategy) { default: case STRATEGY_MIN_SIZE: spanCount = getSpanCountForMinSize(totalSpace, mColumnSize); break; case STRATEGY_SUITABLE_SIZE: spanCount = getSpanCountForSuitableSize(totalSpace, mColumnSize); break; } setSpanCount(spanCount); mColumnSizeChanged = false; if (null != mListeners) { for (int i = 0, n = mListeners.size(); i < n; i++) { mListeners.get(i).onUpdateSpanCount(spanCount); } } } super.onLayoutChildren(recycler, state); }
Example 5
Source File: FlexibleItemDecoration.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
protected void draw(Canvas c, RecyclerView parent) { if (parent.getLayoutManager() == null) { return; } if (LayoutUtils.getOrientation(parent) == RecyclerView.VERTICAL) { drawVertical(c, parent); } else { drawHorizontal(c, parent); } }
Example 6
Source File: SelectiveDividerItemDecoration.java From CommonUtils with Apache License 2.0 | 5 votes |
@Override public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { if (mDivider == null) { outRect.set(0, 0, 0, 0); return; } int pos = parent.indexOfChild(view); if (pos != -1 && isDecorated(pos)) { if (mOrientation == RecyclerView.VERTICAL) outRect.set(0, 0, 0, mDivider.getIntrinsicHeight()); else outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0); } }
Example 7
Source File: BothDirectionsScrollLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
@Override public int computeVerticalScrollExtent(RecyclerView.State state) { if (getOrientation() == RecyclerView.VERTICAL) { return super.computeVerticalScrollExtent(state); } return computeVerticalScrollExtent(); }
Example 8
Source File: BothDirectionsScrollLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
@Override public int computeVerticalScrollOffset(RecyclerView.State state) { if (getOrientation() == RecyclerView.VERTICAL) { return super.computeVerticalScrollOffset(state); } return computeVerticalScrollOffset(); }
Example 9
Source File: MediaScrollingActivity.java From BaldPhone with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!checkPermissions(this, requiredPermissions())) return; setContentView(R.layout.activity_media_scrolling); final Intent callingIntent = getIntent(); mediaChoose = callingIntent != null && (Intent.ACTION_GET_CONTENT.equals(callingIntent.getAction()) || Intent.ACTION_PICK.equals(callingIntent.getAction())); baldTitleBar = findViewById(R.id.bald_title_bar); recyclerView = findViewById(R.id.child); baldTitleBar.setTitle(title()); final Point point = new Point(); getWindowManager().getDefaultDisplay().getSize(point); final int num = (point.x / point.y) > 0 ? 6 : 3; final GridLayoutManager gridLayoutManager = new GridLayoutManager(this, num, RecyclerView.VERTICAL, REVERSED); recyclerView.setLayoutManager(gridLayoutManager); width = (int) ((recyclerView.getWidth() / 3) - TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics())); cursor = cursor(getContentResolver()); setupBeforeAdapter(); adapter = new MediaRecyclerViewAdapter(); recyclerView.setAdapter(adapter); }
Example 10
Source File: AnRecyclerView.java From Animer with Apache License 2.0 | 5 votes |
private boolean directionVertical() { switch (LAYOUT_MODE){ case LINEAR_LAYOUT: return ((LinearLayoutManager)mLayoutManager).getOrientation() == RecyclerView.VERTICAL; case GRID_LAYOUT: return ((GridLayoutManager)mLayoutManager).getOrientation() == RecyclerView.VERTICAL; case STAGGERED_LAYOUT: return ((StaggeredGridLayoutManager)mLayoutManager).getOrientation() == RecyclerView.VERTICAL; } return true; }
Example 11
Source File: FlexibleItemDecoration.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void applySectionGap(Rect outRect, RecyclerView.Adapter adapter, int position, int orientation) { // Section Gap Offset if (mSectionOffset > 0 && adapter instanceof FlexibleAdapter) { FlexibleAdapter flexibleAdapter = (FlexibleAdapter) adapter; IFlexible nextItem = flexibleAdapter.getItem(position + 1); // IMPORTANT: the check must be done on the BOTTOM of the section, // otherwise the sticky header will jump! if (flexibleAdapter.isHeader(nextItem)) { //Log.v("applySectionGap position=%s", position); if (orientation == RecyclerView.VERTICAL) { outRect.bottom += mSectionOffset; } else { outRect.right += mSectionOffset; } } if (position >= adapter.getItemCount() - mSectionGapOnLastItem) { //Log.v("applySectionGapOnLastPosition position=%s", position); if (orientation == RecyclerView.VERTICAL) { outRect.bottom += mSectionOffset; } else { outRect.right += mSectionOffset; } } } }
Example 12
Source File: AddedMultiViewHolder.java From Android-Keyboard with Apache License 2.0 | 5 votes |
@Override public void fillView(IMELanguageWrapper entity, int size) { LinearLayoutManager layoutManager = new LinearLayoutManager(itemView.getContext(), RecyclerView.VERTICAL,false); binding.recyclerView.setLayoutManager(layoutManager); binding.layoutSetName.setText(entity.getMultiIMELanguage().getLayoutName()); if(size <= 1){ binding.removeBtn.setVisibility(View.GONE); }else{ binding.removeBtn.setVisibility(View.VISIBLE); } adapter = new LanguageSettingAdapter(); binding.recyclerView.setAdapter(adapter); adapter.setDataSet(entity.getMultiIMELanguage().getIMELanguageWrappers()); binding.removeBtn.setOnClickListener(v -> { if(languageListener == null){ return; } languageListener.onClickRemove(entity); }); binding.recyclerView.setOnTouchListener((v, event) -> itemView.onTouchEvent(event)); itemView.setOnClickListener(v -> { if(languageListener == null){ return; } List<IMELanguage> imeList = entity.getMultiIMELanguage().getSubtypeIMEList(); if (imeList.size() > 0) { languageListener.onClickChangeLayoutSet(imeList.get(0)); } }); }
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: BothDirectionsScrollLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
/** * 计算垂直滚动边界 * * @return 滚动边界 */ protected int computeVerticalScrollExtent() { if (getOrientation() == RecyclerView.VERTICAL) { final RecyclerView view = getRecyclerView(); return view == null ? 0 : view.computeVerticalScrollExtent(); } return getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); }
Example 15
Source File: RecyclerViewStickyHeadItemDecoration.java From RecyclerViewDecoration with Apache License 2.0 | 5 votes |
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); if (mParent == null) { if (parent.getLayoutManager() instanceof LinearLayoutManager) { if (((LinearLayoutManager) parent.getLayoutManager()).getOrientation() != RecyclerView.VERTICAL) { throw new IllegalArgumentException("Only support LinearLayoutManager.VERTICAL"); } } mParent = parent; initListener(); } }
Example 16
Source File: BothDirectionsScrollLayoutManager.java From ProjectX with Apache License 2.0 | 5 votes |
@Override public int computeVerticalScrollRange(RecyclerView.State state) { if (getOrientation() == RecyclerView.VERTICAL) { return super.computeVerticalScrollRange(state); } return computeVerticalScrollRange(); }
Example 17
Source File: HomeActivity.java From PercentageChartView with Apache License 2.0 | 4 votes |
private void setupLayout() { final LinearLayoutManager llm = new LinearLayoutManager(this, RecyclerView.VERTICAL, false); llm.setItemPrefetchEnabled(true); mHomeRv.setLayoutManager(llm); mHomeRv.setHasFixedSize(true); adapter = new HomeAdapter(this); mHomeRv.setAdapter(adapter); adapter.setOnHomeClickedListener(position -> { Bundle transitionbundle = ActivityOptions.makeSceneTransitionAnimation(this).toBundle(); switch (position) { default: case 0: startActivity(new Intent(this, PieActivity.class), transitionbundle); break; case 1: startActivity(new Intent(this, RingActivity.class), transitionbundle); break; case 2: startActivity(new Intent(this, FillActivity.class), transitionbundle); break; case 3: startActivity(new Intent(this, AdaptiveColorsActivity.class), transitionbundle); break; case 4: startActivity(new Intent(this, GradientColorsActivity.class), transitionbundle); break; case 5: startActivity(new Intent(this, TextFormatterActivity.class), transitionbundle); break; case 6: Uri url = Uri.parse(getString(R.string.github_url)); Intent intent = new Intent(Intent.ACTION_VIEW, url); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } break; } }); }
Example 18
Source File: WebAppFragment.java From FastLib with Apache License 2.0 | 4 votes |
@Override public RecyclerView.LayoutManager getLayoutManager() { return new GridLayoutManager(mContext, 3, RecyclerView.VERTICAL, false); }
Example 19
Source File: StopwatchFragment.java From Clock-view with Apache License 2.0 | 4 votes |
private void initViews(View view) { stopwatch = view.findViewById(R.id.stopwatch); stopwatch.setStopwatchListener(this); savedItemList = new ArrayList<>(); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, true); StopWatchAdapter stopWatchAdapter = new StopWatchAdapter(savedItemList); recyclerView = view.findViewById(R.id.rv_values); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setAdapter(stopWatchAdapter); startBtn = view.findViewById(R.id.btn_start); startBtn.setOnClickListener(this); stopBtn = view.findViewById(R.id.btn_stop); stopBtn.setOnClickListener(this); saveBtn = view.findViewById(R.id.btn_save); saveBtn.setOnClickListener(this); }
Example 20
Source File: RecyclerViewFragment.java From AndroidFastScroll with Apache License 2.0 | 4 votes |
@NonNull protected LinearLayoutManager createLayoutManager(@NonNull RecyclerView recyclerView) { return new LinearLayoutManager(recyclerView.getContext(), RecyclerView.VERTICAL, false); }