{"id":24117112,"url":"https://github.com/picsart/stateful","last_synced_at":"2025-07-20T08:06:34.071Z","repository":{"id":78722044,"uuid":"153099469","full_name":"PicsArt/stateful","owner":"PicsArt","description":"Stateful is a Kotlin library which makes Android application development faster and easier.","archived":false,"fork":false,"pushed_at":"2020-06-10T08:22:03.000Z","size":85,"stargazers_count":67,"open_issues_count":0,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-28T10:14:33.377Z","etag":null,"topics":["android","android-library","kotlin","kotlin-android","kotlin-android-extensions","kotlin-library"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PicsArt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-10-15T11:10:05.000Z","updated_at":"2025-03-11T21:54:02.000Z","dependencies_parsed_at":"2023-03-02T18:00:31.993Z","dependency_job_id":null,"html_url":"https://github.com/PicsArt/stateful","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/PicsArt/stateful","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PicsArt%2Fstateful","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PicsArt%2Fstateful/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PicsArt%2Fstateful/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PicsArt%2Fstateful/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PicsArt","download_url":"https://codeload.github.com/PicsArt/stateful/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PicsArt%2Fstateful/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266087790,"owners_count":23874519,"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":["android","android-library","kotlin","kotlin-android","kotlin-android-extensions","kotlin-library"],"created_at":"2025-01-11T07:38:20.604Z","updated_at":"2025-07-20T08:06:34.040Z","avatar_url":"https://github.com/PicsArt.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://img.shields.io/maven-central/v/com.picsart/stateful.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.picsart%22%20AND%20a:%22stateful%22)\n# Stateful\nStateful is a Kotlin library which makes Android application development faster and easier. It helps you delete all the boilerplate code for saving instance state and lets you forget about saving and restoring your fragment's/activity's state.\n\n# Download\nGradle:\n```groovy\nimplementation 'com.picsart:stateful:1.2.1'\n```\n# Using Stateful\nThe most activities look like the following example.\n```kotlin\nclass MySuperCoolActivity : Activity() {\n    private var importantNumber: Int = 3\n    private var importantNullableNumber: Int? = null\n    private var importantFlag: Boolean = false\n    ///and many other super important properties\n\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        if (savedInstanceState != null) {\n            importantNumber = savedInstanceState.getInt(\"important property key\")\n            importantFlag = savedInstanceState.getBoolean(\"important flag key\")\n            if (savedInstanceState.containsKey(\"important nullable property key\")) {\n                importantNullableNumber = savedInstanceState.getInt(\"important nullable property key\")            \n            }\n            //....\n        }\n        //some important logic...\n    }\n\n    override fun onSaveInstanceState(outState: Bundle) {\n        super.onSaveInstanceState(outState)\n        outState.putInt(\"important property key\", importantNumber)\n        outState.putBoolean(\"important flag key\", importantFlag)\n        importantNullableNumber?.let {\n            outState.putInt(\"important nullable property key\", it)\n        }\n        //....\n    }\n\n    //some more code..\n}\n```\n\nWhat if I say that you can remove all boilerplate code for saving state with the help of stateful?\n\n```kotlin\nclass MySuperCoolActivity : Activity(), Stateful by state() {\n    private var importantNumber: Int by statefulProperty(3)\n    private var importantNullableNumber: Int? by statefulNullableProperty\u003cInt\u003e(null)\n    private var importantFlag: Boolean by statefulProperty(false)\n    ///and many more super important properties\n\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        restore(savedInstanceState)\n        //some important logic...\n    }\n\n    override fun onSaveInstanceState(outState: Bundle) {\n        super.onSaveInstanceState(outState)\n        save(outState)\n    }\n\n    //some more code..\n}\n```\n\nThe default implementation is using property names as a key to put them in the bundle. If you want to implement your own logic for a key generation you can extend *Stateful* interface and use your own implementation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicsart%2Fstateful","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpicsart%2Fstateful","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicsart%2Fstateful/lists"}