Giter VIP home page Giter VIP logo

expandable-recycler-view's Introduction

Deprecated

This library has been deprecated. Feature development and bug fixing is no longer planned. Feel free to fork for your development.

Replacements

Take a look at Groupie for a more featured implementation. Thoughbot's expandable-recycler-view offers similar api and functionality.

expandable-recycler-view's People

Contributors

alunsford3 avatar bryant1410 avatar cstew avatar dgreenhalgh avatar egor-n avatar jingibus avatar matthew-compton avatar paulirotta avatar rbro112 avatar srodenberg avatar subhrajyotisen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

expandable-recycler-view's Issues

item selection onLongPress?

I'm using Vertical Linear Sample of demo app...
is there any sample on how to (highlight) select items of recyclerView onLongPress?
thanks...

Problems with notifyParentItemRangeInserted

I have a list of 20 parent elements. I load 12 elements and add all at the end of list with addAll. After this call notifyParentItemInserted (20,12) but not so no modifications and log appears an error indexOfBounds. How do I notify you insert several items on my list?

notifyItemRangeRemoved does not work?

So I tried to remove a parent object and it seemed that none of the notify methods worked. notifyDataSetChanged had no effect. notifyItemRemoved and notifyItemRangeRemoved animated the deletion but after that the item stayed where it was. I had to refresh the RecyclerView to know the changes. Did I miss something?

Support notifyDataSetChanged()

Allow the user to change the entire list and notify the adapter that the dataset is changed.

In order to do this we will need to implement and idea of stableId's for the items to preserve expanded state.

notifyDataSetChanged() or similar methods do not work.

When notifyDataSetChanged() or any similar methods are called, the new dataset is not displayed. This is due to the ExpandableRecyclerAdapterHelper not refreshing the data. We should add a method to refresh the data as a whole or at a certain position since I believe we can't directly override notifyDataSetChanged().

notifyItemMoved method

Hey,
im looking for an alternative method for

notifyItemMoved(fromPosition, toPosition);

I tried:

notifyParentItemChanged(fromPosition);
notifyParentItemChanged(toPosition);

But it didnt work. Any solutions?

some times it crashes

Hello. I'm using your adapter in my app (2.0 SNAPSHOT cuz I need isInitiallyExpanded() {
return true; in my case). And some times it crash

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
at android.view.LayoutInflater.from(LayoutInflater.java:219)
at com.stasbar.gabi4k.MyExpandableAdapter.(MyExpandableAdapter.java:42)
at com.stasbar.gabi4k.fragments.CategoryFragment.setList(CategoryFragment.java:49)
at com.stasbar.gabi4k.fragments.presenters.CategoryPresenter$1.success(CategoryPresenter.java:37)
at com.stasbar.gabi4k.fragments.presenters.CategoryPresenter$1.success(CategoryPresenter.java:28)
at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5293)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)

How do I know if parent is expanded

I'm using onExpansionToggled to detect if a parent item is expanded so that I can change something in its view, but when I scroll the recyclerview, the inital view is back again, my question is how can I know that a parent is expanded or not in onBindParentViewHolder so that I can keep its state?

Bring mItemList back

I just updated and had to revert because I need this variable, or any other way to see the complete list of items on the Adapter.

My use case: I have different ViewTypes, more than just Parent and Child, and I am using this library as my BaseAdapter. But without mItemList I can't get the currentItem on the onBindViewHolder, so I can't Override it correctly.

How to open/close programmatically

What is the preferred way to programmatically expand/collapse the views? I see no method to do so and i see no way to retrieve the views to fake click events on them. The overall design is very "closed" so i can't get access to anything that could help me, as far as i discovered this lib.

Specify expanding container in parent

Hi,

currently children are expanded from the bottom. But I would like to specify a container, which expands as I click on the parent. Let's say I have three containers in my parent namely a header, a main container and a footer, which are layouted horizontally. When I click on the parent the main container, which is in the middle should open moving the footer down as well (not overlapping it).

I'd like to hear your thoughts on that idea. Maybe I can help you and implement it myself if you are (too) busy.

Best regards
dasheck

How to use notifyparentitemisterted ?

I am really lost in how to implement notifyparentiteminserted. The way i know is add item to list in adapter then notify the change. I couldnt figure out how to add item to parentlistitem

thanks in advance

Should add `parentObject` as param in `onBindChildViewHolder`

I don't know how to get the parent object in onBindChildViewHolader method. And I think it will be useful when parent object have an effect on child object.

