├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ └── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── content_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── name
│ │ │ └── quanke
│ │ │ └── app
│ │ │ └── libs
│ │ │ └── emptylayoutsimple
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── name
│ │ │ └── quanke
│ │ │ └── app
│ │ │ └── libs
│ │ │ └── emptylayoutsimple
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── name
│ │ └── quanke
│ │ └── app
│ │ └── libs
│ │ └── emptylayoutsimple
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── emptylayout
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_empty.png
│ │ │ │ ├── ic_error.png
│ │ │ │ ├── ic_loading.png
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_empty.png
│ │ │ │ ├── ic_error.png
│ │ │ │ ├── ic_loading.png
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_empty.png
│ │ │ │ ├── ic_error.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_loading.png
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ ├── view_empty.xml
│ │ │ │ ├── view_error.xml
│ │ │ │ └── view_loading.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── name
│ │ │ └── quanke
│ │ │ └── app
│ │ │ └── libs
│ │ │ └── emptylayout
│ │ │ └── EmptyLayout.java
│ ├── test
│ │ └── java
│ │ │ └── name
│ │ │ └── quanke
│ │ │ └── app
│ │ │ └── libs
│ │ │ └── emptylayout
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── name
│ │ └── quanke
│ │ └── app
│ │ └── libs
│ │ └── emptylayout
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
├── gradle.properties
├── bintray.gradle
└── emptylayout.iml
├── settings.gradle
├── screenshots
├── data.png
├── empty.png
├── error.png
└── loading.png
├── aar
├── emptylayout-debug.aar
└── emptylayout-release.aar
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── local.properties
├── .gitignore
├── gradle.properties
├── EmptyLayout.iml
├── EmptyLayoutSimple.iml
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/emptylayout/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':emptylayout'
2 |
--------------------------------------------------------------------------------
/screenshots/data.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/screenshots/data.png
--------------------------------------------------------------------------------
/screenshots/empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/screenshots/empty.png
--------------------------------------------------------------------------------
/screenshots/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/screenshots/error.png
--------------------------------------------------------------------------------
/screenshots/loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/screenshots/loading.png
--------------------------------------------------------------------------------
/aar/emptylayout-debug.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/aar/emptylayout-debug.aar
--------------------------------------------------------------------------------
/aar/emptylayout-release.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/aar/emptylayout-release.aar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-hdpi/ic_empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-hdpi/ic_empty.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-hdpi/ic_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-hdpi/ic_error.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-mdpi/ic_empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-mdpi/ic_empty.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-mdpi/ic_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-mdpi/ic_error.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-hdpi/ic_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-hdpi/ic_loading.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-mdpi/ic_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-mdpi/ic_loading.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-xhdpi/ic_empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-xhdpi/ic_empty.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-xhdpi/ic_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-xhdpi/ic_error.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/emptylayout/src/main/res/drawable-xhdpi/ic_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanke/AndroidEmptyLayout/HEAD/emptylayout/src/main/res/drawable-xhdpi/ic_loading.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EmptyLayoutSimple
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed May 04 15:11:25 CST 2016
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-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/emptylayout/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/emptylayout/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EmptyLayout
3 | 啥也没有
4 | 请等一等啦ლ(╹◡╹ლ)
5 | 哎呀!发生了一些错误
6 |
7 | 重试
8 | 取消
9 | 重试
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/emptylayout/src/test/java/name/quanke/app/libs/emptylayout/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package name.quanke.app.libs.emptylayout;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/test/java/name/quanke/app/libs/emptylayoutsimple/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package name.quanke.app.libs.emptylayoutsimple;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/emptylayout/src/androidTest/java/name/quanke/app/libs/emptylayout/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package name.quanke.app.libs.emptylayout;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/name/quanke/app/libs/emptylayoutsimple/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package name.quanke.app.libs.emptylayoutsimple;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Fri Dec 11 16:57:33 CST 2015
11 | sdk.dir=/home/quanke/soft/android-sdk-linux
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 |
19 | # Local configuration file (sdk path, etc)
20 | local.properties
21 |
22 | # Proguard folder generated by Eclipse
23 | proguard/
24 |
25 | # Log Files
26 | *.log
27 |
28 | # Android Studio Navigation editor temp files
29 | .navigation/
30 |
31 | # Android Studio captures folder
32 | captures/
33 | /.idea
34 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\sdk\android-sdk-windows/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/emptylayout/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\sdk\android-sdk-windows/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "name.quanke.app.libs.emptylayoutsimple"
9 | minSdkVersion 14
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 |
23 | dependencies {
24 | compile fileTree(include: ['*.jar'], dir: 'libs')
25 | testCompile 'junit:junit:4.12'
26 | compile 'com.android.support:appcompat-v7:23.1.1'
27 | compile 'com.android.support:design:23.1.1'
28 | compile project(':emptylayout')
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/EmptyLayout.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/EmptyLayoutSimple.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/emptylayout/src/main/res/layout/view_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
18 |
19 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/emptylayout/src/main/res/layout/view_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/emptylayout/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 |
4 | group='com.github.quanke'
5 | android {
6 | compileSdkVersion 23
7 | buildToolsVersion "23.0.2"
8 |
9 | defaultConfig {
10 | minSdkVersion 14
11 | targetSdkVersion 23
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 | buildTypes {
16 |
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | buildscript {
25 | repositories {
26 | jcenter()
27 | }
28 | dependencies {
29 | // classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
30 | // classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
31 | // NOTE: Do not place your application dependencies here; they belong
32 | // in the individual module build.gradle files
33 | }
34 | }
35 |
36 | dependencies {
37 | compile fileTree(dir: 'libs', include: ['*.jar'])
38 | testCompile 'junit:junit:4.12'
39 | compile 'com.android.support:appcompat-v7:23.1.1'
40 | }
41 |
42 | //apply from: 'bintray.gradle'
43 |
--------------------------------------------------------------------------------
/emptylayout/src/main/res/layout/view_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
24 |
25 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/emptylayout/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | PROJ_GROUP=quanke.name
21 | PROJ_VERSION=1.0
22 | PROJ_NAME=EmptyLayout
23 | PROJ_WEBSITEURL=https://github.com/quanke/EmptyLayout
24 | PROJ_ISSUETRACKERURL=
25 | PROJ_VCSURL=git@github.com:quanke/EmptyLayout.git
26 | PROJ_DESCRIPTION=android view error empty
27 | PROJ_ARTIFACTID=emptylayout
28 |
29 | DEVELOPER_ID=quanke
30 | DEVELOPER_NAME=quanke
31 | DEVELOPER_EMAIL=609319858@qq.com
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 |
21 |
22 |
28 |
29 |
34 |
35 |
40 |
41 |
46 |
47 |
48 |
49 |
53 |
54 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # EmptyLayout
2 |
3 | ###Android 空页面|错误页面|加载中页面处理,支持所有的布局,使用简单方便
4 |
5 | ## Screenshots ##
6 |    
7 | ## EmptyLayout使用 ##
8 |
9 |
10 | 1.打开 Project root 的 build.gradle
11 |
12 | ```
13 |
14 | allprojects {
15 | repositories {
16 | ...
17 | maven { url "https://jitpack.io" }
18 | }
19 | }
20 |
21 | ```
22 |
23 | 2.增加dependency
24 |
25 | ```
26 |
27 | dependencies {
28 | compile 'com.github.quanke:AndroidEmptyLayout:v1.0.0'
29 | }
30 |
31 | ```
32 |
33 |
34 | 3.在布局文件里增加
35 |
36 | ```
37 |
41 |
42 |
47 |
48 |
49 |
50 | ```
51 |
52 | 4.代码里增加:
53 |
54 | ```
55 | findViewById(R.id.btnLoading).setOnClickListener(new View.OnClickListener() {
56 | @Override
57 | public void onClick(View view) {
58 | emptyLayout.showLoading();
59 | }
60 | });
61 | findViewById(R.id.btnEmpty).setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View view) {
64 | emptyLayout.showEmpty();
65 | }
66 | });
67 | findViewById(R.id.btnError).setOnClickListener(new View.OnClickListener() {
68 | @Override
69 | public void onClick(View view) {
70 | emptyLayout.showError();
71 | }
72 | });
73 | findViewById(R.id.btnData).setOnClickListener(new View.OnClickListener() {
74 | @Override
75 | public void onClick(View view) {
76 | emptyLayout.hide();
77 | }
78 | });
79 | ```
80 |
81 | ```
82 | Copyright 2016 ken.cai (http://quanke.name)
83 |
84 | Licensed under the Apache License, Version 2.0 (the "License");
85 | you may not use this file except in compliance with the License.
86 | You may obtain a copy of the License at
87 | http://www.apache.org/licenses/LICENSE-2.0
88 | Unless required by applicable law or agreed to in writing, software
89 | distributed under the License is distributed on an "AS IS" BASIS,
90 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
91 | See the License for the specific language governing permissions and
92 | limitations under the License.
93 | ```
--------------------------------------------------------------------------------
/app/src/main/java/name/quanke/app/libs/emptylayoutsimple/MainActivity.java:
--------------------------------------------------------------------------------
1 | package name.quanke.app.libs.emptylayoutsimple;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 | import android.widget.TextView;
12 |
13 | import org.w3c.dom.Text;
14 |
15 | import name.quanke.app.libs.emptylayout.EmptyLayout;
16 |
17 | public class MainActivity extends AppCompatActivity {
18 |
19 | private TextView textHello;
20 | private EmptyLayout emptyLayout;
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_main);
26 |
27 | textHello = (TextView) findViewById(R.id.textHello);
28 |
29 | emptyLayout = (EmptyLayout) findViewById(R.id.emptyLayout);
30 |
31 | emptyLayout.setErrorButtonClickListener(new View.OnClickListener() {
32 | @Override
33 | public void onClick(View view) {
34 |
35 | }
36 | });
37 | findViewById(R.id.btnLoading).setOnClickListener(new View.OnClickListener() {
38 | @Override
39 | public void onClick(View view) {
40 | emptyLayout.showLoading();
41 | }
42 | });
43 | findViewById(R.id.btnEmpty).setOnClickListener(new View.OnClickListener() {
44 | @Override
45 | public void onClick(View view) {
46 | emptyLayout.showEmpty();
47 | }
48 | });
49 | findViewById(R.id.btnError).setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View view) {
52 | emptyLayout.showError();
53 | }
54 | });
55 | findViewById(R.id.btnData).setOnClickListener(new View.OnClickListener() {
56 | @Override
57 | public void onClick(View view) {
58 | emptyLayout.hide();
59 | }
60 | });
61 |
62 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
63 | setSupportActionBar(toolbar);
64 |
65 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
66 | fab.setOnClickListener(new View.OnClickListener() {
67 | @Override
68 | public void onClick(View view) {
69 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
70 | .setAction("Action", null).show();
71 | }
72 | });
73 | }
74 |
75 | @Override
76 | public boolean onCreateOptionsMenu(Menu menu) {
77 | // Inflate the menu; this adds items to the action bar if it is present.
78 | getMenuInflater().inflate(R.menu.menu_main, menu);
79 | return true;
80 | }
81 |
82 | @Override
83 | public boolean onOptionsItemSelected(MenuItem item) {
84 | // Handle action bar item clicks here. The action bar will
85 | // automatically handle clicks on the Home/Up button, so long
86 | // as you specify a parent activity in AndroidManifest.xml.
87 | int id = item.getItemId();
88 |
89 | //noinspection SimplifiableIfStatement
90 | if (id == R.id.action_settings) {
91 | return true;
92 | }
93 |
94 | return super.onOptionsItemSelected(item);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/emptylayout/bintray.gradle:
--------------------------------------------------------------------------------
1 | //group = PROJ_GROUP
2 | //version = PROJ_VERSION
3 | //project.archivesBaseName = PROJ_ARTIFACTID
4 | //
5 | //apply plugin: 'com.jfrog.bintray'
6 | //apply plugin: 'com.github.dcendents.android-maven'
7 | //
8 | //task sourcesJar(type: Jar) {
9 | // from android.sourceSets.main.java.srcDirs
10 | // classifier = 'sources'
11 | //}
12 | //
13 | //task javadoc(type: Javadoc) {
14 | // source = android.sourceSets.main.java.srcDirs
15 | // classpath += configurations.compile
16 | // classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
17 | //}
18 | //
19 | //task javadocJar(type: Jar, dependsOn: javadoc) {
20 | // classifier = 'javadoc'
21 | // from javadoc.destinationDir
22 | //}
23 | //
24 | //javadoc {
25 | // options{
26 | // encoding "UTF-8"
27 | // charSet 'UTF-8'
28 | // author true
29 | // version true
30 | // links "http://docs.oracle.com/javase/7/docs/api"
31 | // title PROJ_ARTIFACTID
32 | // }
33 | //}
34 | //
35 | //artifacts {
36 | // archives sourcesJar
37 | // archives javadocJar
38 | //}
39 | //
40 | //install {
41 | // repositories.mavenInstaller {
42 | // pom.project {
43 | // name PROJ_NAME
44 | // description PROJ_DESCRIPTION
45 | // url PROJ_WEBSITEURL
46 | // inceptionYear '2016'
47 | //
48 | // packaging 'aar'
49 | // groupId PROJ_GROUP
50 | // artifactId PROJ_ARTIFACTID
51 | // version PROJ_VERSION
52 | //
53 | // licenses {
54 | // license {
55 | // name 'The Apache Software License, Version 2.0'
56 | // url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
57 | // distribution 'repo'
58 | // }
59 | // }
60 | // scm {
61 | // connection PROJ_VCSURL
62 | // url PROJ_WEBSITEURL
63 | //
64 | // }
65 | // developers {
66 | // developer {
67 | // id DEVELOPER_ID
68 | // name DEVELOPER_NAME
69 | // email DEVELOPER_EMAIL
70 | // }
71 | // }
72 | // }
73 | // }
74 | //}
75 | //
76 | //bintray {
77 | // user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : project.property('BINTRAY_USER')
78 | // key = project.hasProperty('bintrayKey') ? project.property('bintrayKey') : project.property('BINTRAY_KEY')
79 | //
80 | // configurations = ['archives']
81 | //
82 | // dryRun = false
83 | // publish = true
84 | //
85 | // pkg {
86 | // repo = 'maven'
87 | // name = PROJ_NAME
88 | // licenses = ['Apache-2.0']
89 | // vcsUrl = PROJ_VCSURL
90 | // websiteUrl = PROJ_WEBSITEURL
91 | // issueTrackerUrl = PROJ_ISSUETRACKERURL
92 | // publicDownloadNumbers = true
93 | // version {
94 | // name = PROJ_VERSION
95 | // desc = PROJ_DESCRIPTION
96 | // vcsTag = PROJ_VERSION
97 | //
98 | // gpg {
99 | // sign = true
100 | // }
101 | //
102 | // mavenCentralSync {
103 | // sync = project.hasProperty('SONATYPE_USER') && project.hasProperty('SONATYPE_KEY')
104 | // user = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : ""
105 | // password = project.hasProperty('SONATYPE_PASS') ? project.property('SONATYPE_PASS') : ""
106 | // close = '1'
107 | // }
108 | // }
109 | // }
110 | //}
111 | //
112 | ////以下内容用于发布SNAPSHOT版本,如果不需要可以移除。
113 | ////参考自:https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin
114 | //
115 | //apply plugin: "com.jfrog.artifactory"
116 | //artifactory {
117 | // contextUrl = 'http://oss.jfrog.org/artifactory' //The base Artifactory URL if not overridden by the publisher/resolver
118 | // resolve {
119 | // repository {
120 | // repoKey = 'libs-release'
121 | // }
122 | // }
123 | // publish {
124 | // repository {
125 | // repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to
126 | // username = bintray.user
127 | // password = bintray.key
128 | // maven = true
129 | // }
130 | // defaults {
131 | // //这里的名字和前面bintray.configurations的值一致即可,会将其包含的输出上传到jfrog上去
132 | // publishConfigs('archives')
133 | // }
134 | // }
135 | //}
--------------------------------------------------------------------------------
/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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/emptylayout/emptylayout.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/emptylayout/src/main/java/name/quanke/app/libs/emptylayout/EmptyLayout.java:
--------------------------------------------------------------------------------
1 | package name.quanke.app.libs.emptylayout;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.Drawable;
5 | import android.util.AttributeSet;
6 | import android.util.Log;
7 | import android.view.Gravity;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.view.animation.Animation;
12 | import android.view.animation.AnimationUtils;
13 | import android.view.animation.LinearInterpolator;
14 | import android.view.animation.RotateAnimation;
15 | import android.widget.LinearLayout;
16 | import android.widget.RelativeLayout;
17 | import android.widget.TextView;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | /**
23 | * 空页面 错误页面 数据加载中 展示
24 | *
25 | * Created by quanke(http://quanke.name) on 2016/4/5.
26 | */
27 | public class EmptyLayout extends LinearLayout{
28 |
29 | private Animation mLoadingAnimation;
30 |
31 | private ViewGroup mLoadingView;
32 | private ViewGroup mEmptyView;
33 | private ViewGroup mErrorView;
34 |
35 | private TextView mLoadingMessageView;
36 | private TextView mEmptyMessageView;
37 | private TextView mErrorMessageView;
38 |
39 |
40 | private RelativeLayout mEmptyRelativeLayout;
41 | private int mErrorMessageViewId;
42 | private int mEmptyMessageViewId;
43 | private int mLoadingMessageViewId;
44 | private LayoutInflater mInflater;
45 | private boolean mViewsAdded;
46 | private int mLoadingAnimationViewId;
47 | private View.OnClickListener mLoadingButtonClickListener;
48 | private View.OnClickListener mEmptyButtonClickListener;
49 | private View.OnClickListener mErrorButtonClickListener;
50 |
51 |
52 | // ---------------------------
53 | // static variables
54 | // ---------------------------
55 | /**
56 | * The empty state
57 | */
58 | public final static int TYPE_EMPTY = 1;
59 | /**
60 | * The loading state
61 | */
62 | public final static int TYPE_LOADING = 2;
63 | /**
64 | * The error state
65 | */
66 | public final static int TYPE_ERROR = 3;
67 |
68 | // ---------------------------
69 | // default values
70 | // ---------------------------
71 | private int mEmptyType = TYPE_LOADING;
72 | private int mErrorDrawable = R.drawable.ic_error;
73 | private int mEmptyDrawable = R.drawable.ic_empty;
74 | private int mLoadingDrawable = R.drawable.ic_loading;
75 |
76 | private String mErrorMessage = "哎呀!发生了一些错误";
77 | private String mEmptyMessage = "啥也没有";
78 | private String mLoadingMessage = "请等一等啦ლ(╹◡╹ლ)";
79 |
80 | private int mLoadingViewButtonId = R.id.buttonLoading;
81 | private int mErrorViewButtonId = R.id.buttonError;
82 | private int mEmptyViewButtonId = R.id.buttonEmpty;
83 | private boolean mShowEmptyButton = true;
84 | private boolean mShowLoadingButton = true;
85 | private boolean mShowErrorButton = true;
86 |
87 | private List childViews;
88 |
89 |
90 | public EmptyLayout(Context context) {
91 | super(context);
92 | init();
93 | }
94 |
95 |
96 | public EmptyLayout(Context context, AttributeSet attrs) {
97 | super(context, attrs);
98 | init();
99 | }
100 |
101 | public EmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
102 | super(context, attrs, defStyleAttr);
103 | init();
104 | }
105 |
106 | private void init(){
107 | childViews = new ArrayList<>();
108 | // getChildViews();
109 |
110 | mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
111 | }
112 |
113 | // ---------------------------
114 | // getters and setters
115 | // ---------------------------
116 | /**
117 | * Gets the loading layout
118 | * @return the loading layout
119 | */
120 | public ViewGroup getLoadingView() {
121 | return mLoadingView;
122 | }
123 |
124 | /**
125 | * Sets loading layout
126 | * @param loadingView
127 | */
128 | public void setLoadingView(ViewGroup loadingView) {
129 | this.mLoadingView = loadingView;
130 | }
131 |
132 | /**
133 | * Sets loading layout resource
134 | * @param res
135 | */
136 | public void setLoadingViewRes(int res){
137 | this.mLoadingView = (ViewGroup) mInflater.inflate(res, null);
138 | }
139 |
140 | /**
141 | * Gets the empty layout
142 | * @return the empty layout
143 | */
144 | public ViewGroup getEmptyView() {
145 | return mEmptyView;
146 | }
147 |
148 | /**
149 | * Sets empty layout
150 | * @param emptyView
151 | */
152 | public void setEmptyView(ViewGroup emptyView) {
153 | this.mEmptyView = emptyView;
154 | }
155 |
156 | /**
157 | * Sets empty layout resource
158 | * @param res
159 | */
160 | public void setEmptyViewRes(int res){
161 | this.mEmptyView = (ViewGroup) mInflater.inflate(res, null);
162 | }
163 |
164 | /**
165 | * Gets the error layout
166 | * @return the error layout
167 | */
168 | public ViewGroup getErrorView() {
169 | return mErrorView;
170 | }
171 |
172 | /**
173 | * Sets error layout
174 | * @param errorView
175 | */
176 | public void setErrorView(ViewGroup errorView) {
177 | this.mErrorView = errorView;
178 | }
179 |
180 | /**
181 | * Sets error layout resource
182 | * @param res
183 | */
184 | public void setErrorViewRes(int res){
185 | this.mErrorView = (ViewGroup) mInflater.inflate(res, null);
186 | }
187 |
188 | /**
189 | * Gets the loading animation
190 | * @return the loading animation
191 | */
192 | public Animation getLoadingAnimation() {
193 | return mLoadingAnimation;
194 | }
195 |
196 | /**
197 | * Sets the loading animation
198 | * @param animation
199 | */
200 | public void setLoadingAnimation(Animation animation) {
201 | this.mLoadingAnimation = animation;
202 | }
203 |
204 | /**
205 | * Sets the resource of loading animation
206 | * @param animationResource
207 | */
208 | public void setLoadingAnimationRes(int animationResource) {
209 | mLoadingAnimation = AnimationUtils.loadAnimation(getContext(), animationResource);
210 | }
211 |
212 |
213 | /**
214 | * @return
215 | */
216 | public int getEmptyType() {
217 | return mEmptyType;
218 | }
219 |
220 | /**
221 | * @param emptyType
222 | */
223 | public void setEmptyType(int emptyType) {
224 | this.mEmptyType = emptyType;
225 | changeEmptyType();
226 | }
227 |
228 | /**
229 | *
230 | * @return
231 | */
232 | public String getErrorMessage() {
233 | return mErrorMessage;
234 | }
235 |
236 | /**
237 | *
238 | * @param errorMessage the error message
239 | * @param messageViewId
240 | */
241 | public void setErrorMessage(String errorMessage, int messageViewId) {
242 | this.mErrorMessage = errorMessage;
243 | this.mErrorMessageViewId = messageViewId;
244 | }
245 |
246 | /**
247 | *
248 | * @param errorMessage the error message
249 | */
250 | public void setErrorMessage(String errorMessage) {
251 | this.mErrorMessage = errorMessage;
252 | }
253 |
254 | /**
255 | *
256 | * @return
257 | */
258 | public String getEmptyMessage() {
259 | return mEmptyMessage;
260 | }
261 |
262 | /**
263 | *
264 | * @param emptyMessage the message
265 | * @param messageViewId
266 | */
267 | public void setEmptyMessage(String emptyMessage, int messageViewId) {
268 | this.mEmptyMessage = emptyMessage;
269 | this.mEmptyMessageViewId = messageViewId;
270 | }
271 |
272 | /**
273 | *
274 | * @param emptyMessage the message
275 | */
276 | public void setEmptyMessage(String emptyMessage) {
277 | this.mEmptyMessage = emptyMessage;
278 | }
279 |
280 | /**
281 | * Gets the message which will be shown when the list is being loaded
282 | * @return
283 | */
284 | public String getLoadingMessage() {
285 | return mLoadingMessage;
286 | }
287 |
288 | /**
289 | * @param loadingMessage the message
290 | * @param messageViewId
291 | */
292 | public void setLoadingMessage(String loadingMessage, int messageViewId) {
293 | this.mLoadingMessage = loadingMessage;
294 | this.mLoadingMessageViewId = messageViewId;
295 | }
296 |
297 | /**
298 | *
299 | * @param loadingMessage the message
300 | */
301 | public void setLoadingMessage(String loadingMessage) {
302 | this.mLoadingMessage = loadingMessage;
303 | }
304 |
305 | /**
306 | *
307 | * @return
308 | */
309 | public int getLoadingAnimationViewId() {
310 | return mLoadingAnimationViewId;
311 | }
312 |
313 | /**
314 | *
315 | * @param loadingAnimationViewId the id of the view
316 | */
317 | public void setLoadingAnimationViewId(int loadingAnimationViewId) {
318 | this.mLoadingAnimationViewId = loadingAnimationViewId;
319 | }
320 |
321 | /**
322 | * Gets the OnClickListener which perform when LoadingView was click
323 | * @return
324 | */
325 | public View.OnClickListener getLoadingButtonClickListener() {
326 | return mLoadingButtonClickListener;
327 | }
328 |
329 | /**
330 | * Sets the OnClickListener to LoadingView
331 | * @param loadingButtonClickListener OnClickListener Object
332 | */
333 | public void setLoadingButtonClickListener(View.OnClickListener loadingButtonClickListener) {
334 | this.mLoadingButtonClickListener = loadingButtonClickListener;
335 | }
336 |
337 | /**
338 | * Gets the OnClickListener which perform when EmptyView was click
339 | * @return
340 | */
341 | public View.OnClickListener getEmptyButtonClickListener() {
342 | return mEmptyButtonClickListener;
343 | }
344 |
345 | /**
346 | * Sets the OnClickListener to EmptyView
347 | * @param emptyButtonClickListener OnClickListener Object
348 | */
349 | public void setEmptyButtonClickListener(View.OnClickListener emptyButtonClickListener) {
350 | this.mEmptyButtonClickListener = emptyButtonClickListener;
351 | }
352 |
353 | /**
354 | * Gets the OnClickListener which perform when ErrorView was click
355 | * @return
356 | */
357 | public View.OnClickListener getErrorButtonClickListener() {
358 | return mErrorButtonClickListener;
359 | }
360 |
361 | /**
362 | * Sets the OnClickListener to ErrorView
363 | * @param errorButtonClickListener OnClickListener Object
364 | */
365 | public void setErrorButtonClickListener(View.OnClickListener errorButtonClickListener) {
366 | this.mErrorButtonClickListener = errorButtonClickListener;
367 | }
368 |
369 | /**
370 | * Gets if a button is shown in the empty view
371 | * @return if a button is shown in the empty view
372 | */
373 | public boolean isEmptyButtonShown() {
374 | return mShowEmptyButton;
375 | }
376 |
377 | /**
378 | * Sets if a button will be shown in the empty view
379 | * @param showEmptyButton will a button be shown in the empty view
380 | */
381 | public void setShowEmptyButton(boolean showEmptyButton) {
382 | this.mShowEmptyButton = showEmptyButton;
383 | }
384 |
385 | /**
386 | * Gets if a button is shown in the loading view
387 | * @return if a button is shown in the loading view
388 | */
389 | public boolean isLoadingButtonShown() {
390 | return mShowLoadingButton;
391 | }
392 |
393 | /**
394 | * Sets if a button will be shown in the loading view
395 | * @param showLoadingButton will a button be shown in the loading view
396 | */
397 | public void setShowLoadingButton(boolean showLoadingButton) {
398 | this.mShowLoadingButton = showLoadingButton;
399 | }
400 |
401 | /**
402 | * Gets if a button is shown in the error view
403 | * @return if a button is shown in the error view
404 | */
405 | public boolean isErrorButtonShown() {
406 | return mShowErrorButton;
407 | }
408 |
409 | /**
410 | * Sets if a button will be shown in the error view
411 | * @param showErrorButton will a button be shown in the error view
412 | */
413 | public void setShowErrorButton(boolean showErrorButton) {
414 | this.mShowErrorButton = showErrorButton;
415 | }
416 |
417 | /**
418 | * Gets the ID of the button in the loading view
419 | * @return the ID of the button in the loading view
420 | */
421 | public int getmLoadingViewButtonId() {
422 | return mLoadingViewButtonId;
423 | }
424 |
425 | /**
426 | * Sets the ID of the button in the loading view. This ID is required if you want the button the loading view to be click-able.
427 | * @param loadingViewButtonId the ID of the button in the loading view
428 | */
429 | public void setLoadingViewButtonId(int loadingViewButtonId) {
430 | this.mLoadingViewButtonId = loadingViewButtonId;
431 | }
432 |
433 | /**
434 | * Gets the ID of the button in the error view
435 | * @return the ID of the button in the error view
436 | */
437 | public int getErrorViewButtonId() {
438 | return mErrorViewButtonId;
439 | }
440 |
441 | /**
442 | * Sets the ID of the button in the error view. This ID is required if you want the button the error view to be click-able.
443 | * @param errorViewButtonId the ID of the button in the error view
444 | */
445 | public void setErrorViewButtonId(int errorViewButtonId) {
446 | this.mErrorViewButtonId = errorViewButtonId;
447 | }
448 |
449 | /**
450 | * Gets the ID of the button in the empty view
451 | * @return the ID of the button in the empty view
452 | */
453 | public int getEmptyViewButtonId() {
454 | return mEmptyViewButtonId;
455 | }
456 |
457 | /**
458 | * Sets the ID of the button in the empty view. This ID is required if you want the button the empty view to be click-able.
459 | * @param emptyViewButtonId the ID of the button in the empty view
460 | */
461 | public void setEmptyViewButtonId(int emptyViewButtonId) {
462 | this.mEmptyViewButtonId = emptyViewButtonId;
463 | }
464 |
465 |
466 | public int getErrorDrawable() {
467 | return mErrorDrawable;
468 | }
469 |
470 | /**
471 | * 设置错误的图片
472 | * @param mErrorDrawable 错误图片资源id
473 | */
474 | public void setErrorDrawable(int mErrorDrawable) {
475 | this.mErrorDrawable = mErrorDrawable;
476 | }
477 |
478 | public int getEmptyDrawable() {
479 | return mEmptyDrawable;
480 | }
481 |
482 | /**
483 | * 设置空的图片
484 | * @param mEmptyDrawable 错误空资源id
485 | */
486 | public void setEmptyDrawable(int mEmptyDrawable) {
487 | this.mEmptyDrawable = mEmptyDrawable;
488 | }
489 |
490 | public int getLoadingDrawable() {
491 | return mLoadingDrawable;
492 | }
493 |
494 | /**
495 | * 设置Loading的图片
496 | * @param mLoadingDrawable 错误Loading资源id
497 | */
498 | public void setLoadingDrawable(int mLoadingDrawable) {
499 | this.mLoadingDrawable = mLoadingDrawable;
500 | }
501 |
502 | private void getChildViews(){
503 | int childCount = getChildCount();
504 | Log.d("EmptyLayout","ChildCount:"+childCount);
505 | View view;
506 | for (int i=0;i 0) loadingAnimationView = findViewById(mLoadingAnimationViewId);
653 | switch (mEmptyType) {
654 | case TYPE_EMPTY:
655 | if (mEmptyView!=null) mEmptyView.setVisibility(View.VISIBLE);
656 | if (mErrorView!=null) mErrorView.setVisibility(View.GONE);
657 | if (mLoadingView!=null) {
658 | mLoadingView.setVisibility(View.GONE);
659 | if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel();
660 | }
661 | break;
662 | case TYPE_ERROR:
663 | if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE);
664 | if (mErrorView!=null) mErrorView.setVisibility(View.VISIBLE);
665 | if (mLoadingView!=null) {
666 | mLoadingView.setVisibility(View.GONE);
667 | if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel();
668 | }
669 | break;
670 | case TYPE_LOADING:
671 | if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE);
672 | if (mErrorView!=null) mErrorView.setVisibility(View.GONE);
673 | if (mLoadingView!=null) {
674 | mLoadingView.setVisibility(View.VISIBLE);
675 | if (mLoadingAnimation != null && loadingAnimationView!=null) {
676 | loadingAnimationView.startAnimation(mLoadingAnimation);
677 | }
678 | else if (loadingAnimationView!=null) {
679 | loadingAnimationView.startAnimation(getRotateAnimation());
680 | }
681 | }
682 | break;
683 | default:
684 | break;
685 | }
686 | }
687 |
688 | private void refreshMessages() {
689 |
690 | if (mEmptyMessageViewId>0 && mEmptyMessage!=null) {
691 | mEmptyMessageView = ((TextView)mEmptyView.findViewById(mEmptyMessageViewId));
692 | mEmptyMessageView.setText(mEmptyMessage);
693 | setTopDrawables(mEmptyMessageView, mEmptyDrawable);
694 |
695 | }
696 | if (mLoadingMessageViewId>0 && mLoadingMessage!=null) {
697 | mLoadingMessageView = ((TextView)mLoadingView.findViewById(mLoadingMessageViewId));
698 | mLoadingMessageView .setText(mLoadingMessage);
699 | // setTopDrawables(mLoadingMessageView,mLoadingDrawable);// loading 不能已经有loading image view ,不能直接设置TopDrawable
700 | }
701 | if (mErrorMessageViewId>0 && mErrorMessage!=null){
702 | mErrorMessageView = ((TextView)mErrorView.findViewById(mErrorMessageViewId));
703 | mErrorMessageView.setText(mErrorMessage);
704 | setTopDrawables(mErrorMessageView,mErrorDrawable);
705 | }
706 | }
707 |
708 |
709 | private void setTopDrawables(TextView textView,int resId){
710 | Drawable drawable = getResources().getDrawable(resId);
711 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());//必须设置图片大小,否则不显示
712 | textView.setCompoundDrawables(null,drawable,null,null);
713 | }
714 |
715 | private void setDefaultValues() {
716 | if (mEmptyView==null) {
717 | mEmptyView = (ViewGroup) mInflater.inflate(R.layout.view_empty, null);
718 | if (!(mEmptyMessageViewId>0)) mEmptyMessageViewId = R.id.textViewMessage;
719 | if (mShowEmptyButton && mEmptyViewButtonId>0 && mEmptyButtonClickListener!=null) {
720 | View emptyViewButton = mEmptyView.findViewById(mEmptyViewButtonId);
721 | if (emptyViewButton != null) {
722 | emptyViewButton.setOnClickListener(mEmptyButtonClickListener);
723 | emptyViewButton.setVisibility(View.VISIBLE);
724 | }
725 | }
726 | else if (mEmptyViewButtonId>0) {
727 | View emptyViewButton = mEmptyView.findViewById(mEmptyViewButtonId);
728 | emptyViewButton.setVisibility(View.GONE);
729 | }
730 | }
731 | if (mLoadingView==null) {
732 | mLoadingView = (ViewGroup) mInflater.inflate(R.layout.view_loading, null);
733 | mLoadingAnimationViewId = R.id.imageViewLoading;
734 | if (!(mLoadingMessageViewId>0)) mLoadingMessageViewId = R.id.textViewMessage;
735 | if (mShowLoadingButton && mLoadingViewButtonId>0 && mLoadingButtonClickListener!=null) {
736 | View loadingViewButton = mLoadingView.findViewById(mLoadingViewButtonId);
737 | if (loadingViewButton != null) {
738 | loadingViewButton.setOnClickListener(mLoadingButtonClickListener);
739 | loadingViewButton.setVisibility(View.VISIBLE);
740 | }
741 | }
742 | else if (mLoadingViewButtonId>0) {
743 | View loadingViewButton = mLoadingView.findViewById(mLoadingViewButtonId);
744 | loadingViewButton.setVisibility(View.GONE);
745 | }
746 | }
747 | if (mErrorView==null) {
748 | mErrorView = (ViewGroup) mInflater.inflate(R.layout.view_error, null);
749 | if (!(mErrorMessageViewId>0)) mErrorMessageViewId = R.id.textViewMessage;
750 | if (mShowErrorButton && mErrorViewButtonId>0 && mErrorButtonClickListener!=null) {
751 | View errorViewButton = mErrorView.findViewById(mErrorViewButtonId);
752 | if (errorViewButton != null) {
753 | errorViewButton.setOnClickListener(mErrorButtonClickListener);
754 | errorViewButton.setVisibility(View.VISIBLE);
755 | }
756 | }
757 | else if (mErrorViewButtonId>0) {
758 | View errorViewButton = mErrorView.findViewById(mErrorViewButtonId);
759 | errorViewButton.setVisibility(View.GONE);
760 | }
761 | }
762 | }
763 |
764 | private static Animation getRotateAnimation() {
765 | final RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
766 | rotateAnimation.setDuration(1500);
767 | rotateAnimation.setInterpolator(new LinearInterpolator());
768 | rotateAnimation.setRepeatCount(Animation.INFINITE);
769 | return rotateAnimation;
770 | }
771 |
772 | // showEmpty
773 | // showLoading
774 | // showError
775 | // setLoadingView
776 | // setEmptyView
777 | // setErrorView
778 | // setLoadingAnimation
779 | // setErrorMessage
780 | // setLoadingMessage
781 | // setEmptyMessage
782 | // setEmptyViewButtonClickListener
783 | // setLoadingViewButtonClickListener
784 | // setErrorViewButtonClickListener
785 | // setShowEmptyButton
786 | // setShowLoadingButton
787 | // setShowErrorButton
788 | }
789 |
--------------------------------------------------------------------------------