Comments (19)
My tester confirmed that if I remove the caches from StickyListHeadersCursorAdapter, the problem goes away.
I don't really follow the use of the caches -- it appears that it's assumed that each cache will contain only one view at most? I
from stickylistheaders.
By limiting the cache to one item only, the problem also goes away:
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position,axtractHeaderAndListItemFromConvertView(convertView),parent);
boolean useCache = (headerCache.size() <= 1) && (wrapperCache.size() <= 1) && (dividerCache.size() <= 1);
if(position == 0 || getHeaderId(position)!=getHeaderId(position-1)){
v = attachHeaderToListItem(getHeaderWithForPosition(position, useCache),v, useCache);
v.setTag(true);
}else{
v = attachDividerToListItem(v, useCache);
v.setTag(false);
}
headerCache.clear();
wrapperCache.clear();
dividerCache.clear();
return v;
}
But there is a noticeable performance penalty with this. So I am not sure how the cache with multiple items is supposed to work, but looks like the various caches can get out of sync and the wrong view is used. Maybe having a single Object with the 3 views and caching those would be better???? I don't know.
from stickylistheaders.
Can you build a sample project where the problem is visible?
from stickylistheaders.
Hi, no, as I mentioned, it doesn't happen on my Galaxy Nexus. But it's obvious by looking at the code that it relies on the order in which getView() is called for the various rows. Since the caches are just queues (FIFO), If called out of order, they can end up with more than one item which are not retrieved in the right order causing this problem. This doesn't seem to happen on my device, but it happens reproducibly did on my tester's device. My "fix", which is a huge hack, throws away the cache if any of them end up with more than one item. In effect, the cache just because a single variable.
from stickylistheaders.
Maybe changing the data structure from a queue to a stack might also help.
from stickylistheaders.
I really don't see why this would happen. When you say it displays the wrong data, what do you mean?
from stickylistheaders.
It sometime displays data from the header that belongs to a different list item. I fixed it by the code above.
from stickylistheaders.
so let's say you have an alphabetical list and the header is the first letter. This bug causes the header to be "B" when it should say "C" ?
from stickylistheaders.
Yes, exactly. Your caching code seems to assume a certain order of things happening, that, under some circumstances, don't.
from stickylistheaders.
The thing is, I could never duplicate this issue on my Galaxy Nexus, but one of my testers could repeatable duplicate it on his phone, which was not a Nexus device. I forgot what skin it used.
from stickylistheaders.
yeah, the thing is that i am having a hard time understanding what would cause this. But i am looking into it ATM and will update
from stickylistheaders.
Yes, I never understood the real issue, either. But limiting the cache fixed it and it caused no noticeable performance issues.
from stickylistheaders.
I have theory that this might have to do with issue #25 (fixed now, will push tomorrow probably) . Does that sound possible? Because i don't feel like pushing a work around when i don't know the underlying problem.
from stickylistheaders.
Not likely. It happens for the tester when there is a long list. He would scroll the header out and then back in and it would appear wrong. The data is not changed.
I asked him what phone and version of Android he is on. Waiting for an answer.
from stickylistheaders.
ok great, will continue to investigate
from stickylistheaders.
He says it was a Samsung Galaxy S II with stock 2.3.6. So that's TouchWiz.
from stickylistheaders.
I will continue checking this out but i don't have that model with that software version at my disposal.
from stickylistheaders.
This should be closable since the behavior has changed significantly since the report.
from stickylistheaders.
I was thinking the same thing. Never could see the bug anyways so hard to see if is gone. @androidmoney you can open a new issue if this persists with after recent changes
from stickylistheaders.
Related Issues (20)
- ExpandableStickyListHeadersListView has only one child HOT 1
- How to change the content of the header to the marigin start?
- Crash on scrolling listview java.lang.ArrayIndexOutOfBoundsException: HOT 1
- facing ANR Warning
- can load more?
- Multi choice mode not working
- -
- Android P - App crashing - Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed HOT 4
- How to return the headerId? HOT 1
- Robolectric tests failing when used on Robolectric4/Androidx
- access to mSelectorPosition and mSelectorRect will be removed by the Android Framework HOT 1
- [QUESTION] Where I can find the CI service?
- Change the grouping of the sections rather then by first character
- app_bar_scrolling_view_behavior not working
- [Security] Static Scan Issues faced on MobSF platform
- Fatal Exception: java.lang.ClassCastException android.widget.FrameLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams HOT 2
- adding footer not working
- Not compatible with Android 10 HOT 4
- List header HOT 1
- Handling non empty state of parent class is not implemented HOT 4
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 stickylistheaders.