I try to modify the code like this:

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (mExpandableRecyclerAdapterHelper.getHelperItemAtPosition(position) instanceof ParentWrapper) {
        ...
        ...
    } else {

        Object child = mItemList.get(position);
        ParentObject parent = null;
        for (ParentObject p : mParentItemList) {
            if (p.getChildObjectList().contains(child)) {
                parent = p;
                break;
            }
        }

        onBindChildViewHolder((CVH) holder, position, child, parent);
    }
}

Always Expanded ?

Hello. Is it possible to set parent to be always expanded and prevent for collapsing ?

Variable naming cleanup

We've got some inconsistent/bad naming patterns in the library. mHelperItemList could be more descriptive, etc. We should do a pass through the library to clean things up.

Use custom object for parent list?

Hi, currently, parent object must implement ParentObject interface and that interface only accepts a List of Object-s. Is there a way to make custom objects work with it?

Sticky headers

Is there a way to make the headers pinned as in Instgram? I tried to use SuperSLim Library along expandable-recycler-view however it didn't not work

Manifest has application tag

For a library an application tag shouldn't be needed. Also allowBackup=true can mess with projects which set it to false.

Crash Restoring State

From #90:

I used the code you provided in my MyExpandableAdapter.java

Everything works fine but after i browse the application, change the device configuration to landscape and switch to another application there was an error occurred related to
ArrayIndexOutOfBound in the mExpandableAdapter.onRestoreInstanceState(savedInstanceState);

Caused by: java.lang.IndexOutOfBoundsException: Invalid index 20, size is 20
at com.bignerdranch.expandablerecyclerview.Adapter.ExpandableRecyclerAdapter.getListItem(ExpandableRecyclerAdapter.java:490)
at com.bignerdranch.expandablerecyclerview.Adapter.ExpandableRecyclerAdapter.onRestoreInstanceState(ExpandableRecyclerAdapter.java:445)
at com.eyey.android.eyeynews.ui.MainActivity.onRestoreInstanceState(MainActivity.java:87)

Expanded state lost in the Criminal Intent sample app

Noticed that in the Criminal Intent app that the expansion state doesn't persist through rotation. Thought the adapter didn't support it, but then realized it does, but the the state wasn't restored by the fragment.

Filed #37 for a possible fix.

Thanks for creating this library!

ChildItem causes problems

Hello,
I'm almost done. There is one last problem:
How to remove an ChildItem that has no parent?
When i drag a child around it can temporary inserted everywhere. It can be that it has no parentitem. Then this childitem shall be removed and added to the nearest parent item.
I call notifyItemMoved every time a item gets moved. For the parent the drag&drop behaviour works fantastic. Also swiping is implemented and causes no problems. Only dragging childitems causes problems.

setExpanded not working

Initializing the parent ViewHolder with setExpanded wont work.

@Override public void onBindParentViewHolder(OTDFavoriteBusRouteParentExpandableViewHolder otdParent, int i, Object o) { OTDExpandableParent parent = (OTDExpandableParent) o; parent.setExpanded(true); otdParent.parentTitle.setText(parent.getParentTitle()); }

And isInitiallyExpanded does not exist.

Using 1.0.3

Prepare dev branch

As we start work on 2.1.0, we'll want a dev branch so that we can keep working on 2.0.X if necessary. This story includes the following tasks:

  • Create dev branch
  • Update project setup instructions so that contributors know which branch to develop against

notifyChildItemChanged

notifyChildItemChanged causes notifyItemChanged. I would like to have a notifyDataSetChanged method which cause a onItemsChanged for the child. snx)

use fragment as childview

