Comments (10)
I don't understand the question, sorry.
What are you trying to achieve? You want the sample to contain lots of nested recyclerviews?
from gravitysnaphelper.
Which part exactly isn't understood?
I didn't ask about nested RecyclerViews, though this can be a case of heavy pages.
from gravitysnaphelper.
I meant the title: "How to choose if it should create the views around?"
This sample has 4 nested RecyclerViews. Each one has a different SnapHelper. You mentioned the onBindViewHolder just gets called once in this case, which is ok, although it doesn't reflect the case in real life apps. So, what's the problem here?
EDIT:
Maybe this is useful: https://medium.com/google-developers/recyclerview-prefetch-c2f269075710
from gravitysnaphelper.
onBindViewHolder Should be called not just for the current one, but also for those near it.
That's why I mentioned RecyclerView and ViewPager.
If you use this library to be used on the case of a full screen cell, for some reason, it doesn't load those near it.
This was written some time ago, so maybe I was mistakenly writing this on the wrong repo.
from gravitysnaphelper.
Closing due to inactivity. This is question was out of scope for this library.
from gravitysnaphelper.
@rubensousa I don't remember what it was about, but reading what I wrote, I think it was about the case that each cell would take whole screen (or just the whole width for horizontal scrolling), like a ViewPager, and that the issue is that it doesn't work like ViewPager.
This means that there is an issue, that the views around don't get updated till you actually see a part of them.
This is bad, because in the case of loading the images from the Internet for the cells, you will always first see a placeholder because it takes time to load each.
It's also bad because the creation of the near cells should be performed now, and not later.
from gravitysnaphelper.
Yes, I finally understood what you meant, since I faced this exact issue a few months ago. My fix was extending LinearLayoutManager and just return more extra space in getExtraLayoutSpace: https://developer.android.com/reference/android/support/v7/widget/LinearLayoutManager.html#getExtraLayoutSpace(android.support.v7.widget.RecyclerView.State). I think we need to use this as an alternative to ViewPager's setOffscreenPageLimit: https://developer.android.com/reference/android/support/v4/view/ViewPager.html#setOffscreenPageLimit(int)
This also happens in the original LinearSnapHelper and that's why I decided to close this, since the fix involves configuring the RecyclerView and its LayoutManager
from gravitysnaphelper.
Can you please show how to do it?
How to force that at least one item from each side of the current one would be loaded?
from gravitysnaphelper.
I'm not sure if it's the best solution, but this was my workaround:
public class ViewPagerLinearLayoutManager extends LinearLayoutManager {
private int offScreenPageLimit = 1;
public ViewPagerLinearLayoutManager(Context context) {
super(context);
}
public ViewPagerLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
public void setOffscreenPageLimit(int extraPages) {
this.offScreenPageLimit = extraPages;
}
@Override
protected int getExtraLayoutSpace(RecyclerView.State state) {
return super.getExtraLayoutSpace(state) * offScreenPageLimit;
}
}
If you come up with another solution, please let me know :)
from gravitysnaphelper.
I see. Thank you.
from gravitysnaphelper.
Related Issues (20)
- GridLayoutManager.SpanSizeLookup is not considered HOT 1
- Show the vertical recyclerview below the horizontal HOT 3
- Question: how to snap right away, and also while allowing first&last items to also be in center? HOT 16
- a GravityPagerSnapHelper snap bug in version 1.5 HOT 6
- GravitySnapHelper dont return the first position when the user scroll at (0,0) position HOT 1
- GravitySnapHelper ignores RecyclerView padding in 2.0 HOT 4
- 222 HOT 1
- how set adapter for that HOT 1
- the first item cannot snap to center HOT 2
- Any help on having a Carousel Effect in this? HOT 1
- GravitySnapHelper.SnapListener not callback when scroll to first position. HOT 7
- can not scroll to the top position when call smoothScrollToPosition(0)
- Gravity.BOTTOM with margin HOT 1
- Does this can work like PagerSnapHelper HOT 7
- Library artifacts are published to jcenter only, which will close in 3 months HOT 1
- how to make hightlight snap item center
- Could not download package HOT 2
- Snap with decoration
- IllegalArgumentException when setting snapGravity to center HOT 3
- Prevent snap on items which are bigger than the viewport
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gravitysnaphelper.