{"action":"created","comment":{"url":"https://api.github.com/repos/novoda/merlin/pulls/comments/118185970","pull_request_review_id":39951372,"id":118185970,"diff_hunk":"@@ -21,29 +16,22 @@\n \n     }\n \n-    static HostPinger withDefaultEndpointValidation(PingerCallback pingerCallback) {","path":"core/src/main/java/com/novoda/merlin/service/HostPinger.java","position":20,"original_position":20,"commit_id":"ff780bb08eae1d5c289aeb4d907d03953e746e4a","original_commit_id":"ff780bb08eae1d5c289aeb4d907d03953e746e4a","user":{"login":"Mecharyry","id":3380092,"avatar_url":"https://avatars2.githubusercontent.com/u/3380092?v=3","gravatar_id":"","url":"https://api.github.com/users/Mecharyry","html_url":"https://github.com/Mecharyry","followers_url":"https://api.github.com/users/Mecharyry/followers","following_url":"https://api.github.com/users/Mecharyry/following{/other_user}","gists_url":"https://api.github.com/users/Mecharyry/gists{/gist_id}","starred_url":"https://api.github.com/users/Mecharyry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mecharyry/subscriptions","organizations_url":"https://api.github.com/users/Mecharyry/orgs","repos_url":"https://api.github.com/users/Mecharyry/repos","events_url":"https://api.github.com/users/Mecharyry/events{/privacy}","received_events_url":"https://api.github.com/users/Mecharyry/received_events","type":"User","site_admin":false},"body":"Default is now specified in the `MerlinBuilder` rather than defaulting to this further down.","created_at":"2017-05-24T07:59:34Z","updated_at":"2017-05-24T07:59:34Z","html_url":"https://github.com/novoda/merlin/pull/121#discussion_r118185970","pull_request_url":"https://api.github.com/repos/novoda/merlin/pulls/121","_links":{"self":{"href":"https://api.github.com/repos/novoda/merlin/pulls/comments/118185970"},"html":{"href":"https://github.com/novoda/merlin/pull/121#discussion_r118185970"},"pull_request":{"href":"https://api.github.com/repos/novoda/merlin/pulls/121"}}},"pull_request":{"url":"https://api.github.com/repos/novoda/merlin/pulls/121","id":122165633,"html_url":"https://github.com/novoda/merlin/pull/121","diff_url":"https://github.com/novoda/merlin/pull/121.diff","patch_url":"https://github.com/novoda/merlin/pull/121.patch","issue_url":"https://api.github.com/repos/novoda/merlin/issues/121","number":121,"state":"open","locked":false,"title":"MER-119/Host Pinger","user":{"login":"Mecharyry","id":3380092,"avatar_url":"https://avatars2.githubusercontent.com/u/3380092?v=3","gravatar_id":"","url":"https://api.github.com/users/Mecharyry","html_url":"https://github.com/Mecharyry","followers_url":"https://api.github.com/users/Mecharyry/followers","following_url":"https://api.github.com/users/Mecharyry/following{/other_user}","gists_url":"https://api.github.com/users/Mecharyry/gists{/gist_id}","starred_url":"https://api.github.com/users/Mecharyry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mecharyry/subscriptions","organizations_url":"https://api.github.com/users/Mecharyry/orgs","repos_url":"https://api.github.com/users/Mecharyry/repos","events_url":"https://api.github.com/users/Mecharyry/events{/privacy}","received_events_url":"https://api.github.com/users/Mecharyry/received_events","type":"User","site_admin":false},"body":"## Problem\r\nWhen adding a custom endpoint to `Merlin` it is ignored for the first ping being performed. The custom endpoint seems to be ignored because the `ping` is performed immediately when the service is created, not after the `onBind`.\r\n\r\n## Solution\r\nEnsure that the `MerlinServiceBinder` tells the `MerlinService` when it can begin performing any operations, rather than performing operations in `onCreate` or `onBind`.\r\n\r\nThe flow has changed slightly to make `MerlinService` testable and to split responsibilities.\r\n\r\n`MerlinService` -> listens for `ConnectivityChangeEvents` coming from the `BroadcastReceiver` or `NetworkCallbacks`. `MerlinService` then passes these to a `ConnectivityChangesForwarder`.\r\n\r\n`ConnectivityChangesForwarder` -> Receives `ConnectivityChangeEvent` from `MerlinService`, performs a ping for further network information and informs any listeners of the new network state. Additionally, `ConnecivityChangesForwarder` will notify of initial network state when the `MerlinService` is first bound.\r\n\r\n`HostPinger` now passes the `PingerCallback` through its method calls rather than as a dependency to prevent it being tightly bound to the `MerlinService`, allowing it to be passed through the `MerlinServiceBinder`.\r\n\r\n### Test(s) added\r\nYES! The `MerlinService` and its collaborators are fully tested 😄 \r\n\r\n### Screenshots\r\nNo UI changes but here are the logs showing the difference.\r\n\r\n#### Before\r\n```\r\n05-18 09:41:05.862 15958-16715/com.novoda.merlin.demo D/DemoLogHandle: Pinging: Endpoint{endpoint='http://connectivitycheck.android.com/generate_204'}\r\n05-18 09:41:05.894 15958-15958/com.novoda.merlin.demo D/DemoLogHandle: onServiceConnected\r\n05-18 09:41:05.895 15958-15958/com.novoda.merlin.demo D/DemoLogHandle: MerlinService.onServiceConnected\r\n05-18 09:41:05.895 15958-15958/com.novoda.merlin.demo D/DemoLogHandle: onBind\r\n05-18 09:41:05.919 15958-16009/com.novoda.merlin.demo D/OpenGLRenderer: endAllStagingAnimators on 0xee83cf00 (RippleDrawable) with handle 0xe0dfff30\r\n05-18 09:41:06.182 15958-15958/com.novoda.merlin.demo D/DemoLogHandle: onConnect\r\n05-18 09:41:56.143 15958-16714/com.novoda.merlin.demo D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524296\r\n```\r\n\r\n#### After\r\n```\r\n5-24 08:37:00.206 14285-14285/com.novoda.merlin.demo D/DemoLogHandle: onServiceConnected\r\n05-24 08:37:00.213 14285-14285/com.novoda.merlin.demo D/DemoLogHandle: onBind\r\n05-24 08:37:00.224 14285-14425/com.novoda.merlin.demo D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524290\r\n05-24 08:37:00.238 14285-14426/com.novoda.merlin.demo D/DemoLogHandle: Pinging: Endpoint{endpoint='https://www.google.co.uk/'}\r\n05-24 08:37:00.262 14285-14315/com.novoda.merlin.demo D/OpenGLRenderer: endAllStagingAnimators on 0xee83cf00 (RippleDrawable) with handle 0xe0cffb10\r\n05-24 08:37:00.573 14285-14285/com.novoda.merlin.demo D/DemoLogHandle: onConnect\r\n```\r\n\r\n### Paired with\r\nNobody.\r\n","created_at":"2017-05-24T07:54:32Z","updated_at":"2017-05-24T07:59:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4bd1aeaa2d66999ad66c58b0b291391d08ab8ba5","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/novoda/merlin/pulls/121/commits","review_comments_url":"https://api.github.com/repos/novoda/merlin/pulls/121/comments","review_comment_url":"https://api.github.com/repos/novoda/merlin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/novoda/merlin/issues/121/comments","statuses_url":"https://api.github.com/repos/novoda/merlin/statuses/ff780bb08eae1d5c289aeb4d907d03953e746e4a","head":{"label":"novoda:MER-119/host_pinger","ref":"MER-119/host_pinger","sha":"ff780bb08eae1d5c289aeb4d907d03953e746e4a","user":{"login":"novoda","id":74874,"avatar_url":"https://avatars1.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"repo":{"id":9941578,"name":"merlin","full_name":"novoda/merlin","owner":{"login":"novoda","id":74874,"avatar_url":"https://avatars1.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/novoda/merlin","description":"Observes network connection status & gives callbacks","fork":false,"url":"https://api.github.com/repos/novoda/merlin","forks_url":"https://api.github.com/repos/novoda/merlin/forks","keys_url":"https://api.github.com/repos/novoda/merlin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/novoda/merlin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/novoda/merlin/teams","hooks_url":"https://api.github.com/repos/novoda/merlin/hooks","issue_events_url":"https://api.github.com/repos/novoda/merlin/issues/events{/number}","events_url":"https://api.github.com/repos/novoda/merlin/events","assignees_url":"https://api.github.com/repos/novoda/merlin/assignees{/user}","branches_url":"https://api.github.com/repos/novoda/merlin/branches{/branch}","tags_url":"https://api.github.com/repos/novoda/merlin/tags","blobs_url":"https://api.github.com/repos/novoda/merlin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/novoda/merlin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/novoda/merlin/git/refs{/sha}","trees_url":"https://api.github.com/repos/novoda/merlin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/novoda/merlin/statuses/{sha}","languages_url":"https://api.github.com/repos/novoda/merlin/languages","stargazers_url":"https://api.github.com/repos/novoda/merlin/stargazers","contributors_url":"https://api.github.com/repos/novoda/merlin/contributors","subscribers_url":"https://api.github.com/repos/novoda/merlin/subscribers","subscription_url":"https://api.github.com/repos/novoda/merlin/subscription","commits_url":"https://api.github.com/repos/novoda/merlin/commits{/sha}","git_commits_url":"https://api.github.com/repos/novoda/merlin/git/commits{/sha}","comments_url":"https://api.github.com/repos/novoda/merlin/comments{/number}","issue_comment_url":"https://api.github.com/repos/novoda/merlin/issues/comments{/number}","contents_url":"https://api.github.com/repos/novoda/merlin/contents/{+path}","compare_url":"https://api.github.com/repos/novoda/merlin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/novoda/merlin/merges","archive_url":"https://api.github.com/repos/novoda/merlin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/novoda/merlin/downloads","issues_url":"https://api.github.com/repos/novoda/merlin/issues{/number}","pulls_url":"https://api.github.com/repos/novoda/merlin/pulls{/number}","milestones_url":"https://api.github.com/repos/novoda/merlin/milestones{/number}","notifications_url":"https://api.github.com/repos/novoda/merlin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/novoda/merlin/labels{/name}","releases_url":"https://api.github.com/repos/novoda/merlin/releases{/id}","deployments_url":"https://api.github.com/repos/novoda/merlin/deployments","created_at":"2013-05-08T17:03:53Z","updated_at":"2017-05-18T07:01:52Z","pushed_at":"2017-05-24T07:55:16Z","git_url":"git://github.com/novoda/merlin.git","ssh_url":"git@github.com:novoda/merlin.git","clone_url":"https://github.com/novoda/merlin.git","svn_url":"https://github.com/novoda/merlin","homepage":"","size":1542,"stargazers_count":311,"watchers_count":311,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":44,"mirror_url":null,"open_issues_count":7,"forks":44,"open_issues":7,"watchers":311,"default_branch":"master"}},"base":{"label":"novoda:master","ref":"master","sha":"397911011256ecac2a31b196d21b5dd45623cf54","user":{"login":"novoda","id":74874,"avatar_url":"https://avatars1.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"repo":{"id":9941578,"name":"merlin","full_name":"novoda/merlin","owner":{"login":"novoda","id":74874,"avatar_url":"https://avatars1.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/novoda/merlin","description":"Observes network connection status & gives callbacks","fork":false,"url":"https://api.github.com/repos/novoda/merlin","forks_url":"https://api.github.com/repos/novoda/merlin/forks","keys_url":"https://api.github.com/repos/novoda/merlin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/novoda/merlin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/novoda/merlin/teams","hooks_url":"https://api.github.com/repos/novoda/merlin/hooks","issue_events_url":"https://api.github.com/repos/novoda/merlin/issues/events{/number}","events_url":"https://api.github.com/repos/novoda/merlin/events","assignees_url":"https://api.github.com/repos/novoda/merlin/assignees{/user}","branches_url":"https://api.github.com/repos/novoda/merlin/branches{/branch}","tags_url":"https://api.github.com/repos/novoda/merlin/tags","blobs_url":"https://api.github.com/repos/novoda/merlin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/novoda/merlin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/novoda/merlin/git/refs{/sha}","trees_url":"https://api.github.com/repos/novoda/merlin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/novoda/merlin/statuses/{sha}","languages_url":"https://api.github.com/repos/novoda/merlin/languages","stargazers_url":"https://api.github.com/repos/novoda/merlin/stargazers","contributors_url":"https://api.github.com/repos/novoda/merlin/contributors","subscribers_url":"https://api.github.com/repos/novoda/merlin/subscribers","subscription_url":"https://api.github.com/repos/novoda/merlin/subscription","commits_url":"https://api.github.com/repos/novoda/merlin/commits{/sha}","git_commits_url":"https://api.github.com/repos/novoda/merlin/git/commits{/sha}","comments_url":"https://api.github.com/repos/novoda/merlin/comments{/number}","issue_comment_url":"https://api.github.com/repos/novoda/merlin/issues/comments{/number}","contents_url":"https://api.github.com/repos/novoda/merlin/contents/{+path}","compare_url":"https://api.github.com/repos/novoda/merlin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/novoda/merlin/merges","archive_url":"https://api.github.com/repos/novoda/merlin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/novoda/merlin/downloads","issues_url":"https://api.github.com/repos/novoda/merlin/issues{/number}","pulls_url":"https://api.github.com/repos/novoda/merlin/pulls{/number}","milestones_url":"https://api.github.com/repos/novoda/merlin/milestones{/number}","notifications_url":"https://api.github.com/repos/novoda/merlin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/novoda/merlin/labels{/name}","releases_url":"https://api.github.com/repos/novoda/merlin/releases{/id}","deployments_url":"https://api.github.com/repos/novoda/merlin/deployments","created_at":"2013-05-08T17:03:53Z","updated_at":"2017-05-18T07:01:52Z","pushed_at":"2017-05-24T07:55:16Z","git_url":"git://github.com/novoda/merlin.git","ssh_url":"git@github.com:novoda/merlin.git","clone_url":"https://github.com/novoda/merlin.git","svn_url":"https://github.com/novoda/merlin","homepage":"","size":1542,"stargazers_count":311,"watchers_count":311,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":44,"mirror_url":null,"open_issues_count":7,"forks":44,"open_issues":7,"watchers":311,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/novoda/merlin/pulls/121"},"html":{"href":"https://github.com/novoda/merlin/pull/121"},"issue":{"href":"https://api.github.com/repos/novoda/merlin/issues/121"},"comments":{"href":"https://api.github.com/repos/novoda/merlin/issues/121/comments"},"review_comments":{"href":"https://api.github.com/repos/novoda/merlin/pulls/121/comments"},"review_comment":{"href":"https://api.github.com/repos/novoda/merlin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/novoda/merlin/pulls/121/commits"},"statuses":{"href":"https://api.github.com/repos/novoda/merlin/statuses/ff780bb08eae1d5c289aeb4d907d03953e746e4a"}}}}
{"actor":{"display_login":"Mecharyry"}}