{"action":"created","issue":{"url":"https://api.github.com/repos/RoboBinding/RoboBinding/issues/201","labels_url":"https://api.github.com/repos/RoboBinding/RoboBinding/issues/201/labels{/name}","comments_url":"https://api.github.com/repos/RoboBinding/RoboBinding/issues/201/comments","events_url":"https://api.github.com/repos/RoboBinding/RoboBinding/issues/201/events","html_url":"https://github.com/RoboBinding/RoboBinding/issues/201","id":58271027,"number":201,"title":"View does not refresh bindings on orientation change","user":{"login":"bj0","id":1139347,"avatar_url":"https://avatars.githubusercontent.com/u/1139347?v=3","gravatar_id":"","url":"https://api.github.com/users/bj0","html_url":"https://github.com/bj0","followers_url":"https://api.github.com/users/bj0/followers","following_url":"https://api.github.com/users/bj0/following{/other_user}","gists_url":"https://api.github.com/users/bj0/gists{/gist_id}","starred_url":"https://api.github.com/users/bj0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bj0/subscriptions","organizations_url":"https://api.github.com/users/bj0/orgs","repos_url":"https://api.github.com/users/bj0/repos","events_url":"https://api.github.com/users/bj0/events{/privacy}","received_events_url":"https://api.github.com/users/bj0/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-19T21:16:46Z","updated_at":"2015-05-04T02:27:59Z","closed_at":"2015-05-04T02:27:59Z","body":"I have a landscape and portrait layout for a view with a ToggleButton on it.  This togglebutton is bound to a bool property in the PresentationModel (PM):\r\n\r\nThe binding is set with:\r\n\r\n    <ToggleButton\r\n        android:id=\"@+id/alt\"\r\n        bind:onClick=\"Click\"\r\n        bind:checked=\"{altMode}\"\r\n        ...\r\n        />\r\n        \r\nThe PM has the properties:\r\n\r\n    private boolean altMode;\r\n\r\n    public boolean isAltMode() { return altMode;}\r\n    public void setAltMode(boolean altMode) {\r\n        this.altMode = altMode;\r\n        changeSupport.firePropertyChange(\"altMode\");\r\n    }\r\n\r\n    public void Click(ClickEvent event) {\r\n        int id = event.getView().getId();\r\n\r\n        if( id == R.id.alt ) {\r\n            setAltMode(!isAltMode());\r\n            return;\r\n        }\r\n        \r\n        ...\r\n    }\r\n        \r\nThe view is created (in Fragment.onCreateView) with:\r\n\r\n    BinderFactory factory = new BinderFactoryBuilder()\r\n            .add(new DynamicViewBinding()\r\n                    .forView(ToggleButton.class)\r\n                    .oneWayProperties(\"checked\")).build();\r\n    ViewBinder binder = factory.createViewBinder(inflater.getContext());\r\n\r\n    if( PresModel == null )\r\n        PresModel = new PM();\r\n    View rootView;\r\n    if (container == null)\r\n        rootView = binder.inflateAndBind(R.layout.fragment, PresModel);\r\n    else\r\n        rootView = binder.inflateAndBindWithoutAttachingToRoot(R.layout.fragment, PresModel, container);\r\n\r\n\r\nThis works as expected except when you toggle the button to \"on\" and then rotate your phone so you get an orientation change.  When this happens, the fragment is re-created, which calls .onCreateView, re-creating the view and PM.  \r\n\r\nThe problem is that the new View is out of sync with the new PM.  The PM's altMode is false, but the view visually shows the button as toggled true.  I realize that it would probably be better to save this property between orientation changes, but it is still a bug that the PM and View are out of sync.\r\n"},"comment":{"url":"https://api.github.com/repos/RoboBinding/RoboBinding/issues/comments/98568848","html_url":"https://github.com/RoboBinding/RoboBinding/issues/201#issuecomment-98568848","issue_url":"https://api.github.com/repos/RoboBinding/RoboBinding/issues/201","id":98568848,"user":{"login":"robobindingacc","id":5292402,"avatar_url":"https://avatars.githubusercontent.com/u/5292402?v=3","gravatar_id":"","url":"https://api.github.com/users/robobindingacc","html_url":"https://github.com/robobindingacc","followers_url":"https://api.github.com/users/robobindingacc/followers","following_url":"https://api.github.com/users/robobindingacc/following{/other_user}","gists_url":"https://api.github.com/users/robobindingacc/gists{/gist_id}","starred_url":"https://api.github.com/users/robobindingacc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robobindingacc/subscriptions","organizations_url":"https://api.github.com/users/robobindingacc/orgs","repos_url":"https://api.github.com/users/robobindingacc/repos","events_url":"https://api.github.com/users/robobindingacc/events{/privacy}","received_events_url":"https://api.github.com/users/robobindingacc/received_events","type":"User","site_admin":false},"created_at":"2015-05-04T02:27:59Z","updated_at":"2015-05-04T02:27:59Z","body":"No further communication. Close for now and reopen when required."}}