{"action":"created","issue":{"url":"https://api.github.com/repos/bignerdranch/expandable-recycler-view/issues/247","repository_url":"https://api.github.com/repos/bignerdranch/expandable-recycler-view","labels_url":"https://api.github.com/repos/bignerdranch/expandable-recycler-view/issues/247/labels{/name}","comments_url":"https://api.github.com/repos/bignerdranch/expandable-recycler-view/issues/247/comments","events_url":"https://api.github.com/repos/bignerdranch/expandable-recycler-view/issues/247/events","html_url":"https://github.com/bignerdranch/expandable-recycler-view/issues/247","id":174107077,"number":247,"title":"removing child item ","user":{"login":"makleyston","id":19152738,"avatar_url":"https://avatars.githubusercontent.com/u/19152738?v=3","gravatar_id":"","url":"https://api.github.com/users/makleyston","html_url":"https://github.com/makleyston","followers_url":"https://api.github.com/users/makleyston/followers","following_url":"https://api.github.com/users/makleyston/following{/other_user}","gists_url":"https://api.github.com/users/makleyston/gists{/gist_id}","starred_url":"https://api.github.com/users/makleyston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makleyston/subscriptions","organizations_url":"https://api.github.com/users/makleyston/orgs","repos_url":"https://api.github.com/users/makleyston/repos","events_url":"https://api.github.com/users/makleyston/events{/privacy}","received_events_url":"https://api.github.com/users/makleyston/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bignerdranch/expandable-recycler-view/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-30T19:42:54Z","updated_at":"2016-09-28T15:55:15Z","closed_at":null,"body":"Hello, I'm doing the expandable list with a button in a child that when clicked, the child associated item should be removed from the parent. However, when I do the tests I realize that does not work correctly because when you click the last parent application is closed. I would like to understand why, therefore, I urge colleagues to show me some solution or some link. Here is a piece of code for consideration of you.\r\n```java\r\n    @Override\r\n    public void onBindChildViewHolder(final IngredientViewHolder childViewHolder, final int position, final Object childListItem) {\r\n        Ingredient ingredient = (Ingredient) childListItem;\r\n        childViewHolder.btn_del.setOnClickListener(new View.OnClickListener() {\r\n            @Override\r\n            public void onClick(View view) {\r\n                mItemList.remove(childListItem);\r\n                notifyDataSetChanged();\r\n            }\r\n        });\r\n        childViewHolder.bind(ingredient);\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/bignerdranch/expandable-recycler-view/issues/comments/250210797","html_url":"https://github.com/bignerdranch/expandable-recycler-view/issues/247#issuecomment-250210797","issue_url":"https://api.github.com/repos/bignerdranch/expandable-recycler-view/issues/247","id":250210797,"user":{"login":"avtseben","id":16372490,"avatar_url":"https://avatars.githubusercontent.com/u/16372490?v=3","gravatar_id":"","url":"https://api.github.com/users/avtseben","html_url":"https://github.com/avtseben","followers_url":"https://api.github.com/users/avtseben/followers","following_url":"https://api.github.com/users/avtseben/following{/other_user}","gists_url":"https://api.github.com/users/avtseben/gists{/gist_id}","starred_url":"https://api.github.com/users/avtseben/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avtseben/subscriptions","organizations_url":"https://api.github.com/users/avtseben/orgs","repos_url":"https://api.github.com/users/avtseben/repos","events_url":"https://api.github.com/users/avtseben/events{/privacy}","received_events_url":"https://api.github.com/users/avtseben/received_events","type":"User","site_admin":false},"created_at":"2016-09-28T15:55:15Z","updated_at":"2016-09-28T15:55:15Z","body":"In my Shopping List application i use ExpandableRecyclerView to group Products by Category.\r\nUse swipe left to delete child (Product) from RecyclerView. And when swipe happens you get only\r\n(int position) of your item, but you don't know parentPosition and childPosition in your adapter data to \r\nremove childItem correctly. I solve it by this method in Adapter class:\r\n```\r\n   public void removeChildItem(int position){\r\n        int childPosition = 0;\r\n        int parentPosition = 0;\r\n        boolean parentFound = false;\r\n        for(int i = position; i > 0; i--) {\r\n            if(mItemList.get(i).getClass().equals(ParentWrapper.class)) {\r\n                if(!parentFound){\r\n                    parentFound = true;\r\n                }\r\n                parentPosition++;\r\n            } else if(!parentFound) {\r\n                childPosition++;\r\n            }\r\n        }\r\n        childPosition--;\r\n        ParentItem p = (ParentItem)getParentItemList().get(parentPosition);\r\n        List<ProductInstance> childList = p.getChildItemList();\r\n        childList.remove(childPosition);\r\n        notifyChildItemRemoved(parentPosition,childPosition);\r\n    }\r\n```"}}
{"actor":{"display_login":"avtseben"}}