{"action":"created","issue":{"url":"https://api.github.com/repos/h6ah4i/android-advancedrecyclerview/issues/76","labels_url":"https://api.github.com/repos/h6ah4i/android-advancedrecyclerview/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/h6ah4i/android-advancedrecyclerview/issues/76/comments","events_url":"https://api.github.com/repos/h6ah4i/android-advancedrecyclerview/issues/76/events","html_url":"https://github.com/h6ah4i/android-advancedrecyclerview/issues/76","id":99110198,"number":76,"title":"How to notifyDataSetChanged when delete a group?","user":{"login":"wliu6v","id":5987831,"avatar_url":"https://avatars.githubusercontent.com/u/5987831?v=3","gravatar_id":"","url":"https://api.github.com/users/wliu6v","html_url":"https://github.com/wliu6v","followers_url":"https://api.github.com/users/wliu6v/followers","following_url":"https://api.github.com/users/wliu6v/following{/other_user}","gists_url":"https://api.github.com/users/wliu6v/gists{/gist_id}","starred_url":"https://api.github.com/users/wliu6v/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wliu6v/subscriptions","organizations_url":"https://api.github.com/users/wliu6v/orgs","repos_url":"https://api.github.com/users/wliu6v/repos","events_url":"https://api.github.com/users/wliu6v/events{/privacy}","received_events_url":"https://api.github.com/users/wliu6v/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/h6ah4i/android-advancedrecyclerview/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-08-05T03:36:30Z","updated_at":"2015-08-25T07:33:05Z","closed_at":null,"body":"Hi, @h6ah4i \r\n\r\nI'm trying to remove a group in a ExpandableDraggableItemAdapter. But after remove, the items belows the removed item won't refresh.\r\n\r\nHere's my code \r\n\r\n\tpublic Object removeItem(int groupPos) {\r\n\t\tmExpandManager.notifyGroupItemRemoved(groupPos);\r\n\t\tObject obj = mDataList.remove(groupPos);\r\n\t\treturn obj;\r\n\t}\r\n\r\n\r\n----\r\n\r\nAnd there's another implementation. I try to refresh all the item below the deleted item.\r\n\r\nObviously, The code is ugly. And I want to know how to make it better.\r\n\r\n\tpublic Object removeItem2(int groupPos) {\r\n\t\tlong packedPos = RecyclerViewExpandableItemManager\r\n\t\t\t\t.getPackedPositionForGroup(groupPos);\r\n\t\tint realPos = mExpandManager.getFlatPosition(packedPos);\r\n\r\n\t\tnotifyItemRemoved(realPos);\r\n\t\tnotifyItemRangeChanged(realPos, 999);  // 999 because I don't know how to getItemCount();\r\n\r\n\t\tObject obj = mDataList.remove(groupPos);\r\n\t\treturn obj;\r\n\t}"},"comment":{"url":"https://api.github.com/repos/h6ah4i/android-advancedrecyclerview/issues/comments/134510664","html_url":"https://github.com/h6ah4i/android-advancedrecyclerview/issues/76#issuecomment-134510664","issue_url":"https://api.github.com/repos/h6ah4i/android-advancedrecyclerview/issues/76","id":134510664,"user":{"login":"h6ah4i","id":2552365,"avatar_url":"https://avatars.githubusercontent.com/u/2552365?v=3","gravatar_id":"","url":"https://api.github.com/users/h6ah4i","html_url":"https://github.com/h6ah4i","followers_url":"https://api.github.com/users/h6ah4i/followers","following_url":"https://api.github.com/users/h6ah4i/following{/other_user}","gists_url":"https://api.github.com/users/h6ah4i/gists{/gist_id}","starred_url":"https://api.github.com/users/h6ah4i/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/h6ah4i/subscriptions","organizations_url":"https://api.github.com/users/h6ah4i/orgs","repos_url":"https://api.github.com/users/h6ah4i/repos","events_url":"https://api.github.com/users/h6ah4i/events{/privacy}","received_events_url":"https://api.github.com/users/h6ah4i/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T07:33:05Z","updated_at":"2015-08-25T07:33:05Z","body":"@wliu6v Try the following code. My old implementations can cause a crash when you click the list items frequently.\r\n\r\n```java\r\n\tpublic void removeItem3(View v, int groupPos) {\r\n\t\tRecyclerView.ViewHolder vh = RecyclerViewAdapterUtils.getViewHolder(v);\r\n\r\n\t\tint flatPosition = vh.getAdapterPosition();\r\n\r\n\t\tif (flatPosition == RecyclerView.NO_POSITION) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tlong expandablePosition = mExpandableManager.getExpandablePosition(flatPosition);\r\n\t\tint groupPos2 = RecyclerViewExpandableItemManager.getPackedPositionGroup(expandablePosition);\r\n\r\n\t\tif (groupPos != groupPos2) {\r\n\t\t\tString msg = \"groupPos: \" + groupPos + \" / groupPos2: \" + groupPos2;\r\n\t\t\tToast.makeText(v.getContext().getApplicationContext(), msg, Toast.LENGTH_SHORT).show();\r\n\t\t}\r\n\r\n\t\tmData.remove(groupPos2);\r\n\t\tmExpandableManager.notifyGroupItemRemoved(groupPos2);\r\n\t}\r\n```"}}