Git Product home page Git Product logo

expandable-recycler-view's Issues

NotifyDataSetChanged for add group is not working

Hi I want add group to the list when I clicked on the button but when click on button app is crash and I received the error length 2 index 2
this is my code in MainActivity

List<CommentTitle>  commentTitles = new ArrayList<>();
        List<Comment> comments1 = new ArrayList<>();
        List<Comment> comments2 = new ArrayList<>();

        comments1.add(new Comment("1395/12/8", "moein", "hello", 0, 10, 10));
        comments1.add(new Comment("1395/12/8", "moein", "hello", 1, 10, 10));
        comments1.add(new Comment("1395/12/8", "moein", "hello", 2, 10, 10));
        commentTitles.add(new CommentTitle("comment 1", comments1));

        comments2.add(new Comment("1395/12/8", "ali", "hello", 0, 10, 10));
        comments2.add(new Comment("1395/12/8", "reza", "hello", 1, 10, 10));
        comments2.add(new Comment("1395/12/8", "hassan", "hello", 2, 10, 10));
        commentTitles.add(new CommentTitle("comment 1", comments2));

        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.commentList);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(layoutManager);
        commentAdapter = new CommentAdapter(commentTitles, context);
        recyclerView.setAdapter(commentAdapter);


Button send = (Button) findViewById(R.id.button);
               send.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                     
                            List<Comment> comments3 = new ArrayList<>();
                            comments3.add(new Comment("1395/12/8", "moein","Hello World!", 0, 10, 10));
                            commentTitles.add(new CommentTitle("c", comments3));
                            commentAdapter.notifyDataSetChanged();

                        
                    }
                });


Make an interface for ExpandableGroup

Maybe have IExpandableGroup that is an interface which has exact contract that ExpandableGroup has.

This would allow developers to decide what their "Group" model extends from.

In my case, I need to extend BaseModel from dbFlow. I mean, of course I can create a wrapper class that contains my model and extends ExpandableGroup, but then I'm not sure that would even be compatible with my existing client code so a lot of classes might have to adapt.

By having IExpandableGroup, I just have to implement it in my existing model class and respect its contract.

ExpandableGroup can continue being the base class that people can use.

Yes, I know that's asking a lot.. Besides, I see some classes having to change when implementing this request, for example ExpandableRecyclerViewAdapter.onBindChildViewHolder(). It's a breaking change for sure.

MultiTypeExpandableRecyclerView

Is it possible to have SingleCheckExpandableGroup and MultiCheckExpandableGroup in same adapter?
Iw tried using MultiTypeExpandableRecyclerViewAdapter but single checkable groups are not working(im able to check all of the items)

value of edittext inside child changed on scroll

i have two buttons and one textview in each child row. those two buttons are used as triggers to count number and then write the number in textview. my problem is, the value of textview is always changes when i scroll the recyclerview and sometimes change the textview on neighbour child row. anyone can help ? thank you.

15240072_120300000948967656_247844965_n 1

when i click + on first row (1), textview on third row(2) is also changed.

Expand a group programmatically

How can I expand a group programmatically?

For example I have 3 groups. And when user opens an activity - the groups should be expanded already (without making user to expand each group manually).

Maybe something like:
recyclerView.getGroup(1).expand()

p.s. Thanks for this great lib guys!

Notify child item on adapter

How to notify when removing an item or inserting an item. i want to notify only particular group section to notify when changes happen not whole adapter. If anyone have a solution than please reply

Thank you in advance

How do i expand an item after a network call?

when i click on a group item, i need to make a network call (so dont rightaway expand that group). expand the group and POPULATE subgroup items with data, only on the success callback of that network call. is this possible?

Latency problem

Whenever i click on one of the checkboxes-there is quite a bit of delay till it accualy checks(and i dont mean animation) and i hate it, could u please fix it? it may have something to do with that it keeps trying to reload some of the groups (under the one thats child was checked)

Last group expand issue

