{"id":13428346,"url":"https://github.com/Kennyc1012/MultiStateView","last_synced_at":"2025-03-16T01:32:23.231Z","repository":{"id":30798048,"uuid":"34355111","full_name":"Kennyc1012/MultiStateView","owner":"Kennyc1012","description":"Android View that displays different content based on its state","archived":false,"fork":false,"pushed_at":"2021-02-13T14:21:40.000Z","size":309,"stargazers_count":1221,"open_issues_count":4,"forks_count":177,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-03-06T15:22:04.667Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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/Kennyc1012.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-04-21T22:19:39.000Z","updated_at":"2025-01-23T03:10:31.000Z","dependencies_parsed_at":"2022-08-29T06:51:47.429Z","dependency_job_id":null,"html_url":"https://github.com/Kennyc1012/MultiStateView","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kennyc1012%2FMultiStateView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kennyc1012%2FMultiStateView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kennyc1012%2FMultiStateView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kennyc1012%2FMultiStateView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kennyc1012","download_url":"https://codeload.github.com/Kennyc1012/MultiStateView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814900,"owners_count":20352037,"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-07-31T01:00:53.588Z","updated_at":"2025-03-16T01:32:22.905Z","avatar_url":"https://github.com/Kennyc1012.png","language":"Kotlin","readme":"# MultiStateView\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MultiStateView-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/1726)\nAndroid View that displays different content based on its state.\u003cbr\u003e\nBased off of [MeetMe/MultiStateView](https://github.com/MeetMe/Android-MultiStateView)\n\nThe four different states the view can be in are:\n- Content\n- Empty\n- Error\n- Loading\n\n![screenshot](https://github.com/Kennyc1012/MultiStateView/blob/master/art/content.png)\n![screenshot](https://github.com/Kennyc1012/MultiStateView/blob/master/art/loading.png)\n![screenshot](https://github.com/Kennyc1012/MultiStateView/blob/master/art/empty.png)\n![screenshot](https://github.com/Kennyc1012/MultiStateView/blob/master/art/error.png)\n\n\n# Using MultiStateView\nMultiStateView can be used the same as any other view by adding it as a layout file via XML\n```xml\n\u003ccom.kennyc.view.MultiStateView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:id=\"@+id/multiStateView\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    app:msv_errorView=\"@layout/error_view\"\n    app:msv_emptyView=\"@layout/empty_view\"\n    app:msv_loadingView=\"@layout/loading_view\"\n    app:msv_viewState=\"loading\"\u003e\n    \n      \u003cListView\n        android:id=\"@+id/list\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        tools:listitem=\"@android:layout/simple_list_item_1\" /\u003e\n\n\u003c/com.kennyc.view.MultiStateView\u003e\n```\nThe attributes to set for MultiStateView are\n```xml\n\u003cattr name=\"msv_loadingView\" format=\"reference\" /\u003e\n\u003cattr name=\"msv_emptyView\" format=\"reference\" /\u003e\n\u003cattr name=\"msv_errorView\" format=\"reference\" /\u003e\n\u003cattr name=\"msv_viewState\" format=\"enum\"\u003e\n\u003cattr name=\"msv_animateViewChanges\" format=\"boolean\" /\u003e\n```\n\n`msv_loadingView` is the view to be used for `VIEW_STATE_LOADING` \u003cbr\u003e\n`msv_emptyView` is the view to be used for `VIEW_STATE_EMPTY` \u003cbr\u003e\n`msv_errorView` is the view to be used for `VIEW_STATE_ERROR` \u003cbr\u003e\n`msv_viewState` is the [ViewState](https://github.com/Kennyc1012/MultiStateView/blob/master/library/src/main/java/com/kennyc/view/MultiStateView.kt#L34) for the MultiStateView\u003cbr\u003e\n`msv_animateViewChanges` is a flag to set whether the views should animate in and out when switching states. `false` by default\u003cbr\u003e\n`VIEW_STATE_CONTENT` is determined by whatever is inside of the tags via XML. \u003cb\u003eNOTE a Content view must be set for the view to function, this is by design.\u003c/b\u003e\n\nTo switch the state of MultiStateView, simply call\n```kotlin \nmultiStateView.viewState = state: ViewState\n```\nor in java\n```java\nmultiStateView.setViewState(@NonNull ViewState state)\n```\n\nYou can also get the View for the accompanying ViewState by calling\n```kotlin \nmultiStateView.getView(state: ViewState):View?\n```\nor in java\n```java\n@Nullable\npublic View getView(@NonNull ViewState state)\n```\n\n# Including in your project\nTo include MultiStateView in your project, make the following changes to your build.gradle file\n\n## Add repository \n```groovy\nrepositories {\n    maven { url 'https://jitpack.io' }\n}\n```\n## Add dependency\n```groovy\ndependencies {\n    implementation  'com.github.Kennyc1012:MultiStateView:2.2.0'\n}\n```\n\n# Contribution\nPull requests are welcomed and encouraged. If you experience any bugs, please file an [issue](https://github.com/Kennyc1012/MultiStateView/issues)\n\nLicense\n=======\n\n    Copyright 2015 Kenny Campagna\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","funding_links":[],"categories":["Libraries","空白页","Java"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKennyc1012%2FMultiStateView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKennyc1012%2FMultiStateView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKennyc1012%2FMultiStateView/lists"}