Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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`