Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/islamdidarmd/multistate-layout
A custom layout that helps to manage multiple states(LOADING, EMPTY, CONTENT) of view. This layout is also aware about network state.
https://github.com/islamdidarmd/multistate-layout
android custom java kotlin layout multi network state ui
Last synced: 20 days ago
JSON representation
A custom layout that helps to manage multiple states(LOADING, EMPTY, CONTENT) of view. This layout is also aware about network state.
- Host: GitHub
- URL: https://github.com/islamdidarmd/multistate-layout
- Owner: islamdidarmd
- License: mit
- Created: 2019-03-20T04:04:44.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-20T04:20:23.000Z (almost 6 years ago)
- Last Synced: 2024-11-22T11:52:18.731Z (3 months ago)
- Topics: android, custom, java, kotlin, layout, multi, network, state, ui
- Language: Kotlin
- Homepage:
- Size: 306 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Multistate Layout
A custom layout that helps to manage multiple states(LOADING, EMPTY, CONTENT) of the layout. This layout is also aware
about network state.[![](https://jitpack.io/v/islamdidarmd/multistate-layout.svg)](https://jitpack.io/v/islamdidarmd/multistate-layout)
## Installation (with Gradle)
Add the dependency to your root *build.gradle*:
```groovy
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
```
Now add this dependency in your module *build.gradle*
```groovy
dependencies {
implementation 'com.github.islamdidarmd:multistate-layout:$latest_release'
}
```### Demo
![]()
![]()
![]()
### How to use
For using custom attributes use `msl` namespace in the root element of the layout`xmlns:msl="http://schemas.android.com/apk/res-auto"`
`msl:loadingLayout`, `msl:emptyLayout` are optional. If you don't include these, a basic layout will be shown.
if you set `msl:showConnectionStatus="true"`, then a layout will be shown on top of the layout if device doesn't have a data
connection```xml
...
...
...
```
### States
```
State.LOADING,
State.EMPTY,
State.CONTENT
```
### Changing States
```kotlin
btnLoading.setOnClickListener {
multiStateLayout.setState(MultiStateLayout.State.LOADING)
}btnContent.setOnClickListener {
multiStateLayout.setState(MultiStateLayout.State.CONTENT)
}btnEmpty.setOnClickListener {
multiStateLayout.setState(MultiStateLayout.State.EMPTY)
}
```For a complete example see the sample app `https://github.com/islamdidarmd/Multistate-Layout/tree/master/app`