Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.MeetMe:Android-MultiStateView:'
}
dependencies {
implementation("com.github.MeetMe:Android-MultiStateView:")
}
<dependency>
<groupId>com.github.MeetMe</groupId>
<artifactId>Android-MultiStateView</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.MeetMe" % "Android-MultiStateView" % ""
:dependencies [[com.github.MeetMe/Android-MultiStateView ""]]
Handles multiple display states for data-centric views
loadingLayout
attribute, or the default layout (res/layout/msv__loading.xml
)The following shows examples (using default layouts) for Loading, General Error, Network Error, and the Content states (where we've made the "Hello World" the content) in respective order.
View
you want to switch out with MultiStateView
, wrap the View
in a MultiStateView
node.MultiStateView
via MultiStateView#getContentView()
and cast that value as needed. There's no good reason to put an android:id
on the child View
.Example
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.meetme.android.multistateview.MultiStateView
android:id="@+id/list_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="match_parent" />
</com.meetme.android.multistateview.MultiStateView>
</LinearLayout>
Example Notes
0. android:id="@+id/list"
was moved from the ListView
to the MultiStateView
0. It was also renamed to list_container
to note that it now is the parent of the ListView
0. Any references in code should now use MultiStateView#getContentView()
casted to ListView
to reference the ListView
child. There's no good reason to put an id
on the ListView
. See below.
ListView list = (ListView) findViewById(R.id.list);
MultiStateView container = (MultiStateView) findViewById(R.id.list_container);
ListView list = (ListView) container.getContentView();
MultiStateView
, use the MultiStateView#setState(State)
method.container.setState(State.LOADING);
res/layout/msv__loading.xml
). To customize, you can add the custom attribute msvLoadingLayout
to the MultiStateView
in XML with a reference to the layout to inflate.Apache 2.0
Copyright 2013 MeetMe, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
To make contributions, fork this repository, commit your changes, and submit a pull request.