{"id":17069417,"url":"https://github.com/nukc/stateview","last_synced_at":"2026-02-27T09:55:15.489Z","repository":{"id":5430112,"uuid":"53124414","full_name":"nukc/StateView","owner":"nukc","description":":sparkles: StateView is an invisible, zero-sized View that can be used to lazily inflate loadingView/emptyView/retryView/anyView at runtime.","archived":false,"fork":false,"pushed_at":"2025-12-30T10:14:43.000Z","size":2321,"stargazers_count":631,"open_issues_count":1,"forks_count":75,"subscribers_count":11,"default_branch":"kotlin","last_synced_at":"2026-01-03T00:02:29.293Z","etag":null,"topics":["android","custom-view","empty","kotlin","loading","retry","state","stateview","statusview"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nukc.png","metadata":{"files":{"readme":"README-en.md","changelog":"CHANGELOG.md","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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-03-04T09:37:02.000Z","updated_at":"2025-12-30T10:14:46.000Z","dependencies_parsed_at":"2022-08-06T18:15:27.534Z","dependency_job_id":null,"html_url":"https://github.com/nukc/StateView","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/nukc/StateView","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nukc%2FStateView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nukc%2FStateView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nukc%2FStateView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nukc%2FStateView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nukc","download_url":"https://codeload.github.com/nukc/StateView/tar.gz/refs/heads/kotlin","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nukc%2FStateView/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29890637,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T09:48:51.284Z","status":"ssl_error","status_checked_at":"2026-02-27T09:48:43.992Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","custom-view","empty","kotlin","loading","retry","state","stateview","statusview"],"created_at":"2024-10-14T11:26:49.144Z","updated_at":"2026-02-27T09:55:15.483Z","avatar_url":"https://github.com/nukc.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StateView\n\n[![Build Status](https://travis-ci.org/nukc/StateView.svg?branch=master)](https://travis-ci.org/nukc/StateView)\n[![](https://jitpack.io/v/nukc/StateView.svg)](https://jitpack.io/#nukc/StateView)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-StateView-green.svg?style=true)](https://android-arsenal.com/details/1/4255)\n\n[中文](https://github.com/nukc/StateView/blob/master/README-zh.md)\n\nStateView is an invisible, zero-sized View that can be used to lazily inflate loadingView/emptyView/retryView/anyView at runtime.\n\n\u003cimg src=\"https://raw.githubusercontent.com/nukc/stateview/master/art/custom.gif\"\u003e\u003cimg width=\"200\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/nukc/stateview/master/art/animations.gif\"\u003e\n\n## Installation\n\n\u003e JitPack\n\n#### Groovy:\nStep 1. Add the JitPack repository to your build file\nAdd it in your root settings.gradle at the end of repositories:\n```groovy\ndependencyResolutionManagement {\n    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n    repositories {\n        mavenCentral()\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\nStep 2. Add the dependency\n```groovy\n\tdependencies {\n\t    implementation 'com.github.nukc:StateView:v3.0.6'\n\t}\n```\n\n#### Kotlin:\nStep 1. Add the JitPack repository to your build file\nAdd it in your settings.gradle.kts at the end of repositories:\n```kotlin\n\tdependencyResolutionManagement {\n\t\trepositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n\t\trepositories {\n\t\t\tmavenCentral()\n\t\t\tmaven { url = uri(\"https://jitpack.io\") }\n\t\t}\n\t}\n```\nStep 2. Add the dependency\n```kotlin\n\tdependencies {\n\t        implementation(\"com.github.nukc:StateView:v3.0.6\")\n\t}\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e JCenter: will no available after 2022-02-01\u003c/summary\u003e\n\n```groovy\n   // andoridx, kotlin version, recommend\n   implementation 'com.github.nukc.stateview:kotlin:2.2.0'\n\n   // support library, java version\n   compile 'com.github.nukc.stateview:library:1.5.4'\n\n   // animator providers\n   compile 'com.github.nukc.stateview:animations:1.0.2'\n```\n\n\u003c/details\u003e\n\n##Usage\n\nCan be directly used in java.\n\n```java\n    mStateView = StateView.inject(Activity activity);\n```\n\n```java\n    mStateView = StateView.inject(View view);\n```\n\n```java\n    mStateView = StateView.inject(ViewGroup parent);\n```\n\nOr include the StateView widget in your layout.\n\n```xml\n\n    \u003ccom.github.nukc.stateview.StateView\n        android:id=\"@+id/stateView\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"/\u003e\n\n```\n\nTo switch the state view:\n\n- ```mStateView.showEmpty();```\n- ```mStateView.showLoading();```\n- ```mStateView.showRetry();```\n- ```mStateView.showContent();```\n\nTo listen the retry click:\n\n```java\n    mStateView.setOnRetryClickListener(new StateView.OnRetryClickListener() {\n        @Override\n        public void onRetryClick() {\n            //do something, no need to call showLoading()\n        }\n    });\n```\n\nTo customize view:\n\n- Global settings way: create a new layout (layout's name must be ```base_empty```/```base_retry```/```base_loading```).\n\n- Single page setting: create a new layout whit different name, and set resource in java.\n\n```java\nsetEmptyResource(@LayoutRes int emptyResource)\n\nsetRetryResource(@LayoutRes int retryResource)\n\nsetLoadingResource(@LayoutRes int loadingResource)\n\n// v2.1\nsetEmptyView(View view)\nsetRetryView(View view)\nsetLoadingView(View view)\n\n// v3.0.0\nsetView(viewType: Int, view: View)\n\n// v3.0.0\nsetView(viewType: Int, view: View)\n// eg: set empty view\nsetView(mStateView.getEmptyResource(), emptyView)\n// set any view\nsetView(1, view)\n// show view\nshow(viewType: Int)\n\n// v3.0.6\nsetEmpty(view: View)\nsetRetry(view: View)\nsetLoading(view: View)\n```\n\nuse setOnInflateListener to set message, like AnimatorActivity.java#L28\n\n\n## Custom Attribute\n\n```xml\n\u003cresources\u003e\n    \u003cdeclare-styleable name=\"StateView\"\u003e\n        \u003cattr name=\"emptyResource\" format=\"reference\" /\u003e\n        \u003cattr name=\"retryResource\" format=\"reference\" /\u003e\n        \u003cattr name=\"loadingResource\" format=\"reference\" /\u003e\n    \u003c/declare-styleable\u003e\n\u003c/resources\u003e\n```\n\n## Animation\n\nset:\n\n```java\n    // provider default is null, no animation\n    // if need, set a AnimatorProvider\n    setAnimatorProvider(AnimatorProvider provider)\n\n```\n\nanimation can custom, can also compile ```animations```\n\n```groovy\n    compile 'com.github.nukc.stateview:animations:1.0.2'\n```\n\n```animations``` library has:\n\n- ```FadeScaleAnimatorProvider```\n- ```FlipAnimatorProvider```\n- ```SlideAnimatorProvider```\n\n\nif want a custom animation，implements ```AnimatorProvider```\n\n```java\npublic class FadeScaleAnimatorProvider implements AnimatorProvider {\n\n    @Override\n    public Animator showAnimation(View view) {\n        AnimatorSet set = new AnimatorSet();\n        set.playTogether(\n                ObjectAnimator.ofFloat(view, \"alpha\", 0f, 1f),\n                ObjectAnimator.ofFloat(view, \"scaleX\", 0.1f, 1f),\n                ObjectAnimator.ofFloat(view, \"scaleY\", 0.1f, 1f)\n        );\n        return set;\n    }\n\n    @Override\n    public Animator hideAnimation(View view) {\n        AnimatorSet set = new AnimatorSet();\n        set.playTogether(\n                ObjectAnimator.ofFloat(view, \"alpha\", 1f, 0f),\n                ObjectAnimator.ofFloat(view, \"scaleX\", 1f, 0.1f),\n                ObjectAnimator.ofFloat(view, \"scaleY\", 1f, 0.1f)\n        );\n        return set;\n    }\n}\n\n```\n\n\n## License\n\n    The MIT License (MIT)\n\n    Copyright (c) 2016 Nukc\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n    SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnukc%2Fstateview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnukc%2Fstateview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnukc%2Fstateview/lists"}