Comments (5)
When you say "I just click on the item very quickly" can you clarify? Is the list being modified -- items being added or removed?
from stickyheaders.
This is ItemViewHolder class.
`public class ItemViewHolder extends SectioningAdapter.ItemViewHolder implements View.OnClickListener {
TextView personNameTextView;
TextView detailTextView;
public ItemViewHolder(View itemView) {
super(itemView);
personNameTextView = (TextView) itemView.findViewById(R.id.personNameTextView);
detailTextView = (TextView) itemView.findViewById(R.id.detail);
itemView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
int sectionIndex = getSectionForAdapterPosition(getAdapterPosition());
int itemIndex = getPositionOfItemInSection(sectionIndex, getAdapterPosition());
int position = getAdapterPositionForSectionItem(sectionIndex, itemIndex);
sections.get(sectionIndex).people.get(itemIndex).name.first = "Ann";
if (sections.get(sectionIndex).people.get(itemIndex).isShowDetail) {
sections.get(sectionIndex).people.get(itemIndex).isShowDetail = false;
}
else {
sections.get(sectionIndex).people.get(itemIndex).isShowDetail = true;
}
notifySectionItemChanged(sectionIndex, itemIndex);
}
}
`
This is onBindItemViewHolder.
@OverRide
public void onBindItemViewHolder(SectioningAdapter.ItemViewHolder viewHolder, int sectionIndex, int itemIndex) {
Section s = sections.get(sectionIndex);
ItemViewHolder ivh = (ItemViewHolder) viewHolder;
Person person = s.people.get(itemIndex);
ivh.personNameTextView.setText(capitalize(person.name.last) + ", " + capitalize(person.name.first));
if (sections.get(sectionIndex).people.get(itemIndex).isShowDetail) {
ivh.detailTextView.setVisibility(View.VISIBLE);
}
else {
ivh.detailTextView.setVisibility(View.GONE);
}
}
This is list_item_addressbook_person.xml
<TextView
android:id="@+id/personNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_gravity="start|center_vertical"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divider"/>
<TextView
android:id="@+id/detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:padding="10dp"
android:visibility="gone"
android:gravity="center"
android:textColor="@android:color/holo_red_dark"
android:text="Detail view"/>
Thanks in advance
from stickyheaders.
Hey, I think my bug is linked, here is the stacktrace
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.view.View.getTag(int)' on a null object reference at org.zakariya.stickyheaders.StickyHeaderLayoutManager.getViewViewHolder(StickyHeaderLayoutManager.java:730) at org.zakariya.stickyheaders.StickyHeaderLayoutManager.getViewAdapterPosition(StickyHeaderLayoutManager.java:734) at org.zakariya.stickyheaders.StickyHeaderLayoutManager.getBottommostChildView(StickyHeaderLayoutManager.java:578) at org.zakariya.stickyheaders.StickyHeaderLayoutManager.scrollVerticallyBy(StickyHeaderLayoutManager.java:354) at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4061) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871) at android.view.Choreographer.doCallbacks(Choreographer.java:683) at android.view.Choreographer.doFrame(Choreographer.java:616) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
The bug occurs when I'm modifying one element of the recyclerview (and calling notifySectionItemChanged
) while scrolling.
More precisely, I resume to the activity which contains my recyclerview, I start a task and the callback of this task modify an object of the list and call notifySectionItemChanged
on the element that changed. If I scroll very fast before the method is called it causes a bug.
I can also write my own issue as well if you prefer but this looks very similar to me ;)
EDIT: calling notifyAllSectionsDataSetChanged
instead of notifySectionItemChanged
allows me to avoid the bug even if it's not ideal, my list is relatively small.
Thx
from stickyheaders.
@Meldoyo this is very similar (if not identical) to a bug I encountered while implementing paged loading. Since I just (hopefully) fixed issue #18 I will put this at the top of my queue. Any chance you could whip up a simple demo app to reproduce this?
from stickyheaders.
Sure i'll try to find some time to do it today or this week.
from stickyheaders.
Related Issues (20)
- Class cast exception after upgrading to android x HOT 1
- Disabling item section collapsing on open HOT 2
- Publish version 0.7.9 to Maven HOT 4
- IndexOutOfBoundsException HOT 6
- How to set setStackFromEnd??
- Accessibility using StickyHeaders HOT 1
- App Crashing If the List size is 0. HOT 2
- Custom Scroll Behaviour
- wrap_content not working
- notifySectionItemChanged() crashes the app
- How to include grid layout with sticky headers ?
- This lib doesn't seem to support clipToPadding = false on RecyclerView
- Item size 0 , crash the app. HOT 1
- jcenter is deprecated. Move to mavencentral HOT 2
- how to get the current sticky section?
- StickyHeaderLayoutManager doesn't display scroll bars HOT 4
- Refactor AndroidX HOT 5
- StickyLayoutManager does not work in kotlin and recycler view appears empty HOT 1
- when user scroll the page, data changed in rows !
- Some problems when use this with smartRefreshLayout
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 stickyheaders.