{"action":"created","comment":{"url":"https://api.github.com/repos/airbnb/epoxy/pulls/comments/225611864","pull_request_review_id":165249951,"id":225611864,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNTYxMTg2NA==","diff_hunk":"@@ -74,47 +92,114 @@ public void detach(@NonNull RecyclerView recyclerView) {\n     attachedRecyclerView = null;\n   }\n \n-  private void processChildren() {\n+  private void processChangeEvent(String debug) {\n+    processChildren(null, debug);\n+  }\n+\n+  private void processChangeEventWithDetachedView(@Nullable View detachedView, String debug) {\n+    processChildren(detachedView, debug);\n+  }\n+\n+  private void processChildren(@Nullable View detachedView, String debug) {\n+\n+    // On every every events lookup for a new adapter\n+    processNewAdapterIfNecessary();\n+\n+    // Process the detached child if any\n+    if (detachedView != null) {\n+      processChild(detachedView, true, debug);\n+    }\n+\n+    // Process all attached children\n     final RecyclerView recyclerView = attachedRecyclerView;\n     if (recyclerView != null) {\n       for (int i = 0; i < recyclerView.getChildCount(); i++) {\n         final View child = recyclerView.getChildAt(i);\n-        if (child != null) {\n-          processChild(child);\n+        if (child != null && child != detachedView) {\n+          // Is some case the detached child is still in the recycler view. Don't process it as it\n+          // was already processed.\n+          processChild(child, false, debug);\n         }\n       }\n     }\n   }\n \n-  private void processChild(@NonNull View child) {\n-    processChild(child, false);\n+  /**\n+   * If there is a new adapter on the attached RecyclerView it will resister the data observer and\n+   * clear the current visibility states\n+   */\n+  private void processNewAdapterIfNecessary() {\n+    if (attachedRecyclerView != null && attachedRecyclerView.getAdapter() != null) {\n+      if (lastAdapterSeen != attachedRecyclerView.getAdapter()) {\n+        if (lastAdapterSeen != null) {\n+          // Unregister the old adapter\n+          lastAdapterSeen.unregisterAdapterDataObserver(this.observer);\n+        }\n+        // Register the new adapter\n+        attachedRecyclerView.getAdapter().registerAdapterDataObserver(this.observer);\n+        lastAdapterSeen = attachedRecyclerView.getAdapter();\n+        // Clear our visibility items\n+        visibilityIdToItemMap.clear();","path":"epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java","position":null,"original_position":119,"commit_id":"bd9fa23c55b2ec99217c54a8f026936121e41086","original_commit_id":"d913fc1961d1f54ba3909999f95a5fe716e3e409","user":{"login":"eboudrant","id":773377,"node_id":"MDQ6VXNlcjc3MzM3Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/773377?v=4","gravatar_id":"","url":"https://api.github.com/users/eboudrant","html_url":"https://github.com/eboudrant","followers_url":"https://api.github.com/users/eboudrant/followers","following_url":"https://api.github.com/users/eboudrant/following{/other_user}","gists_url":"https://api.github.com/users/eboudrant/gists{/gist_id}","starred_url":"https://api.github.com/users/eboudrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eboudrant/subscriptions","organizations_url":"https://api.github.com/users/eboudrant/orgs","repos_url":"https://api.github.com/users/eboudrant/repos","events_url":"https://api.github.com/users/eboudrant/events{/privacy}","received_events_url":"https://api.github.com/users/eboudrant/received_events","type":"User","site_admin":false},"body":"Ok, make sense. I added `clearVisibilityStates()`.","created_at":"2018-10-16T16:19:42Z","updated_at":"2018-10-16T16:19:42Z","html_url":"https://github.com/airbnb/epoxy/pull/575#discussion_r225611864","pull_request_url":"https://api.github.com/repos/airbnb/epoxy/pulls/575","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/airbnb/epoxy/pulls/comments/225611864"},"html":{"href":"https://github.com/airbnb/epoxy/pull/575#discussion_r225611864"},"pull_request":{"href":"https://api.github.com/repos/airbnb/epoxy/pulls/575"}},"in_reply_to_id":225345594},"pull_request":{"url":"https://api.github.com/repos/airbnb/epoxy/pulls/575","id":223054565,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzMDU0NTY1","html_url":"https://github.com/airbnb/epoxy/pull/575","diff_url":"https://github.com/airbnb/epoxy/pull/575.diff","patch_url":"https://github.com/airbnb/epoxy/pull/575.patch","issue_url":"https://api.github.com/repos/airbnb/epoxy/issues/575","number":575,"state":"open","locked":false,"title":"Follow-up for visibility tracking : adapter data changes","user":{"login":"eboudrant","id":773377,"node_id":"MDQ6VXNlcjc3MzM3Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/773377?v=4","gravatar_id":"","url":"https://api.github.com/users/eboudrant","html_url":"https://github.com/eboudrant","followers_url":"https://api.github.com/users/eboudrant/followers","following_url":"https://api.github.com/users/eboudrant/following{/other_user}","gists_url":"https://api.github.com/users/eboudrant/gists{/gist_id}","starred_url":"https://api.github.com/users/eboudrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eboudrant/subscriptions","organizations_url":"https://api.github.com/users/eboudrant/orgs","repos_url":"https://api.github.com/users/eboudrant/repos","events_url":"https://api.github.com/users/eboudrant/events{/privacy}","received_events_url":"https://api.github.com/users/eboudrant/received_events","type":"User","site_admin":false},"body":"Follow-up for visibility tracking (#560). This fix the case where item get added, removed or moved from the adapter. For doing it it require to add a `AdapterDataObserver` on the current adapter. The idea is to shift the adapter position maintained in the visibility item.\r\n\r\nThis chance activate `testInsertData` / `testDeleteData` tests  and add  a new test : `testMoveData`.","created_at":"2018-10-15T21:52:26Z","updated_at":"2018-10-16T16:19:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5035e7ca6da3c9e31a47ffb4d56e698e7379fce0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/airbnb/epoxy/pulls/575/commits","review_comments_url":"https://api.github.com/repos/airbnb/epoxy/pulls/575/comments","review_comment_url":"https://api.github.com/repos/airbnb/epoxy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/airbnb/epoxy/issues/575/comments","statuses_url":"https://api.github.com/repos/airbnb/epoxy/statuses/bd9fa23c55b2ec99217c54a8f026936121e41086","head":{"label":"eboudrant:feature/visibility_fix_changed_from_adapter","ref":"feature/visibility_fix_changed_from_adapter","sha":"bd9fa23c55b2ec99217c54a8f026936121e41086","user":{"login":"eboudrant","id":773377,"node_id":"MDQ6VXNlcjc3MzM3Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/773377?v=4","gravatar_id":"","url":"https://api.github.com/users/eboudrant","html_url":"https://github.com/eboudrant","followers_url":"https://api.github.com/users/eboudrant/followers","following_url":"https://api.github.com/users/eboudrant/following{/other_user}","gists_url":"https://api.github.com/users/eboudrant/gists{/gist_id}","starred_url":"https://api.github.com/users/eboudrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eboudrant/subscriptions","organizations_url":"https://api.github.com/users/eboudrant/orgs","repos_url":"https://api.github.com/users/eboudrant/repos","events_url":"https://api.github.com/users/eboudrant/events{/privacy}","received_events_url":"https://api.github.com/users/eboudrant/received_events","type":"User","site_admin":false},"repo":{"id":150630781,"node_id":"MDEwOlJlcG9zaXRvcnkxNTA2MzA3ODE=","name":"epoxy","full_name":"eboudrant/epoxy","private":false,"owner":{"login":"eboudrant","id":773377,"node_id":"MDQ6VXNlcjc3MzM3Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/773377?v=4","gravatar_id":"","url":"https://api.github.com/users/eboudrant","html_url":"https://github.com/eboudrant","followers_url":"https://api.github.com/users/eboudrant/followers","following_url":"https://api.github.com/users/eboudrant/following{/other_user}","gists_url":"https://api.github.com/users/eboudrant/gists{/gist_id}","starred_url":"https://api.github.com/users/eboudrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eboudrant/subscriptions","organizations_url":"https://api.github.com/users/eboudrant/orgs","repos_url":"https://api.github.com/users/eboudrant/repos","events_url":"https://api.github.com/users/eboudrant/events{/privacy}","received_events_url":"https://api.github.com/users/eboudrant/received_events","type":"User","site_admin":false},"html_url":"https://github.com/eboudrant/epoxy","description":"Epoxy is an Android library for building complex screens in a RecyclerView","fork":true,"url":"https://api.github.com/repos/eboudrant/epoxy","forks_url":"https://api.github.com/repos/eboudrant/epoxy/forks","keys_url":"https://api.github.com/repos/eboudrant/epoxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eboudrant/epoxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eboudrant/epoxy/teams","hooks_url":"https://api.github.com/repos/eboudrant/epoxy/hooks","issue_events_url":"https://api.github.com/repos/eboudrant/epoxy/issues/events{/number}","events_url":"https://api.github.com/repos/eboudrant/epoxy/events","assignees_url":"https://api.github.com/repos/eboudrant/epoxy/assignees{/user}","branches_url":"https://api.github.com/repos/eboudrant/epoxy/branches{/branch}","tags_url":"https://api.github.com/repos/eboudrant/epoxy/tags","blobs_url":"https://api.github.com/repos/eboudrant/epoxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eboudrant/epoxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eboudrant/epoxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/eboudrant/epoxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eboudrant/epoxy/statuses/{sha}","languages_url":"https://api.github.com/repos/eboudrant/epoxy/languages","stargazers_url":"https://api.github.com/repos/eboudrant/epoxy/stargazers","contributors_url":"https://api.github.com/repos/eboudrant/epoxy/contributors","subscribers_url":"https://api.github.com/repos/eboudrant/epoxy/subscribers","subscription_url":"https://api.github.com/repos/eboudrant/epoxy/subscription","commits_url":"https://api.github.com/repos/eboudrant/epoxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/eboudrant/epoxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/eboudrant/epoxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/eboudrant/epoxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/eboudrant/epoxy/contents/{+path}","compare_url":"https://api.github.com/repos/eboudrant/epoxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eboudrant/epoxy/merges","archive_url":"https://api.github.com/repos/eboudrant/epoxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eboudrant/epoxy/downloads","issues_url":"https://api.github.com/repos/eboudrant/epoxy/issues{/number}","pulls_url":"https://api.github.com/repos/eboudrant/epoxy/pulls{/number}","milestones_url":"https://api.github.com/repos/eboudrant/epoxy/milestones{/number}","notifications_url":"https://api.github.com/repos/eboudrant/epoxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eboudrant/epoxy/labels{/name}","releases_url":"https://api.github.com/repos/eboudrant/epoxy/releases{/id}","deployments_url":"https://api.github.com/repos/eboudrant/epoxy/deployments","created_at":"2018-09-27T18:27:30Z","updated_at":"2018-10-12T22:07:03Z","pushed_at":"2018-10-16T16:19:38Z","git_url":"git://github.com/eboudrant/epoxy.git","ssh_url":"git@github.com:eboudrant/epoxy.git","clone_url":"https://github.com/eboudrant/epoxy.git","svn_url":"https://github.com/eboudrant/epoxy","homepage":"https://goo.gl/eIK82p","size":5477,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"airbnb:master","ref":"master","sha":"bb634e8db7e2dc340b99e72f6df6fa607dfd963d","user":{"login":"airbnb","id":698437,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5ODQzNw==","avatar_url":"https://avatars3.githubusercontent.com/u/698437?v=4","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"repo":{"id":65245890,"node_id":"MDEwOlJlcG9zaXRvcnk2NTI0NTg5MA==","name":"epoxy","full_name":"airbnb/epoxy","private":false,"owner":{"login":"airbnb","id":698437,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5ODQzNw==","avatar_url":"https://avatars3.githubusercontent.com/u/698437?v=4","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/airbnb/epoxy","description":"Epoxy is an Android library for building complex screens in a RecyclerView","fork":false,"url":"https://api.github.com/repos/airbnb/epoxy","forks_url":"https://api.github.com/repos/airbnb/epoxy/forks","keys_url":"https://api.github.com/repos/airbnb/epoxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/airbnb/epoxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/airbnb/epoxy/teams","hooks_url":"https://api.github.com/repos/airbnb/epoxy/hooks","issue_events_url":"https://api.github.com/repos/airbnb/epoxy/issues/events{/number}","events_url":"https://api.github.com/repos/airbnb/epoxy/events","assignees_url":"https://api.github.com/repos/airbnb/epoxy/assignees{/user}","branches_url":"https://api.github.com/repos/airbnb/epoxy/branches{/branch}","tags_url":"https://api.github.com/repos/airbnb/epoxy/tags","blobs_url":"https://api.github.com/repos/airbnb/epoxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/airbnb/epoxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/airbnb/epoxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/airbnb/epoxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/airbnb/epoxy/statuses/{sha}","languages_url":"https://api.github.com/repos/airbnb/epoxy/languages","stargazers_url":"https://api.github.com/repos/airbnb/epoxy/stargazers","contributors_url":"https://api.github.com/repos/airbnb/epoxy/contributors","subscribers_url":"https://api.github.com/repos/airbnb/epoxy/subscribers","subscription_url":"https://api.github.com/repos/airbnb/epoxy/subscription","commits_url":"https://api.github.com/repos/airbnb/epoxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/airbnb/epoxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/airbnb/epoxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/airbnb/epoxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/airbnb/epoxy/contents/{+path}","compare_url":"https://api.github.com/repos/airbnb/epoxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/airbnb/epoxy/merges","archive_url":"https://api.github.com/repos/airbnb/epoxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/airbnb/epoxy/downloads","issues_url":"https://api.github.com/repos/airbnb/epoxy/issues{/number}","pulls_url":"https://api.github.com/repos/airbnb/epoxy/pulls{/number}","milestones_url":"https://api.github.com/repos/airbnb/epoxy/milestones{/number}","notifications_url":"https://api.github.com/repos/airbnb/epoxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/airbnb/epoxy/labels{/name}","releases_url":"https://api.github.com/repos/airbnb/epoxy/releases{/id}","deployments_url":"https://api.github.com/repos/airbnb/epoxy/deployments","created_at":"2016-08-08T23:05:11Z","updated_at":"2018-10-16T15:45:18Z","pushed_at":"2018-10-16T16:19:40Z","git_url":"git://github.com/airbnb/epoxy.git","ssh_url":"git@github.com:airbnb/epoxy.git","clone_url":"https://github.com/airbnb/epoxy.git","svn_url":"https://github.com/airbnb/epoxy","homepage":"https://goo.gl/eIK82p","size":5339,"stargazers_count":4772,"watchers_count":4772,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":351,"mirror_url":null,"archived":false,"open_issues_count":48,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":351,"open_issues":48,"watchers":4772,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/airbnb/epoxy/pulls/575"},"html":{"href":"https://github.com/airbnb/epoxy/pull/575"},"issue":{"href":"https://api.github.com/repos/airbnb/epoxy/issues/575"},"comments":{"href":"https://api.github.com/repos/airbnb/epoxy/issues/575/comments"},"review_comments":{"href":"https://api.github.com/repos/airbnb/epoxy/pulls/575/comments"},"review_comment":{"href":"https://api.github.com/repos/airbnb/epoxy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/airbnb/epoxy/pulls/575/commits"},"statuses":{"href":"https://api.github.com/repos/airbnb/epoxy/statuses/bd9fa23c55b2ec99217c54a8f026936121e41086"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"eboudrant"}}