{"action":"opened","number":7,"pull_request":{"url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/pulls/7","id":82556423,"html_url":"https://github.com/devsoulwolf/MaterialRadioGroup/pull/7","diff_url":"https://github.com/devsoulwolf/MaterialRadioGroup/pull/7.diff","patch_url":"https://github.com/devsoulwolf/MaterialRadioGroup/pull/7.patch","issue_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/issues/7","number":7,"state":"open","locked":false,"title":"Fix issue with MaterialRadioGroup on orientation changed","user":{"login":"paul1893","id":10085515,"avatar_url":"https://avatars.githubusercontent.com/u/10085515?v=3","gravatar_id":"","url":"https://api.github.com/users/paul1893","html_url":"https://github.com/paul1893","followers_url":"https://api.github.com/users/paul1893/followers","following_url":"https://api.github.com/users/paul1893/following{/other_user}","gists_url":"https://api.github.com/users/paul1893/gists{/gist_id}","starred_url":"https://api.github.com/users/paul1893/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paul1893/subscriptions","organizations_url":"https://api.github.com/users/paul1893/orgs","repos_url":"https://api.github.com/users/paul1893/repos","events_url":"https://api.github.com/users/paul1893/events{/privacy}","received_events_url":"https://api.github.com/users/paul1893/received_events","type":"User","site_admin":false},"body":"By default when orientation changed the view is recreated. It appears that MaterialRadioGroup didn't preserve his state between this orientation changed.\r\nThat was due by the fact that each MaterialRadioButton is added one by one when MaterialRadioGroup is created. (see below).\r\n\r\n```java\r\nMaterialRadioGroup.java\r\n-------------------------------\r\npublic void addView(View child, int index, ViewGroup.LayoutParams params) {\r\n        if (child instanceof MaterialRadioButton) {\r\n             ...\r\n        }\r\n}\r\n```\r\nAnd each time a MaterialRadioButton is added to the MaterialRadioGroup this two line are called:\r\n\r\n```java\r\nMaterialCompoundButton.java\r\n-------------------------------\r\nLayoutInflater.from(context).inflate(R.layout.mcl_compound_button, this, true);\r\nmButtonView = (MaterialStateButton) findViewById(R.id.mci_compound_button_image);\r\n```\r\nMaterialStateButton preserved his state during orientation due to this method onSaveInstanceState() and onRestoreInstanceState(Parcelable state). So we reused the state of the last configured MaterialStateButton when we reinstantiate the MaterialRadioButton on orientation changed.\r\n\r\nIf I take an example:\r\n1) -> Boy is checked (MaterialStateButton checked) | Girl is unchecked (MaterialStateButton unchecked).\r\n2) -> Device rotation\r\n3) -> View is recreated\r\n4) -> Boy is checked (But last state of MaterialStateButton is unchecked (remember the girl ;)) \r\nso we have:\r\nBoy is checked (MaterialStateButton unchecked) | Girl is unchecked (MaterialStateButton unchecked).\r\n\r\nNB: If we 'checked' the girl at step one it has been worked because last MaterialStateButton was 'checked' and it can only have one MaterialRadioButton checked in the MaterialRadioGroup due to\r\n```java\r\npublic void check(int id) {\r\n        // don't even bother\r\n        if (id != -1 && (id == mCheckedId)) {\r\n            return;\r\n        }\r\n        if (mCheckedId != -1) {\r\n            setCheckedStateForView(mCheckedId, false);\r\n        }\r\n        if (id != -1) {\r\n            setCheckedStateForView(id, true);\r\n        }\r\n        setCheckedId(id);\r\n    }\r\n```\r\nGiven that the Girl is also in last position it worked by chance.\r\n\r\nWhat I do is save the MaterialRadioGroup checkedId on orientation changed instead of the MaterialStateButton. And it seems to works everytime now ;)","created_at":"2016-08-24T14:47:52Z","updated_at":"2016-08-24T14:47:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/pulls/7/commits","review_comments_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/pulls/7/comments","review_comment_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/pulls/comments{/number}","comments_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/issues/7/comments","statuses_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/statuses/546fa35b8e0a18127bedb885a36b937b4d5ad840","head":{"label":"paul1893:master","ref":"master","sha":"546fa35b8e0a18127bedb885a36b937b4d5ad840","user":{"login":"paul1893","id":10085515,"avatar_url":"https://avatars.githubusercontent.com/u/10085515?v=3","gravatar_id":"","url":"https://api.github.com/users/paul1893","html_url":"https://github.com/paul1893","followers_url":"https://api.github.com/users/paul1893/followers","following_url":"https://api.github.com/users/paul1893/following{/other_user}","gists_url":"https://api.github.com/users/paul1893/gists{/gist_id}","starred_url":"https://api.github.com/users/paul1893/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paul1893/subscriptions","organizations_url":"https://api.github.com/users/paul1893/orgs","repos_url":"https://api.github.com/users/paul1893/repos","events_url":"https://api.github.com/users/paul1893/events{/privacy}","received_events_url":"https://api.github.com/users/paul1893/received_events","type":"User","site_admin":false},"repo":{"id":66468546,"name":"MaterialRadioGroup","full_name":"paul1893/MaterialRadioGroup","owner":{"login":"paul1893","id":10085515,"avatar_url":"https://avatars.githubusercontent.com/u/10085515?v=3","gravatar_id":"","url":"https://api.github.com/users/paul1893","html_url":"https://github.com/paul1893","followers_url":"https://api.github.com/users/paul1893/followers","following_url":"https://api.github.com/users/paul1893/following{/other_user}","gists_url":"https://api.github.com/users/paul1893/gists{/gist_id}","starred_url":"https://api.github.com/users/paul1893/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paul1893/subscriptions","organizations_url":"https://api.github.com/users/paul1893/orgs","repos_url":"https://api.github.com/users/paul1893/repos","events_url":"https://api.github.com/users/paul1893/events{/privacy}","received_events_url":"https://api.github.com/users/paul1893/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/paul1893/MaterialRadioGroup","description":"This is a cool radio button group!","fork":true,"url":"https://api.github.com/repos/paul1893/MaterialRadioGroup","forks_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/forks","keys_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/teams","hooks_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/hooks","issue_events_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/issues/events{/number}","events_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/events","assignees_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/assignees{/user}","branches_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/branches{/branch}","tags_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/tags","blobs_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/git/refs{/sha}","trees_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/statuses/{sha}","languages_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/languages","stargazers_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/stargazers","contributors_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/contributors","subscribers_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/subscribers","subscription_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/subscription","commits_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/commits{/sha}","git_commits_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/git/commits{/sha}","comments_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/comments{/number}","issue_comment_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/issues/comments{/number}","contents_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/contents/{+path}","compare_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/merges","archive_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/downloads","issues_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/issues{/number}","pulls_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/pulls{/number}","milestones_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/milestones{/number}","notifications_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/labels{/name}","releases_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/releases{/id}","deployments_url":"https://api.github.com/repos/paul1893/MaterialRadioGroup/deployments","created_at":"2016-08-24T13:57:54Z","updated_at":"2016-08-24T13:57:55Z","pushed_at":"2016-08-24T14:23:39Z","git_url":"git://github.com/paul1893/MaterialRadioGroup.git","ssh_url":"git@github.com:paul1893/MaterialRadioGroup.git","clone_url":"https://github.com/paul1893/MaterialRadioGroup.git","svn_url":"https://github.com/paul1893/MaterialRadioGroup","homepage":null,"size":322,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"devsoulwolf:master","ref":"master","sha":"0d89569c6bfef767a118559acc887559d9893b6e","user":{"login":"devsoulwolf","id":10868455,"avatar_url":"https://avatars.githubusercontent.com/u/10868455?v=3","gravatar_id":"","url":"https://api.github.com/users/devsoulwolf","html_url":"https://github.com/devsoulwolf","followers_url":"https://api.github.com/users/devsoulwolf/followers","following_url":"https://api.github.com/users/devsoulwolf/following{/other_user}","gists_url":"https://api.github.com/users/devsoulwolf/gists{/gist_id}","starred_url":"https://api.github.com/users/devsoulwolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devsoulwolf/subscriptions","organizations_url":"https://api.github.com/users/devsoulwolf/orgs","repos_url":"https://api.github.com/users/devsoulwolf/repos","events_url":"https://api.github.com/users/devsoulwolf/events{/privacy}","received_events_url":"https://api.github.com/users/devsoulwolf/received_events","type":"User","site_admin":false},"repo":{"id":39130656,"name":"MaterialRadioGroup","full_name":"devsoulwolf/MaterialRadioGroup","owner":{"login":"devsoulwolf","id":10868455,"avatar_url":"https://avatars.githubusercontent.com/u/10868455?v=3","gravatar_id":"","url":"https://api.github.com/users/devsoulwolf","html_url":"https://github.com/devsoulwolf","followers_url":"https://api.github.com/users/devsoulwolf/followers","following_url":"https://api.github.com/users/devsoulwolf/following{/other_user}","gists_url":"https://api.github.com/users/devsoulwolf/gists{/gist_id}","starred_url":"https://api.github.com/users/devsoulwolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devsoulwolf/subscriptions","organizations_url":"https://api.github.com/users/devsoulwolf/orgs","repos_url":"https://api.github.com/users/devsoulwolf/repos","events_url":"https://api.github.com/users/devsoulwolf/events{/privacy}","received_events_url":"https://api.github.com/users/devsoulwolf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/devsoulwolf/MaterialRadioGroup","description":"This is a cool radio button group!","fork":false,"url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup","forks_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/forks","keys_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/teams","hooks_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/hooks","issue_events_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/issues/events{/number}","events_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/events","assignees_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/assignees{/user}","branches_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/branches{/branch}","tags_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/tags","blobs_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/git/refs{/sha}","trees_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/statuses/{sha}","languages_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/languages","stargazers_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/stargazers","contributors_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/contributors","subscribers_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/subscribers","subscription_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/subscription","commits_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/commits{/sha}","git_commits_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/git/commits{/sha}","comments_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/comments{/number}","issue_comment_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/issues/comments{/number}","contents_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/contents/{+path}","compare_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/merges","archive_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/downloads","issues_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/issues{/number}","pulls_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/pulls{/number}","milestones_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/milestones{/number}","notifications_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/labels{/name}","releases_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/releases{/id}","deployments_url":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/deployments","created_at":"2015-07-15T10:24:49Z","updated_at":"2016-08-15T08:46:32Z","pushed_at":"2016-08-24T14:47:52Z","git_url":"git://github.com/devsoulwolf/MaterialRadioGroup.git","ssh_url":"git@github.com:devsoulwolf/MaterialRadioGroup.git","clone_url":"https://github.com/devsoulwolf/MaterialRadioGroup.git","svn_url":"https://github.com/devsoulwolf/MaterialRadioGroup","homepage":null,"size":322,"stargazers_count":74,"watchers_count":74,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":26,"mirror_url":null,"open_issues_count":4,"forks":26,"open_issues":4,"watchers":74,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/pulls/7"},"html":{"href":"https://github.com/devsoulwolf/MaterialRadioGroup/pull/7"},"issue":{"href":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/issues/7"},"comments":{"href":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/devsoulwolf/MaterialRadioGroup/statuses/546fa35b8e0a18127bedb885a36b937b4d5ad840"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":3,"additions":50,"deletions":48,"changed_files":5}}
{"actor":{"display_login":"paul1893"}}