{"action":"created","issue":{"url":"https://api.github.com/repos/robolectric/robolectric/issues/1431","labels_url":"https://api.github.com/repos/robolectric/robolectric/issues/1431/labels{/name}","comments_url":"https://api.github.com/repos/robolectric/robolectric/issues/1431/comments","events_url":"https://api.github.com/repos/robolectric/robolectric/issues/1431/events","html_url":"https://github.com/robolectric/robolectric/pull/1431","id":52451409,"number":1431,"title":"Removed ShadowHandler, introduced ShadowMessageQueue","user":{"login":"kriegfrj","id":7224087,"avatar_url":"https://avatars.githubusercontent.com/u/7224087?v=3","gravatar_id":"","url":"https://api.github.com/users/kriegfrj","html_url":"https://github.com/kriegfrj","followers_url":"https://api.github.com/users/kriegfrj/followers","following_url":"https://api.github.com/users/kriegfrj/following{/other_user}","gists_url":"https://api.github.com/users/kriegfrj/gists{/gist_id}","starred_url":"https://api.github.com/users/kriegfrj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kriegfrj/subscriptions","organizations_url":"https://api.github.com/users/kriegfrj/orgs","repos_url":"https://api.github.com/users/kriegfrj/repos","events_url":"https://api.github.com/users/kriegfrj/events{/privacy}","received_events_url":"https://api.github.com/users/kriegfrj/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-12-19T06:15:42Z","updated_at":"2015-01-12T17:45:12Z","closed_at":"2015-01-12T17:43:09Z","pull_request":{"url":"https://api.github.com/repos/robolectric/robolectric/pulls/1431","html_url":"https://github.com/robolectric/robolectric/pull/1431","diff_url":"https://github.com/robolectric/robolectric/pull/1431.diff","patch_url":"https://github.com/robolectric/robolectric/pull/1431.patch"},"body":"Started as a requirement for `ShadowHandler`'s `remove()` functionality to work better.\r\n\r\n`ShadowHandler` attempted to emulate the message queuing of Android. Unfortunately it did so imperfectly, with problems including:\r\n\r\n* `removeCallbacksAndMessages()` only removed messages and not callbacks.\r\n* It didn't honour tags on callbacks (posted `Runnable`s) - only on messages.\r\n* `Handler`s connected to the same `Looper` in Android are isolated from each other - doing a remove on one `Handler` instance will not interfere with the messages associated with a different `Handler` even if they have the same tags. The previous `ShadowHandler` implementation didn't honour this (eg, `removeCallbacksAndMessages()` would remove all callbacks for all handlers associated with the same looper).\r\n\r\nWhen I looked at trying to add this functionality to the `ShadowHandler` I realised I would basically be reinventing the Android implementation of `MessageQueue` for most of it. Hence `ShadowMessageQueue` was born, which basically only needs to reimplement one method to interface it with the `Scheduler`.\r\n\r\nI kept most of `ShadowHandlerTest` as a regression test to make sure that no existing functionality was broken. Added a couple of more tests to ensure that the broken functionality mentioned above was fixed.\r\n\r\nI also kept `ShadowHandler` only because of the static methods (which client code might be using). This could be removed completely in a later revision."},"comment":{"url":"https://api.github.com/repos/robolectric/robolectric/issues/comments/69611510","html_url":"https://github.com/robolectric/robolectric/pull/1431#issuecomment-69611510","issue_url":"https://api.github.com/repos/robolectric/robolectric/issues/1431","id":69611510,"user":{"login":"erd","id":184194,"avatar_url":"https://avatars.githubusercontent.com/u/184194?v=3","gravatar_id":"","url":"https://api.github.com/users/erd","html_url":"https://github.com/erd","followers_url":"https://api.github.com/users/erd/followers","following_url":"https://api.github.com/users/erd/following{/other_user}","gists_url":"https://api.github.com/users/erd/gists{/gist_id}","starred_url":"https://api.github.com/users/erd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erd/subscriptions","organizations_url":"https://api.github.com/users/erd/orgs","repos_url":"https://api.github.com/users/erd/repos","events_url":"https://api.github.com/users/erd/events{/privacy}","received_events_url":"https://api.github.com/users/erd/received_events","type":"User","site_admin":false},"created_at":"2015-01-12T17:45:12Z","updated_at":"2015-01-12T17:45:12Z","body":"I'd be fine removing the static methods from `ShadowHandler`. We're making a lot of API changes in this release, so if we're going to do it, this is as good of a time as any."}}