When I scroll down list to the last item and click in group item the child cannot show, it out off screen. After collapsing that and clicking in another group item throw exception
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{949ddf4 position=17 id=-1, oldPos=16, pLpos:16 scrap [attachedScrap] tmpDetached no parent}

ExpandableGroup didn't have consistent setting for write and read parcelable

whether the item is null or not, it will all write an int into parcelable, in the read setting, only if the item is not null will call readInt, this will cause error in extended class

protected ExpandableGroup(Parcel in) {
title = in.readString();
if (in.readByte() == 0x01) {
int size = in.readInt();
items = new ArrayList(size);
Class type = (Class) in.readSerializable();
in.readList(items, type.getClassLoader());
} else {
items = null;
}
}

@OverRide
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(title);
if (items == null) {
dest.writeByte((byte) (0x00));
dest.writeInt(0);
} else {
dest.writeByte((byte) (0x01));
dest.writeInt(items.size());
final Class<?> objectsType = items.get(0).getClass();
dest.writeSerializable(objectsType);
dest.writeList(items);
}
}

Performance issue

I have an expandable view in which I have a rotation animation similar to the code samples. On group/parent views which have few child items, there is no problem. When there are larger number of child items (i.e. 39 children in my case), the arrow animation on expanding the group is slow and jumps states. When collapsing, the animation is smooth.

onGroupExpanded bug

when the child list of every group is empty you will get:

java.lang.RuntimeException: Unknown state at com.thoughtbot.expandablerecyclerview.models.ExpandableList.getUnflattenedPosition(ExpandableList.java:80) at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.onGroupExpanded(ExpandableRecyclerViewAdapter.java:119) at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.expandGroup(ExpandCollapseController.java:44) at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.toggleGroup(ExpandCollapseController.java:77) at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.onGroupClick(ExpandableRecyclerViewAdapter.java:151) at com.thoughtbot.expandablerecyclerview.viewholders.GroupViewHolder.onClick(GroupViewHolder.java:28) at android.view.View.performClick(View.java:4881) at android.view.View$PerformClick.run(View.java:19592) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5756) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) at dalvik.system.NativeStart.main(Native Method)

when you try to expand the last group item

#46 Error in readme file

In the following snippet
public class GenreViewHolder extends GroupViewHolder

private TextView genreTitle;

public GenreViewHolder(View itemView) {
super(itemView);
genreTitle = itemView.findViewById(R.id.genre_title);
}

public void setGenreTitle(ExpandableGroup group) {
genreTitle.setText(group.getTitle());
}
}

There is an error at
public class GenreViewHolder extends GroupViewHolder **{**

the opening bracket is missing.

OnClickListener for Groups

I want to have an onclicklistener for a specific group holder. However, when I add an onclicklistener - the previous group holders cannot open.

Problems with saving state

Hello and thanks for this nice library.

However there're several problems:

  1. App crashes in onSaveInstanceState when it tries to cast List to ArrayList<? extends Parcelable> (Android Studio warns about unsafe cast):

@Override public void onSaveInstanceState(Bundle outState) { outState.putParcelableArrayList(CHECKED_STATE_MAP, (ArrayList<? extends Parcelable>) expandableList.groups); super.onSaveInstanceState(outState); }

I tried to fix this by changing List to ArrayList where required, but there's another problem:

