Java Code Examples for androidx.recyclerview.widget.RecyclerView#getMeasuredHeight()
The following examples show how to use
androidx.recyclerview.widget.RecyclerView#getMeasuredHeight() .
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: GridSpacingItemDecoration.java From a with GNU General Public License v3.0 | 6 votes |
private void drawVertical(Canvas canvas, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom(); final int childSize = parent.getChildCount(); for (int i = 0; i < childSize; i++) { final View child = parent.getChildAt(i); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); final int left = child.getRight() + layoutParams.rightMargin; final int right = left + space; if (mDivider != null) { mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } if (mPaint != null) { canvas.drawRect(left, top, right, bottom, mPaint); } } }
Example 2
Source File: GridSpacingItemDecoration.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
private void drawVertical(Canvas canvas, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom(); final int childSize = parent.getChildCount(); for (int i = 0; i < childSize; i++) { final View child = parent.getChildAt(i); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); final int left = child.getRight() + layoutParams.rightMargin; final int right = left + space; if (mDivider != null) { mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } if (mPaint != null) { canvas.drawRect(left, top, right, bottom, mPaint); } } }
Example 3
Source File: RecyclerViewItemRangeSelector.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { boolean adapterIsEmpty = rv.getAdapter() == null || rv.getAdapter().getItemCount() == 0; boolean result = dragSelectActive && !adapterIsEmpty; if (result) { recyclerView = rv; if (hotspotHeight > -1) { hotspotTopBoundStart = hotspotOffsetTop; hotspotTopBoundEnd = hotspotOffsetTop + hotspotHeight; hotspotBottomBoundStart = rv.getMeasuredHeight() - hotspotHeight - hotspotOffsetBottom; hotspotBottomBoundEnd = rv.getMeasuredHeight() - hotspotOffsetBottom; } } if (result && e.getAction() == MotionEvent.ACTION_UP) { onDragSelectionStop(); } return result; }
Example 4
Source File: RecyclerViewItemRangeSelector.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { boolean adapterIsEmpty = rv.getAdapter() == null || rv.getAdapter().getItemCount() == 0; boolean result = dragSelectActive && !adapterIsEmpty; if (result) { recyclerView = rv; if (hotspotHeight > -1) { hotspotTopBoundStart = hotspotOffsetTop; hotspotTopBoundEnd = hotspotOffsetTop + hotspotHeight; hotspotBottomBoundStart = rv.getMeasuredHeight() - hotspotHeight - hotspotOffsetBottom; hotspotBottomBoundEnd = rv.getMeasuredHeight() - hotspotOffsetBottom; } } if (result && e.getAction() == MotionEvent.ACTION_UP) { onDragSelectionStop(); } return result; }
Example 5
Source File: MainAdapter.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
public void onScroll(RecyclerView recyclerView) { AbstractMainViewHolder holder; for (int i = 0; i < getItemCount(); i ++) { holder = (AbstractMainViewHolder) recyclerView.findViewHolderForAdapterPosition(i); if (holder != null && holder.getTop() < recyclerView.getMeasuredHeight()) { holder.enterScreen(pendingAnimatorList, listAnimationEnabled); } } }
Example 6
Source File: MediaActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void updateSections(RecyclerView listView, boolean checkTopBottom) { int count = listView.getChildCount(); int minPositionDateHolder = Integer.MAX_VALUE; View minDateChild = null; float padding = listView.getPaddingTop() + actionBar.getTranslationY(); int minTop = Integer.MAX_VALUE; int maxBottom = 0; for (int a = 0; a < count; a++) { View view = listView.getChildAt(a); int bottom = view.getBottom(); minTop = Math.min(minTop, view.getTop()); maxBottom = Math.max(bottom, maxBottom); if (bottom <= padding) { continue; } int position = view.getBottom(); if (view instanceof SharedMediaSectionCell || view instanceof GraySectionCell) { if (view.getAlpha() != 1.0f) { view.setAlpha(1.0f); } if (position < minPositionDateHolder) { minPositionDateHolder = position; minDateChild = view; } } } if (minDateChild != null) { if (minDateChild.getTop() > padding) { if (minDateChild.getAlpha() != 1.0f) { minDateChild.setAlpha(1.0f); } } else { if (minDateChild.getAlpha() != 0.0f) { minDateChild.setAlpha(0.0f); } } } if (checkTopBottom) { if (maxBottom != 0 && maxBottom < (listView.getMeasuredHeight() - listView.getPaddingBottom())) { resetScroll(); } else if (minTop != Integer.MAX_VALUE && minTop > listView.getPaddingTop() + actionBar.getTranslationY()) { scrollWithoutActionBar(listView, -listView.computeVerticalScrollOffset()); resetScroll(); } } }
Example 7
Source File: MediaActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void updateSections(RecyclerView listView, boolean checkTopBottom) { int count = listView.getChildCount(); int minPositionDateHolder = Integer.MAX_VALUE; View minDateChild = null; float padding = listView.getPaddingTop() + actionBar.getTranslationY(); int minTop = Integer.MAX_VALUE; int maxBottom = 0; for (int a = 0; a < count; a++) { View view = listView.getChildAt(a); int bottom = view.getBottom(); minTop = Math.min(minTop, view.getTop()); maxBottom = Math.max(bottom, maxBottom); if (bottom <= padding) { continue; } int position = view.getBottom(); if (view instanceof SharedMediaSectionCell || view instanceof GraySectionCell) { if (view.getAlpha() != 1.0f) { view.setAlpha(1.0f); } if (position < minPositionDateHolder) { minPositionDateHolder = position; minDateChild = view; } } } if (minDateChild != null) { if (minDateChild.getTop() > padding) { if (minDateChild.getAlpha() != 1.0f) { minDateChild.setAlpha(1.0f); } } else { if (minDateChild.getAlpha() != 0.0f) { minDateChild.setAlpha(0.0f); } } } if (checkTopBottom) { if (maxBottom != 0 && maxBottom < (listView.getMeasuredHeight() - listView.getPaddingBottom())) { resetScroll(); } else if (minTop != Integer.MAX_VALUE && minTop > listView.getPaddingTop() + actionBar.getTranslationY()) { scrollWithoutActionBar(listView, -listView.computeVerticalScrollOffset()); resetScroll(); } } }