can childview be a fragment ,i want reuse it in other places, it seems the fragment won`t display nomaly

Implement Additional notifyDatasetChanged methods

Currently ExpandableRecyclerView implements

 // Parent Changes
 notifyParentItemInserted(int parentPosition)}
 notifyParentItemRemoved(int parentPosition)}
 notifyParentItemChanged(int parentPosition)}
 notifyParentItemRangeInserted(int parentPositionStart, int itemCount)}
 // Child Changes
 notifyChildItemInserted(int parentPosition, int childPosition)}
 notifyChildItemRemoved(int parentPosition, int childPosition)}
 notifyChildItemChanged(int parentPosition, int childPosition)}

Would be nice to have:

 notifyParentItemRangeRemoved(int parentPositionStart, int itemCount)}
 notifyParentItemRangeChanged(int parentPositionStart, int itemCount)}

 notifyChildItemRangeRemoved(int parentPosition, int childPositionStart, int itemCount)}
 notifyChildItemRangeInserted(int parentPosition, int childPositionStart, int itemCount)}
 notifyChildItemRangeChanged(int parentPosition, int childPositionStart, int itemCount)}

notifyParentItemMoved(int parentFromPosition, int parentToPosition)
notifyChildItemMoved(int parentPosition, int childFromPosition, int childToPosition)

Feedback Adapter Expand

Hey,
for my drag and swipe behaviour I have to know in the ADAPTER class which parent-items are expanded. So i can count the position of the moved/swiped item and whether its a parent or child - item. Have you an idea?

Add a way to iterate over all items

Right now items are removed from the list when it's collapsing. It would be nice if you would add a way to iterate over all items (parents and their children) no matter if the list is expanded or collapsed.
My usecase is this:
I'm implementing single selection for nav drawer. Everything works ok when list is expanded. But when I do the following:

  1. expand some item
  2. select subitem
  3. collapse previously expanded item
  4. select some parent item
    Parent item gets selected but I have no way to inform collapsed subitem that it should unselect itself.

ChildItem

How to get value of ChildItem onItem ClickListener ?

Expand and collapse list items by range

In 2.0.0, we can expand/collapse individual list items or we can expand/collapse the entire list. We should add the ability to expand/collapse a group a list items by providing a range of indices from the list of parents.

Way to prevent multiple activities being created when double tapping the childview?

Is there a way to prevent duplicate activities being made when the childview is double tapped? I fixed it in other recyclerviews by adding a boolean canStart thats set false when an Activity is created, and then set true in the onResume of the activity with the recyclerview. But since the listener is assigned in the adapter, this method is not possible. Does anyone have any suggestions?

setParentListItemExpandCollapseListener causes Recyclerview to not expand collapse

I am trying to collapse all views but the current one so that only one parents children are visible at a time. Somehow you guys removed the setParentItemClickListener from version 1.0.3 but added the setParentListItemExpandCollapseListener as some kind of replacement i guess. So the collapsing is working but after adding the ExpandCollapseListener the view did not expand (and therefore) not collapse anymore

if you comment in the section "VERSION1" or "VERSION2" with an ordinary click listener the expansion did not work anymore

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bignerdranch.expandablerecyclerview.Adapter.ExpandableRecyclerAdapter;
import com.bignerdranch.expandablerecyclerview.Model.ParentListItem;
import com.bignerdranch.expandablerecyclerview.ViewHolder.ChildViewHolder;
import com.bignerdranch.expandablerecyclerview.ViewHolder.ParentViewHolder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class CTCMainActivity extends AppCompatActivity {

    private RecyclerView mRecyclerView;
    private LinearLayoutManager mLayoutManager;
    private CTCMainMenuAdapter mCtcMenuAdapter;


    public class MenuElement implements ParentListItem {

        public String menuName;

        public List<MenuChild> mChildItemList;

        public MenuElement(String menuName) {
            this.menuName = menuName;

            mChildItemList = new ArrayList<>();
        }

        public MenuElement addChild(String childText) {
            mChildItemList.add(new MenuChild(childText));
            return this;
        }

        @Override
        public List<MenuChild> getChildItemList() {
            return mChildItemList;
        }

        @Override
        public boolean isInitiallyExpanded() {
            return false;
        }

        public class MenuChild {

            public MenuChild(String childText) {
                this.childText = childText;
            }

            public String childText;

        }
    }

    private class EntryHeaderViewHolder extends ParentViewHolder {

        public TextView textView;

        public EntryHeaderViewHolder(View itemView) {
            super(itemView);

            this.textView = (TextView)itemView.findViewById(R.id.ctc_menu_head_text);
        }
    }

    private class EntryBodyViewHolder extends ChildViewHolder{

        public TextView textView;

        public EntryBodyViewHolder(View itemView) {
            super(itemView);

            this.textView = (TextView)itemView.findViewById(R.id.ctc_menu_body_text);
        }
    }



    public class CTCMainMenuAdapter extends ExpandableRecyclerAdapter<EntryHeaderViewHolder, EntryBodyViewHolder> {


        public CTCMainMenuAdapter(List<? extends ParentListItem> parentItemList) {
            super(parentItemList);
        }

        @Override
        public EntryHeaderViewHolder onCreateParentViewHolder(ViewGroup viewGroup) {
            final View header = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.ctc_menu_head, viewGroup, false);
            return new EntryHeaderViewHolder(header);
        }

        @Override
        public EntryBodyViewHolder onCreateChildViewHolder(ViewGroup viewGroup) {
            final View body = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.ctc_menu_body, viewGroup, false);
            return new EntryBodyViewHolder(body);
        }

        @Override
        public void onBindParentViewHolder(EntryHeaderViewHolder entryHeaderViewHolder, int i, ParentListItem parentListItem) {
            final MenuElement menuElement = (MenuElement) parentListItem;
            entryHeaderViewHolder.textView.setText(menuElement.menuName);

////          VERSION1
//            entryHeaderViewHolder.setParentListItemExpandCollapseListener(new ParentViewHolder.ParentListItemExpandCollapseListener() {
//                @Override
//                public void onParentListItemExpanded(int i) {
//
//                    System.out.println("expand: " + i);
//                    mCtcMenuAdapter.collapseAllParents();
//                }
//
//                @Override
//                public void onParentListItemCollapsed(int i) {
//
//                    System.out.println("collapsed:" + i);
//
//                }
//            });


////          VERSION2
//            entryHeaderViewHolder.textView.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                    System.out.println("expand: " + i);
//                    mCtcMenuAdapter.collapseAllParents();
//                }
//            });


        }

        @Override
        public void onBindChildViewHolder(EntryBodyViewHolder entryBodyViewHolder, int i, Object object) {
            MenuElement.MenuChild menuChild = (MenuElement.MenuChild) object;
            entryBodyViewHolder.textView.setText(menuChild.childText);
        }


    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ctcmain);

        mRecyclerView = (RecyclerView) findViewById(R.id.ctcmain_recyclerView);
        mLayoutManager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(mLayoutManager);

        List<MenuElement> menuItems = Arrays.asList(
                new MenuElement("Menu1"),

                new MenuElement("Menu2")
                        .addChild("submenu1")
                        .addChild("submenu2")
                        .addChild("submenu3")
                        .addChild("submenu4"),

                new MenuElement("Menu3")
                        .addChild("submenu1")
                        .addChild("submenu2")
                        .addChild("submenu3"),

                new MenuElement("Menu4")
                        .addChild("submenu1")
                        .addChild("submenu2")
                        .addChild("submenu3")
                        .addChild("submenu4")
                        .addChild("submenu5"));

        mCtcMenuAdapter = new CTCMainMenuAdapter(menuItems);
        mRecyclerView.setAdapter(mCtcMenuAdapter);


    }

}

Header Parent View

I believe giving the developer the ability to create a header view for the Parent View Holder would be an awesome feature. The library is a breeze to use and with this feature implemented it would be the icing on the cake.

Showing child view

Hi

I have one question, how i can display sometimes only child view? (like ParentItem, ParentItem, ChildItem, ParentItem...).
I try in ItemCellParentViewHolder return child view but this way i make a lot of problems.

Is it possible?

Ty

Luka

Improved expand/collapse performance

When expanding/collapsing a group of list items, notifyDataSetChanged is called multiple times. It would perform better if notifyDataSetChanged was just called once after all of the items were expanded/collapsed.

notifyParentItemChanged (2.0.2)

A problem occurred when updated to 2.0.2

I am using ExpandCollapseListener and when onListItemExpandedis is called I update one parent item and call notifyParentItemChanged.

When the item is expanded appear two child items. Sometimes three.

In version 2.0.1 this does not happen

onExpansionCollapsed being called with wrong boolean

Missing methods

Hey guys,
I really like your lib but ive got some questions. After following your example (works well btw) i noticed some methods are missing:
Here is what i got:

    recyclerView = (RecyclerView) findViewById(R.id.expListView);
    recyclerView.setLayoutManager(new LinearLayoutManager(TestActivity.this));
    ExpandableAdapter expAdapter = new ExpandableAdapter(this, generateCrimes());

<//Is missing

    mCrimeExpandableAdapter.setCustomParentAnimationViewId
    (R.id.parent_list_item_expand_arrow);
    mCrimeExpandableAdapter.setParentClickableViewAnimationDefaultDuration();
    mCrimeExpandableAdapter.setParentAndIconExpandOnClick(true);

//>

    recyclerView.setAdapter(expAdapter);

Furthermore i ask myself if its possible to add drag and swipe behaviour to the list with Touchhelper. Has someone handled that already. I used Touchhelper for my non-expandable recyclerview where it works well.
Thx for help!

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.