{"action":"opened","issue":{"url":"https://api.github.com/repos/CymChad/BaseRecyclerViewAdapterHelper/issues/2164","repository_url":"https://api.github.com/repos/CymChad/BaseRecyclerViewAdapterHelper","labels_url":"https://api.github.com/repos/CymChad/BaseRecyclerViewAdapterHelper/issues/2164/labels{/name}","comments_url":"https://api.github.com/repos/CymChad/BaseRecyclerViewAdapterHelper/issues/2164/comments","events_url":"https://api.github.com/repos/CymChad/BaseRecyclerViewAdapterHelper/issues/2164/events","html_url":"https://github.com/CymChad/BaseRecyclerViewAdapterHelper/issues/2164","id":315702078,"number":2164,"title":".remove(position)这个方法会卡顿","user":{"login":"Zeoye","id":13866019,"avatar_url":"https://avatars3.githubusercontent.com/u/13866019?v=4","gravatar_id":"","url":"https://api.github.com/users/Zeoye","html_url":"https://github.com/Zeoye","followers_url":"https://api.github.com/users/Zeoye/followers","following_url":"https://api.github.com/users/Zeoye/following{/other_user}","gists_url":"https://api.github.com/users/Zeoye/gists{/gist_id}","starred_url":"https://api.github.com/users/Zeoye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zeoye/subscriptions","organizations_url":"https://api.github.com/users/Zeoye/orgs","repos_url":"https://api.github.com/users/Zeoye/repos","events_url":"https://api.github.com/users/Zeoye/events{/privacy}","received_events_url":"https://api.github.com/users/Zeoye/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-19T02:07:38Z","updated_at":"2018-04-19T02:07:38Z","closed_at":null,"author_association":"NONE","body":"使用的版本：2.9.30   \r\n使用场景：点击单条数据时，从列表中移除这条数据\r\n问题描述：移除数据时会出现明显卡顿\r\n使用的方法：adapter.remove(position)\r\n\r\n/**\r\n     * remove the item associated with the specified position of adapter\r\n     *\r\n     * @param position\r\n     */\r\n    public void remove(@IntRange(from = 0) int position) {\r\n        mData.remove(position);\r\n        int internalPosition = position + getHeaderLayoutCount();\r\n        notifyItemRemoved(internalPosition);\r\n        compatibilityDataSizeChanged(0);\r\n        notifyItemRangeChanged(internalPosition, mData.size() - internalPosition);\r\n    }\r\n使用这个方法移除数据，当数据较多时，会明显卡顿，大概几十条就会卡的明显了，特别是移除顶部的数据时\r\n\r\n原因是这个方法刷新多余的次数了notifyItemRangeChanged(internalPosition, mData.size() - internalPosition);\r\n\r\n我暂时的解决方式是先在适配器里吗添加了个移除数据的方法\r\n    public void RemoveDate(int position){\r\n        mData.remove(position);\r\n    }\r\n\r\n然后移除的时候使用下面步骤\r\nadapter.RemoveDate(position);\r\nadapter.notifyItemRemoved(position);\r\nadapter.notifyItemRangeChanged(position,1);\r\n\r\n\r\n这样移除数据就完全不卡顿了（是在适配器的点击事件里执行的）\r\n"}}
{"actor":{"display_login":"Zeoye"}}