  1. State is not saved correctly when app is killed by Android and restored (sometimes there's blank space instead of Groups captions, sometimes children views are of incorrect type)
    I tested multi-type checked recyclerview on Android 5.0.2

Cheers!

Expand one row of list

Hi,
I want expand only one item at a time when I click on another list item previous should automatically collapse.

toggleGroup does not work with groups off the screen

I needed an expandable recyclerview which allows only one group to be expanded at the time. I added the follwoing code to GenreAdapter in your sample project:

`private ExpandableGroup expandedGroup;
setOnGroupExpandCollapseListener(new GroupExpandCollapseListener() {
@OverRide
public void onGroupExpanded(ExpandableGroup group) {
if (expandedGroup != null){
toggleGroup(expandedGroup);
}
expandedGroup = group;
}

  @Override
  public void onGroupCollapsed(ExpandableGroup group) {

  }
});`

It works fine when the previously expanded group is visible on the screen. If the group is off the screen, it will not collapse when calling toggleGroup on it. Unless I am doing something wrong?

Looks like there is an infinite loop:

12-23 11:46:07.395 25187-25187/com.thoughtbot.expandablerecyclerview.sample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.thoughtbot.expandablerecyclerview.sample, PID: 25187
java.lang.StackOverflowError: stack size 8MB
at com.thoughtbot.expandablerecyclerview.models.ExpandableListPosition.getRecycledOrCreate(ExpandableListPosition.java:115)
at com.thoughtbot.expandablerecyclerview.models.ExpandableListPosition.obtain(ExpandableListPosition.java:101)
at com.thoughtbot.expandablerecyclerview.models.ExpandableList.getUnflattenedPosition(ExpandableList.java:73)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.isGroupExpanded(ExpandCollapseController.java:63)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.toggleGroup(ExpandCollapseController.java:85)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.toggleGroup(ExpandableRecyclerViewAdapter.java:172)
at com.thoughtbot.expandablerecyclerview.sample.expand.GenreAdapter$1.onGroupExpanded(GenreAdapter.java:25)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.onGroupExpanded(ExpandableRecyclerViewAdapter.java:121)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.expandGroup(ExpandCollapseController.java:44)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.toggleGroup(ExpandCollapseController.java:89)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.toggleGroup(ExpandableRecyclerViewAdapter.java:172)
at com.thoughtbot.expandablerecyclerview.sample.expand.GenreAdapter$1.onGroupExpanded(GenreAdapter.java:25)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.onGroupExpanded(ExpandableRecyclerViewAdapter.java:121)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.expandGroup(ExpandCollapseController.java:44)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.toggleGroup(ExpandCollapseController.java:89)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.toggleGroup(ExpandableRecyclerViewAdapter.java:172)
at com.thoughtbot.expandablerecyclerview.sample.expand.GenreAdapter$1.onGroupExpanded(GenreAdapter.java:25)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.onGroupExpanded(ExpandableRecyclerViewAdapter.java:121)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.expandGroup(ExpandCollapseController.java:44)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.toggleGroup(ExpandCollapseController.java:89)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.toggleGroup(ExpandableRecyclerViewAdapter.java:172)
at com.thoughtbot.expandablerecyclerview.sample.expand.GenreAdapter$1.onGroupExpanded(GenreAdapter.java:25)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.onGroupExpanded(ExpandableRecyclerViewAdapter.java:121)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.expandGroup(ExpandCollapseController.java:44)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.toggleGroup(ExpandCollapseController.java:89)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.toggleGroup(ExpandableRecyclerViewAdapter.java:172)
at com.thoughtbot.expandablerecyclerview.sample.expand.GenreAdapter$1.onGroupExpanded(GenreAdapter.java:25)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.onGroupExpanded(ExpandableRecyclerViewAdapter.java:121)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.expandGroup(ExpandCollapseController.java:44)
at com.thoughtbot.expandablerecyclerview.ExpandCollapseController.toggleGroup(ExpandCollapseController.java:89)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.toggleGroup(ExpandableRecyclerViewAdapter.java:172)
at com.thoughtbot.expandablerecyclerview.sample.expand.GenreAdapter$1.onGroupExpanded(GenreAdapter.java:25)
at com.thoughtbot.expandablerecyclerview.ExpandableRecyclerViewAdapter.onGroupExpanded(ExpandableRecyclerViewAdapter.java:121)
at com.thoughtbot.expandablerecyclerview.ExpandColl

Expand groups for the first time in onCreateGroupViewHolder()

Is there any idea for expanding groups for the first time launching recyclerview, here is my code but it has problem when I click to collapse the second time, it go into animateExpand() so that my indication arrow not animate the right way:

`@Override
public ChatGroupParentVH onCreateGroupViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(mContext)
.inflate(R.layout.item_header, parent, false);
final ChatGroupParentVH holder = new ChatGroupParentVH(itemView);
new Handler().post(new Runnable() {
@OverRide
public void run() {
holder.expand();
onGroupClick(holder.getAdapterPosition());
}
});
return holder;
}

Thank you!`

Multiple Parent View Types + MultiTypeExpandableRecyclerViewAdapter

When combining these two features the checked positions change unpredictably. I assume it is because for example, lets say that group viewholder of type A stores the information about the children's checked status, but then viewholder of type B doesn't have that information.

Bug in ExpandCollapseController

The method "toggleGroup" in the ExpandCollapseController should return true if the group is expanded, after the toggle, false if the group is now collapsed, but it returns true if the group was expanded before the toggle.

Reload expandable-recycler-view

Hi. Thank for great library!
I implement this expandable-recycler-view for my project, but I don't know how to reload data for it.

You can write a tutorial or sample code?

Thank so much!

App crashes with empty list

When you start an adapter with an empty list like:

ArrayList<GroupObject> groupObjectList = new ArrayList<GroupObject>
MyAdaper adapter = new MyAdapter(groupObjectList)

it crashes, so for example if you are downloading objects and get an empty list you have to do some workarounds to use the adapter. I think this is because the numberOfVisibleItemsInGroup in ExpandableListClass always returns 1 or more, so it´s getting a java.lang.ArrayIndexOutOfBoundsException: length=0; index=0

RecyclerView HEIGHT=WRAP_CONTENT not working (hasFixedSize=true, setNestedScrollingEnabled=false)

I'm trying to implement an expandable list using this library but I need that my RecyclerView working with WRAP_CONTENT (auto update of height attribute).

I used hasFixedSize = true and setNestedScrollingEnabled=false but the LinearLayoutManager doesn't update the RecyclerView size.

My layout hierarchy will be like this:
= FrameLayout
== LinearLayout (Vertical)
=== LinearLayout (Horizontal)
=== RecyclerView
== LinearLayout (Vertical)

There are a custom layout manager to make this work? Thanks

NotifyItemChanged does not call onBindChildViewHolder

I am clicking an item (child), opens a dialog fragment. If CANCEL is pressed then nothing happens and if OK is pressed then the background color of the childview changes.

This is notified through notifyItemChanged(). If the group is collapsed and expanded again then the data change gets reflect but it does not get reflected if the group remains expanded.

For the change to be reflected immediately I have tried the following

  1. DefaultItemAnimator animator = new DefaultItemAnimator() { @Override public boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder) { return true; } }; rvFoodList.setItemAnimator(animator);

  2. ((DefaultItemAnimator) rvFoodList.getItemAnimator()).setSupportsChangeAnimations(false);

  3. rvFoodList.setItemAnimator(null);

  4. ((SimpleItemAnimator) rvFoodList.getItemAnimator()).setSupportsChangeAnimations(true);

None of these work.

Please tell how can I achieve this?

Does it support subgroups and subchildren?

My scenario is as follow:

I have categories and subcategories and there is not limit to the depth of subcategories. (sub sub sub sub ..etc)

I also have products for each categories, these products have sub products, too.

IndexOutOfBoundsException when back button pressed

This error appear even if i unsure the data is not empty or null in the onSaveInstace method
The trace of the Error :

java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.thoughtbot.expandablerecyclerview.models.ExpandableGroup.writeToParcel(ExpandableGroup.java:67)
at android.os.Parcel.writeParcelable(Parcel.java:1357)

Examples with the XML layout files

Hello, the documentation is great for the Java part of the library. Can you provide the layout files in the docs too?
The genre_title, artist_name, list_item_genre, list_item_artist and recycler_view.
How does one talk to the other?
Or if there's another source of documentation with a full look at what the code looks like, can you point me in that direction?

Much appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.