├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── custom_test_view.xml │ │ │ │ └── activity_main.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── liyi │ │ │ └── example │ │ │ ├── StatusViewUtil.java │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── liyi │ │ │ └── example │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── liyi │ │ └── example │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── multiple-status-view ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── multiple_empty.png │ │ │ │ ├── multiple_error.png │ │ │ │ └── multiple_network_poor.png │ │ │ ├── values │ │ │ │ └── multiple_status_attrs.xml │ │ │ └── layout │ │ │ │ ├── multiple_view_loading.xml │ │ │ │ ├── multiple_view_empty.xml │ │ │ │ ├── multiple_view_error.xml │ │ │ │ └── multiple_view_network_poor.xml │ │ └── java │ │ │ └── com │ │ │ └── liyi │ │ │ └── multiple │ │ │ ├── ViewHandler.java │ │ │ └── MultipleStatusView.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── liyi │ │ │ └── multiple │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── liyi │ │ └── multiple │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── snapshot └── demo.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── .idea ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml └── misc.xml ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /multiple-status-view/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':multiple-status-view' 2 | -------------------------------------------------------------------------------- /snapshot/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/snapshot/demo.gif -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MultipleStatusView 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /multiple-status-view/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /multiple-status-view/src/main/res/drawable/multiple_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/multiple-status-view/src/main/res/drawable/multiple_empty.png -------------------------------------------------------------------------------- /multiple-status-view/src/main/res/drawable/multiple_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/multiple-status-view/src/main/res/drawable/multiple_error.png -------------------------------------------------------------------------------- /multiple-status-view/src/main/res/drawable/multiple_network_poor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albert-lii/MultipleStatusView/HEAD/multiple-status-view/src/main/res/drawable/multiple_network_poor.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Apr 17 14:14:21 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /multiple-status-view/src/main/java/com/liyi/multiple/ViewHandler.java: -------------------------------------------------------------------------------- 1 | package com.liyi.multiple; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * view 的处理接口 7 | */ 8 | public interface ViewHandler { 9 | 10 | /** 11 | * 可以在本方法中对 view 进行处理 12 | * 13 | * @param viewType view 的类型 14 | * @param view 15 | */ 16 | void handleView(int viewType, View view); 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /multiple-status-view/src/main/res/values/multiple_status_attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/test/java/com/liyi/example/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.liyi.example; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /multiple-status-view/src/test/java/com/liyi/multiple/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.liyi.multiple; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /multiple-status-view/src/main/res/layout/multiple_view_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/custom_test_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /multiple-status-view/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/liyi/example/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.liyi.example; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.liyi.example", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /multiple-status-view/src/androidTest/java/com/liyi/multiple/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.liyi.multiple; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.liyi.multiple.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /multiple-status-view/src/main/res/layout/multiple_view_empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 24 | -------------------------------------------------------------------------------- /multiple-status-view/src/main/res/layout/multiple_view_error.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 24 | -------------------------------------------------------------------------------- /multiple-status-view/src/main/res/layout/multiple_view_network_poor.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 24 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.liyi.example" 7 | minSdkVersion 14 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:26.1.0' 24 | implementation 'com.android.support.constraint:constraint-layout:1.1.0' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 28 | implementation project(':multiple-status-view') 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 1.8 38 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /multiple-status-view/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.novoda.bintray-release' 3 | 4 | def comiple_sdk_version = 25 5 | def support_version = "25.3.1" 6 | def min_sdk_version = 9 7 | def target_sdk_version = 25 8 | def version_code = 2 9 | def version_name = "1.0.1" 10 | 11 | def bintrayRepoName = "android-maven" 12 | def bintrayName = "albertlii" 13 | def bintrayGroupId = "com.liyi.view" 14 | def bintrayArtifactId = "multiple-status-view" 15 | def bintrayDesc = "multiple-status-view" 16 | def bintrayWebSite = "https://github.com/albert-lii/MultipleStatusView" 17 | def bintrayLicences = ['Apache-2.0'] 18 | 19 | android { 20 | compileSdkVersion comiple_sdk_version 21 | 22 | defaultConfig { 23 | minSdkVersion min_sdk_version 24 | targetSdkVersion target_sdk_version 25 | versionCode version_code 26 | versionName version_name 27 | 28 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 29 | } 30 | 31 | buildTypes { 32 | release { 33 | minifyEnabled false 34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 35 | } 36 | } 37 | 38 | } 39 | 40 | dependencies { 41 | implementation fileTree(dir: 'libs', include: ['*.jar']) 42 | 43 | testImplementation 'junit:junit:4.12' 44 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 45 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 46 | implementation 'com.android.support:appcompat-v7:' + support_version 47 | } 48 | 49 | publish { 50 | // bintray 用户名 51 | userOrg = bintrayName 52 | // 要传到的 maven 的名字。你可能有多个 maven,要传哪个写哪个。 53 | repoName = bintrayRepoName 54 | // jcenter 上的路径 55 | groupId = bintrayGroupId 56 | // 项目名称 57 | artifactId = bintrayArtifactId 58 | // 版本号 59 | publishVersion = version_name 60 | // 描述,不重要 61 | desc = bintrayDesc 62 | // 网站,不重要;尽量模拟 github 上的地址 63 | website = bintrayWebSite 64 | licences = bintrayLicences 65 | } 66 | 67 | // 指定编码 68 | tasks.withType(JavaCompile) { 69 | options.encoding = "UTF-8" 70 | } 71 | 72 | // 打包源码 73 | task sourcesJar(type: Jar) { 74 | from android.sourceSets.main.java.srcDirs 75 | classifier = 'sources' 76 | } 77 | 78 | task javadoc(type: Javadoc) { 79 | failOnError false 80 | source = android.sourceSets.main.java.sourceFiles 81 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 82 | classpath += configurations.compile 83 | } 84 | 85 | // 制作文档(Javadoc) 86 | task javadocJar(type: Jar, dependsOn: javadoc) { 87 | classifier = 'javadoc' 88 | from javadoc.destinationDir 89 | } 90 | 91 | artifacts { 92 | archives sourcesJar 93 | archives javadocJar 94 | } 95 | 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/liyi/example/StatusViewUtil.java: -------------------------------------------------------------------------------- 1 | package com.liyi.example; 2 | 3 | import android.view.View; 4 | import android.widget.TextView; 5 | 6 | import com.liyi.multiple.MultipleStatusView; 7 | import com.liyi.multiple.ViewHandler; 8 | 9 | /** 10 | * Created by albertlii on 2018/4/18. 11 | */ 12 | 13 | public class StatusViewUtil { 14 | private MultipleStatusView defaultView, customView; 15 | 16 | public StatusViewUtil(MultipleStatusView defaultView, MultipleStatusView customView) { 17 | this.defaultView = defaultView; 18 | // customView.setView(MultipleStatusView.ViewType.TYPE_LOADING, R.layout.custom_test_view); 19 | // customView.setView(MultipleStatusView.ViewType.TYPE_NETWORK_POOR, R.layout.custom_test_view); 20 | // customView.setView(MultipleStatusView.ViewType.TYPE_EMPTY, R.layout.custom_test_view); 21 | // customView.setView(MultipleStatusView.ViewType.TYPE_ERROR, R.layout.custom_test_view); 22 | // customView.setView(MultipleStatusView.ViewType.TYPE_SPECIFIED, R.layout.custom_test_view); 23 | customView.setView(10, R.layout.custom_test_view); 24 | customView.setView(20, R.layout.custom_test_view); 25 | this.customView = customView; 26 | } 27 | 28 | public void showDefaultView(int viewType) { 29 | defaultView.showView(viewType); 30 | defaultView.setVisibility(View.VISIBLE); 31 | customView.setVisibility(View.GONE); 32 | } 33 | 34 | public void showCustomView(int viewType) { 35 | String desc = "自定义 view 测试"; 36 | switch (viewType) { 37 | case MultipleStatusView.ViewType.TYPE_LOADING: 38 | desc = "TEST === 加载中"; 39 | break; 40 | case MultipleStatusView.ViewType.TYPE_NETWORK_POOR: 41 | desc = "TEST === 网络异常"; 42 | break; 43 | case MultipleStatusView.ViewType.TYPE_EMPTY: 44 | desc = "TEST === 空数据"; 45 | break; 46 | case MultipleStatusView.ViewType.TYPE_ERROR: 47 | desc = "TEST === 加载失败"; 48 | break; 49 | case MultipleStatusView.ViewType.TYPE_SPECIFIED: 50 | desc = "TEST === 自定义 SPECIFIED"; 51 | break; 52 | case 10: 53 | desc = "TEST === 自定义 x10"; 54 | break; 55 | case 20: 56 | desc = "TEST === 自定义 x20"; 57 | break; 58 | } 59 | final String finalDesc = desc; 60 | customView.setHandler(viewType, new ViewHandler() { 61 | @Override 62 | public void handleView(int viewType, View view) { 63 | ((TextView) view.findViewById(R.id.tv_test_desc)).setText(finalDesc); 64 | } 65 | }); 66 | customView.showView(viewType); 67 | customView.setVisibility(View.VISIBLE); 68 | defaultView.setVisibility(View.GONE); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MultipleStatusView 2 | 3 | ![releasesvg] ![apisvg] [![license][licensesvg]][license]   4 | 5 | ## 关于 6 | 一个可以用来切换多种状态视图的view,适用于加载失败状态、空数据状态、网络异常状态等场景,同时支持自定义视图! 7 | 8 | ## 演示 9 | ![demogif] 10 | 11 | ## 添加依赖 12 | - 使用Gradle 13 | ```java 14 |   // 注:如果添加依赖成功,则此句不必添加,此句作用仅为当项目在被审核时,紧急需要使用时添加 15 |   allprojects { 16 | repositories { 17 | ... 18 | // 如果添加依赖时,报找不到项目时(项目正在审核),可以添加此句maven地址,如果找到项目,可不必添加 19 | maven { url "https://dl.bintray.com/albertlii/android-maven/" } 20 | } 21 | } 22 | 23 | dependencies { 24 |         compile 'com.liyi.view:multiple-status-view:1.0.1' 25 | } 26 | ``` 27 | - 使用Maven 28 | ```java 29 | 30 | com.liyi.view 31 | multiple-status-view 32 |      1.0.1 33 | pom 34 | 35 | ``` 36 | 37 | ## 默认提供的类型 38 | | 类型 | 说明 | 39 | |:-------|:------:| 40 | | MultipleStatusView.ViewType.TYPE_LOADING |  加载中 | 41 | | MultipleStatusView.ViewType.TYPE_NETWORK_POOR |  网络异常 | 42 | | MultipleStatusView.ViewType.TYPE_EMPTY |  空数据 | 43 | | MultipleStatusView.ViewType.TYPE_ERROR |  加载失败 | 44 | | MultipleStatusView.ViewType.TYPE_SPECIFIED |  自定义 | 45 | 46 | **除了默认提供的类型,也可自定义类型 47 | 48 | ## 自定义属性 49 | | 属性 | 说明 | 50 | |:-------|:------:| 51 | | loading |  加载中视图 | 52 | | network_poor |  网络异常视图 | 53 | | empty |  空数据视图 | 54 | | error |  加载失败视图 | 55 | | specified |  自定义视图 | 56 | 57 | ##  使用方法 58 | #### 代码中使用 59 | ```Java 60 |  // 显示指定类型的视图 61 |  MultipleStatusView.showView(int viewType) 62 | 63 |  // 动态设置视图 64 |  MultipleStatusView.setView(int viewType,int layoutId) 65 |  MultipleStatusView.setView(int viewType,View view) 66 | 67 |  // 关闭状态视图 68 |  MultipleStatusView.dismiss() 69 | ``` 70 | 71 | #### xml中使用 72 | ```Java 73 | 82 | ``` 83 | 84 | ## 赞赏 85 | 如果你感觉 `MultipleStatusView` 帮助到了你,可以点右上角 "Star" 支持一下哦!:blush: 86 | 87 | ## LICENSE 88 | Copyright 2017 liyi 89 | 90 | Licensed under the Apache License, Version 2.0 (the "License"); 91 | you may not use this file except in compliance with the License. 92 | You may obtain a copy of the License at 93 | 94 | http://www.apache.org/licenses/LICENSE-2.0 95 | 96 | Unless required by applicable law or agreed to in writing, software 97 | distributed under the License is distributed on an "AS IS" BASIS, 98 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 99 | See the License for the specific language governing permissions and 100 | limitations under the License. 101 | 102 | 103 | [releasesvg]:https://img.shields.io/badge/version-1.0.1-brightgreen.svg 104 | [apisvg]: https://img.shields.io/badge/sdk-9+-brightgreen.svg 105 | [licensesvg]: https://img.shields.io/badge/license-Apache--2.0-blue.svg 106 | [license]:http://www.apache.org/licenses/LICENSE-2.0 107 | [statussvg]:https://img.shields.io/librariesio/github/phoenixframework/phoenix.svg 108 | 109 | [demogif]:https://github.com/albert-lii/MultipleStatusView/blob/master/snapshot/demo.gif 110 | -------------------------------------------------------------------------------- /app/src/main/java/com/liyi/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.liyi.example; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | import android.widget.Button; 7 | import android.widget.Toast; 8 | 9 | import com.liyi.multiple.MultipleStatusView; 10 | 11 | public class MainActivity extends Activity implements View.OnClickListener { 12 | private MultipleStatusView defaultView, customView; 13 | private StatusViewUtil util; 14 | 15 | private Button default_loading, default_networkPoor, default_empty, default_error, default_dismiss; 16 | private Button custom_loading, custom_networkPoor, custom_empty, custom_error, 17 | custom_specified, custom_10, custom_20, custom_dismiss; 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_main); 23 | defaultView = findViewById(R.id.multipleStatusView_default); 24 | customView = findViewById(R.id.multipleStatusView_custom); 25 | 26 | default_loading = findViewById(R.id.btn_default_loading); 27 | default_networkPoor = findViewById(R.id.btn_default_networkPoor); 28 | default_empty = findViewById(R.id.btn_default_empty); 29 | default_error = findViewById(R.id.btn_default_error); 30 | default_dismiss = findViewById(R.id.btn_default_dismiss); 31 | 32 | custom_loading = findViewById(R.id.btn_custom_loading); 33 | custom_networkPoor = findViewById(R.id.btn_custom_networkPoor); 34 | custom_empty = findViewById(R.id.btn_custom_empty); 35 | custom_error = findViewById(R.id.btn_custom_error); 36 | custom_specified = findViewById(R.id.btn_custom_specified); 37 | custom_10 = findViewById(R.id.btn_custom_10); 38 | custom_20 = findViewById(R.id.btn_custom_20); 39 | custom_dismiss = findViewById(R.id.btn_custom_dismiss); 40 | 41 | util = new StatusViewUtil(defaultView, customView); 42 | addListeners(); 43 | } 44 | 45 | private void addListeners() { 46 | default_loading.setOnClickListener(this); 47 | default_networkPoor.setOnClickListener(this); 48 | default_empty.setOnClickListener(this); 49 | default_error.setOnClickListener(this); 50 | default_dismiss.setOnClickListener(this); 51 | custom_loading.setOnClickListener(this); 52 | custom_networkPoor.setOnClickListener(this); 53 | custom_empty.setOnClickListener(this); 54 | custom_error.setOnClickListener(this); 55 | custom_specified.setOnClickListener(this); 56 | custom_10.setOnClickListener(this); 57 | custom_20.setOnClickListener(this); 58 | custom_dismiss.setOnClickListener(this); 59 | } 60 | 61 | @Override 62 | public void onClick(View v) { 63 | switch (v.getId()) { 64 | case R.id.btn_default_loading: 65 | util.showDefaultView(MultipleStatusView.ViewType.TYPE_LOADING); 66 | break; 67 | case R.id.btn_default_networkPoor: 68 | util.showDefaultView(MultipleStatusView.ViewType.TYPE_NETWORK_POOR); 69 | break; 70 | case R.id.btn_default_empty: 71 | util.showDefaultView(MultipleStatusView.ViewType.TYPE_EMPTY); 72 | break; 73 | case R.id.btn_default_error: 74 | util.showDefaultView(MultipleStatusView.ViewType.TYPE_ERROR); 75 | break; 76 | case R.id.btn_default_dismiss: 77 | defaultView.dimiss(); 78 | break; 79 | 80 | case R.id.btn_custom_loading: 81 | util.showCustomView(MultipleStatusView.ViewType.TYPE_LOADING); 82 | break; 83 | case R.id.btn_custom_networkPoor: 84 | util.showCustomView(MultipleStatusView.ViewType.TYPE_NETWORK_POOR); 85 | break; 86 | case R.id.btn_custom_empty: 87 | util.showCustomView(MultipleStatusView.ViewType.TYPE_EMPTY); 88 | break; 89 | case R.id.btn_custom_error: 90 | util.showCustomView(MultipleStatusView.ViewType.TYPE_ERROR); 91 | break; 92 | case R.id.btn_custom_specified: 93 | util.showCustomView(MultipleStatusView.ViewType.TYPE_SPECIFIED); 94 | break; 95 | case R.id.btn_custom_10: 96 | util.showCustomView(10); 97 | break; 98 | case R.id.btn_custom_20: 99 | util.showCustomView(20); 100 | break; 101 | case R.id.btn_custom_dismiss: 102 | customView.dimiss(); 103 | break; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 21 | 22 | 26 | 27 | 36 | 37 |