{"id":13848566,"url":"https://github.com/nuuneoi/StatedFragment","last_synced_at":"2025-07-12T13:31:33.346Z","repository":{"id":28213165,"uuid":"31717088","full_name":"nuuneoi/StatedFragment","owner":"nuuneoi","description":"Deprecated","archived":true,"fork":false,"pushed_at":"2015-04-27T08:09:21.000Z","size":344,"stargazers_count":473,"open_issues_count":5,"forks_count":84,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-08-05T19:35:48.265Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nuuneoi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-05T14:15:52.000Z","updated_at":"2023-11-03T05:47:47.000Z","dependencies_parsed_at":"2022-08-02T17:00:44.385Z","dependency_job_id":null,"html_url":"https://github.com/nuuneoi/StatedFragment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuuneoi%2FStatedFragment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuuneoi%2FStatedFragment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuuneoi%2FStatedFragment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuuneoi%2FStatedFragment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuuneoi","download_url":"https://codeload.github.com/nuuneoi/StatedFragment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225825266,"owners_count":17529905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T19:00:52.475Z","updated_at":"2024-11-22T00:30:42.330Z","avatar_url":"https://github.com/nuuneoi.png","language":"Java","funding_links":[],"categories":["Java","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-StatedFragment-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/1660)\n\n# StatedFragment\n\nProvides a functionality to retrieve `onActivityResult` in nested fragment.\n\n# Version\n\n0.10.0\n\n# Installation\n\nTo use this library in your android project, just simply add the following dependency into your build.gradle\n\nStatedFragment for Android Support Library v4's Fragment\n\n```sh\ndependencies {\n    compile 'com.inthecheesefactory.thecheeselibrary:stated-fragment-support-v4:0.10.0'\n}\n```\n\nStatedFragment for Android's Fragment\n\n```sh\ndependencies {\n    compile 'com.inthecheesefactory.thecheeselibrary:stated-fragment:0.10.0'\n}\n```\n\n# Usage\n\n### onActivityResult for Nested Fragment\n\nIn **v0.10.0** onward, `NestedActivityResultFragment` is introduced to fix `onActivityResult` problem which couldn't be called on nested fragment. To use it, you have to override `onActivityResult` on your `Activity` and add a line of code:\n\n```java\n    @Override\n    protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {\n        super.onActivityResult(requestCode, resultCode, data);\n        ActivityResultBus.getInstance().postQueue(new ActivityResultEvent(requestCode, resultCode, data));\n    }\n```\n\nAnd in your fragment, you need to call `getActivity().startActivityForResult(...)` but not `startActivityForResult(...)` since we need to let all the result sent to Activity.\n\nLastly, override `onActivityResult` in your fragment in the standard way.\n\n```java\n    public class MainFragment extends NestedActivityResultFragment {\n    \n        @Override\n        public void onActivityResult(int requestCode, int resultCode, Intent data) {\n            super.onActivityResult(requestCode, resultCode, data);\n            // Add your code here\n            Toast.makeText(getActivity(), \"Fragment Got it: \" + requestCode + \", \" + resultCode, Toast.LENGTH_SHORT).show();\n        }\n        \n    }\n```\n\n### State Saving/Restoring\n\nSince v0.10.0, `StatedFragment` is now marked \u003cspan style=\"color: red\"\u003e**deprecated**\u003c/span\u003e. Please use the traditional way documented at http://inthecheesefactory.com/blog/fragment-state-saving-best-practices/en instead\n\n# Change Logs\n\n### v0.10.0\n\n- `StatedFragment` is marked \u003cspan style=\"color: red\"\u003e**deprecated**\u003c/span\u003e. Traditional way to save/restore fragment's state is recommended.\n- `NestedActivityResultFragment` is introduced to fix `onActivityResult` problem which couldn't be called on nested fragment\n\n### v0.9.3\n\nAdd support to `\u003cfragment\u003e` tag.\n\n### v0.9.2\n\nAdd onActivityResult feature for nested fragment.\n\n### v0.9.1\n\nChange Android Support Library v4 dependency's version to 21.+ to avoid future dependency conflict.\n\n### v0.9.0\n\nSeperates library into two versions:\n- stated-fragment-support-v4: Fragment is inherited from android.support.v4.app.fragment\n- stated-fragment: Fragment is inherited from android.app.fragment\n\n\n# License\nApache 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuuneoi%2FStatedFragment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuuneoi%2FStatedFragment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuuneoi%2FStatedFragment/lists"}