{"action":"created","issue":{"url":"https://api.github.com/repos/Flipboard/bottomsheet/issues/104","labels_url":"https://api.github.com/repos/Flipboard/bottomsheet/issues/104/labels{/name}","comments_url":"https://api.github.com/repos/Flipboard/bottomsheet/issues/104/comments","events_url":"https://api.github.com/repos/Flipboard/bottomsheet/issues/104/events","html_url":"https://github.com/Flipboard/bottomsheet/issues/104","id":122695816,"number":104,"title":"Bug: BottomSheetFragment sample closes the bottomSheet upon hiding app","user":{"login":"AndroidDeveloperLB","id":5357526,"avatar_url":"https://avatars.githubusercontent.com/u/5357526?v=3","gravatar_id":"","url":"https://api.github.com/users/AndroidDeveloperLB","html_url":"https://github.com/AndroidDeveloperLB","followers_url":"https://api.github.com/users/AndroidDeveloperLB/followers","following_url":"https://api.github.com/users/AndroidDeveloperLB/following{/other_user}","gists_url":"https://api.github.com/users/AndroidDeveloperLB/gists{/gist_id}","starred_url":"https://api.github.com/users/AndroidDeveloperLB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndroidDeveloperLB/subscriptions","organizations_url":"https://api.github.com/users/AndroidDeveloperLB/orgs","repos_url":"https://api.github.com/users/AndroidDeveloperLB/repos","events_url":"https://api.github.com/users/AndroidDeveloperLB/events{/privacy}","received_events_url":"https://api.github.com/users/AndroidDeveloperLB/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-17T09:33:34Z","updated_at":"2015-12-17T11:30:23Z","closed_at":null,"body":"Steps:\r\n1. open sample app\r\n2. go to the inner sample of BottomSheetFragment.\r\n3. press the \"show\" button.\r\n4. press the home button of the device, or the recent-tasks.\r\n5. go back to the app (no matter how).\r\n\r\nThe bug:\r\nthe bottom-sheet gets hidden, even though on all other inner samples it doesn't occur.\r\n\r\nHow can I handle it nicely? Why does it occur? Is there a workaround?"},"comment":{"url":"https://api.github.com/repos/Flipboard/bottomsheet/issues/comments/165429515","html_url":"https://github.com/Flipboard/bottomsheet/issues/104#issuecomment-165429515","issue_url":"https://api.github.com/repos/Flipboard/bottomsheet/issues/104","id":165429515,"user":{"login":"AndroidDeveloperLB","id":5357526,"avatar_url":"https://avatars.githubusercontent.com/u/5357526?v=3","gravatar_id":"","url":"https://api.github.com/users/AndroidDeveloperLB","html_url":"https://github.com/AndroidDeveloperLB","followers_url":"https://api.github.com/users/AndroidDeveloperLB/followers","following_url":"https://api.github.com/users/AndroidDeveloperLB/following{/other_user}","gists_url":"https://api.github.com/users/AndroidDeveloperLB/gists{/gist_id}","starred_url":"https://api.github.com/users/AndroidDeveloperLB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndroidDeveloperLB/subscriptions","organizations_url":"https://api.github.com/users/AndroidDeveloperLB/orgs","repos_url":"https://api.github.com/users/AndroidDeveloperLB/repos","events_url":"https://api.github.com/users/AndroidDeveloperLB/events{/privacy}","received_events_url":"https://api.github.com/users/AndroidDeveloperLB/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T11:30:23Z","updated_at":"2015-12-17T11:30:23Z","body":"ok, in order to fix this, here's what I did (and it also seems to handle orientation changes too) : \r\n\r\nBottomSheetFragmentDelegate: \r\n\r\ndismiss the bottomSheet if fragment already existed:\r\n\r\n        public void show(FragmentManager manager, @IdRes int bottomSheetLayoutId) {\r\n            dismissed = false;\r\n            shownByMe = true;\r\n            this.bottomSheetLayoutId = bottomSheetLayoutId;\r\n            final String fragmentTag = String.valueOf(bottomSheetLayoutId);\r\n            final Fragment previousFragment = manager.findFragmentByTag(fragmentTag);\r\n            if (previousFragment != null)\r\n                ((BottomSheetFragmentInterface) previousFragment).dismiss();\r\n            else\r\n                manager.beginTransaction()\r\n                        .add(fragment, fragmentTag)\r\n                        .commit();\r\n        }\r\n\r\nshow the bottom sheet only if not shown already:\r\n\r\n        public void onStart() {\r\n            if (bottomSheetLayout != null) {\r\n                if (bottomSheetLayout.isSheetShowing())\r\n                    return;\r\n                viewDestroyed = false;\r\n                bottomSheetLayout.showWithSheetView(fragment.getView(), sheetFragmentInterface.getViewTransformer());\r\n                bottomSheetLayout.addOnSheetDismissedListener(this);\r\n            }\r\n        }"}}