├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── weavey
│ │ └── loadinglayout
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── weavey
│ │ │ └── loadinglayout
│ │ │ ├── App.java
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── anim
│ │ └── progressbar.xml
│ │ ├── drawable
│ │ └── progressbar.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── define_loading_page.xml
│ │ └── define_loading_page2.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ ├── define_empty.png
│ │ ├── define_error.png
│ │ ├── define_nonetwork.png
│ │ ├── ic_launcher.png
│ │ └── loading.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── weavey
│ └── loadinglayout
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── loadinglib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── weavey
│ │ └── loading
│ │ └── lib
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── weavey
│ │ │ └── loading
│ │ │ └── lib
│ │ │ ├── LoadingLayout.java
│ │ │ └── Utils.java
│ └── res
│ │ ├── drawable
│ │ └── selector_btn_back_gray.xml
│ │ ├── layout
│ │ ├── widget_empty_page.xml
│ │ ├── widget_error_page.xml
│ │ ├── widget_loading_page.xml
│ │ └── widget_nonetwork_page.xml
│ │ ├── mipmap-xhdpi
│ │ ├── empty.png
│ │ ├── error.png
│ │ └── no_network.png
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── color.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── weavey
│ └── loading
│ └── lib
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Android template
3 | # Built application files
4 | *.apk
5 | *.ap_
6 |
7 | # Files for the ART/Dalvik VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 | out/
17 |
18 | # Gradle files
19 | .gradle/
20 | build/
21 |
22 | # Local configuration file (sdk path, etc)
23 | local.properties
24 |
25 | # Proguard folder generated by Eclipse
26 | proguard/
27 |
28 | # Log Files
29 | *.log
30 |
31 | # Android Studio Navigation editor temp files
32 | .navigation/
33 |
34 | # Android Studio captures folder
35 | captures/
36 |
37 | # Intellij
38 | *.iml
39 | .idea/workspace.xml
40 | .idea/tasks.xml
41 | .idea/gradle.xml
42 | .idea/dictionaries
43 | .idea/libraries
44 |
45 | # Keystore files
46 | *.jks
47 |
48 | # External native build folder generated in Android Studio 2.2 and later
49 | .externalNativeBuild
50 |
51 | # Google Services (e.g. APIs or Firebase)
52 | google-services.json
53 |
54 | # Freeline
55 | freeline.py
56 | freeline/
57 | freeline_project_description.json
58 |
59 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
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 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 已停止维护,慎用!!!!!!!!!
2 |
3 |
4 | [LoadingLayout详细介绍](https://weavey.github.io/2016/11/28/%E7%9B%B4%E6%8E%A5%E6%8B%BF%E5%8E%BB%E7%94%A8%E4%B9%8BLoadingLayout/)
5 |
6 | gradle 引用(最新版本)
7 | > compile ‘com.lai.weavey:loadinglayout:1.3.1’
8 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Android template
3 | # Built application files
4 | *.apk
5 | *.ap_
6 |
7 | # Files for the ART/Dalvik VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 | out/
17 |
18 | # Gradle files
19 | .gradle/
20 | build/
21 |
22 | # Local configuration file (sdk path, etc)
23 | local.properties
24 |
25 | # Proguard folder generated by Eclipse
26 | proguard/
27 |
28 | # Log Files
29 | *.log
30 |
31 | # Android Studio Navigation editor temp files
32 | .navigation/
33 |
34 | # Android Studio captures folder
35 | captures/
36 |
37 | # Intellij
38 | *.iml
39 | .idea/workspace.xml
40 | .idea/tasks.xml
41 | .idea/gradle.xml
42 | .idea/dictionaries
43 | .idea/libraries
44 |
45 | # Keystore files
46 | *.jks
47 |
48 | # External native build folder generated in Android Studio 2.2 and later
49 | .externalNativeBuild
50 |
51 | # Google Services (e.g. APIs or Firebase)
52 | google-services.json
53 |
54 | # Freeline
55 | freeline.py
56 | freeline/
57 | freeline_project_description.json
58 |
59 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion '25.0.3'
6 | defaultConfig {
7 | applicationId "com.weavey.loadinglayout"
8 | minSdkVersion 15
9 | targetSdkVersion 21
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.define_loading_page.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | // androidTestCompile('com.android.support.define_loading_page.espresso:espresso-core:2.2.2', {
25 | // exclude group: 'com.android.support', module: 'support-annotations'
26 | // })
27 | compile 'com.android.support:appcompat-v7:23.2.1'
28 | testCompile 'junit:junit:4.12'
29 | compile project(':loadinglib')
30 | }
31 |
--------------------------------------------------------------------------------
/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:\mycodingapp\android\android_sdkV24_2/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/androidTest/java/com/weavey/loadinglayout/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.weavey.loadinglayout;
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 | * Instrumentation define_loading_page, 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 define_loading_page.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.weavey.loadinglayout", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/weavey/loadinglayout/App.java:
--------------------------------------------------------------------------------
1 | package com.weavey.loadinglayout;
2 |
3 | import android.app.Application;
4 |
5 | import com.weavey.loading.lib.LoadingLayout;
6 |
7 | /**
8 | * Created by weavey
9 | * on 2016-11-23.
10 | * todo
11 | */
12 |
13 | public class App extends Application {
14 |
15 | @Override
16 | public void onCreate() {
17 | super.onCreate();
18 |
19 | LoadingLayout.getConfig()
20 | .setErrorText("出错啦~请稍后重试!")
21 | .setEmptyText("抱歉,暂无数据")
22 | .setNoNetworkText("无网络连接,请检查您的网络···")
23 | .setErrorImage(R.mipmap.define_error)
24 | .setEmptyImage(R.mipmap.define_empty)
25 | .setNoNetworkImage(R.mipmap.define_nonetwork)
26 | .setAllTipTextColor(R.color.gray)
27 | .setAllTipTextSize(14)
28 | .setReloadButtonText("点我重试哦")
29 | .setReloadButtonTextSize(14)
30 | .setReloadButtonTextColor(R.color.gray)
31 | .setReloadButtonWidthAndHeight(150,40)
32 | .setAllPageBackgroundColor(R.color.background);
33 | // .setLoadingPageLayout(R.layout.define_loading_page)
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/weavey/loadinglayout/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.weavey.loadinglayout;
2 |
3 | import android.os.Handler;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.widget.Toast;
9 |
10 | import com.weavey.loading.lib.LoadingLayout;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | private LoadingLayout loading;
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_main);
19 |
20 | loading = (LoadingLayout) findViewById(R.id.loading);
21 | loading.setLoadingPage(R.layout.define_loading_page).setOnReloadListener(new LoadingLayout.OnReloadListener() {
22 |
23 | @Override
24 | public void onReload(View v) {
25 |
26 | Toast.makeText(MainActivity.this, "重试", Toast.LENGTH_SHORT).show();
27 | }
28 | });
29 |
30 | loading.setStatus(LoadingLayout.Loading);
31 | new Handler().postDelayed(new Runnable() {
32 | @Override
33 | public void run() {
34 |
35 | loading.setStatus(LoadingLayout.Empty);
36 | }
37 | },2000);
38 |
39 | new Handler().postDelayed(new Runnable() {
40 | @Override
41 | public void run() {
42 |
43 | loading.setStatus(LoadingLayout.Error);
44 | }
45 | },4000);
46 |
47 |
48 | new Handler().postDelayed(new Runnable() {
49 | @Override
50 | public void run() {
51 |
52 | loading.setStatus(LoadingLayout.No_Network);
53 | }
54 | },6000);
55 |
56 | new Handler().postDelayed(new Runnable() {
57 | @Override
58 | public void run() {
59 |
60 | loading.setStatus(LoadingLayout.Success);
61 | }
62 | },8000);
63 |
64 | new Handler().postDelayed(new Runnable() {
65 | @Override
66 | public void run() {
67 |
68 | loading.setStatus(LoadingLayout.Loading);
69 | }
70 | },10000);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/progressbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/progressbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/define_loading_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/define_loading_page2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/define_empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/app/src/main/res/mipmap-xhdpi/define_empty.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/define_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/app/src/main/res/mipmap-xhdpi/define_error.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/define_nonetwork.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/app/src/main/res/mipmap-xhdpi/define_nonetwork.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/app/src/main/res/mipmap-xhdpi/loading.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #898989
7 | #f2f2f2
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LoadingLayoutDemo
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/test/java/com/weavey/loadinglayout/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.weavey.loadinglayout;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit define_loading_page, 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 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | jcenter()
5 | }
6 | dependencies {
7 | classpath 'com.android.tools.build:gradle:2.3.1'
8 |
9 | // NOTE: Do not place your application dependencies here; they belong
10 | // in the individual module build.gradle files
11 | }
12 | }
13 | allprojects {
14 | repositories {
15 | jcenter()
16 | }
17 | }
18 | task clean(type: Delete) {
19 | delete rootProject.buildDir
20 | }
21 |
22 | dependencies {
23 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jun 21 18:20:09 SGT 2017
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/loadinglib/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Android template
3 | # Built application files
4 | *.apk
5 | *.ap_
6 |
7 | # Files for the ART/Dalvik VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 | out/
17 |
18 | # Gradle files
19 | .gradle/
20 | build/
21 |
22 | # Local configuration file (sdk path, etc)
23 | local.properties
24 |
25 | # Proguard folder generated by Eclipse
26 | proguard/
27 |
28 | # Log Files
29 | *.log
30 |
31 | # Android Studio Navigation editor temp files
32 | .navigation/
33 |
34 | # Android Studio captures folder
35 | captures/
36 |
37 | # Intellij
38 | *.iml
39 | .idea/workspace.xml
40 | .idea/tasks.xml
41 | .idea/gradle.xml
42 | .idea/dictionaries
43 | .idea/libraries
44 |
45 | # Keystore files
46 | *.jks
47 |
48 | # External native build folder generated in Android Studio 2.2 and later
49 | .externalNativeBuild
50 |
51 | # Google Services (e.g. APIs or Firebase)
52 | google-services.json
53 |
54 | # Freeline
55 | freeline.py
56 | freeline/
57 | freeline_project_description.json
58 |
59 |
--------------------------------------------------------------------------------
/loadinglib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 |
5 | PUBLISH_GROUP_ID = 'com.lai.weavey'
6 | PUBLISH_ARTIFACT_ID = 'loadinglayout'
7 | PUBLISH_VERSION = '1.3.2'
8 | }
9 |
10 | android {
11 | compileSdkVersion 23
12 | buildToolsVersion '25.0.3'
13 |
14 | defaultConfig {
15 | minSdkVersion 14
16 | targetSdkVersion 21
17 | versionCode 1
18 | versionName "1.0"
19 |
20 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
21 |
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | }
30 |
31 | dependencies {
32 | compile fileTree(include: ['*.jar'], dir: 'libs')
33 | compile 'com.android.support:appcompat-v7:23.2.1'
34 | testCompile 'junit:junit:4.12'
35 | }
36 |
37 | //apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
38 |
--------------------------------------------------------------------------------
/loadinglib/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:\mycodingapp\android\android_sdkV24_2/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 |
--------------------------------------------------------------------------------
/loadinglib/src/androidTest/java/com/weavey/loading/lib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.weavey.loading.lib;
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 | * Instrumentation 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.weavey.loading.lib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/loadinglib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/loadinglib/src/main/java/com/weavey/loading/lib/LoadingLayout.java:
--------------------------------------------------------------------------------
1 | package com.weavey.loading.lib;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Color;
6 | import android.support.annotation.ColorRes;
7 | import android.support.annotation.DimenRes;
8 | import android.support.annotation.DrawableRes;
9 | import android.support.annotation.IntDef;
10 | import android.support.annotation.LayoutRes;
11 | import android.support.annotation.NonNull;
12 | import android.util.AttributeSet;
13 | import android.view.LayoutInflater;
14 | import android.view.View;
15 | import android.widget.FrameLayout;
16 | import android.widget.ImageView;
17 | import android.widget.TextView;
18 |
19 |
20 | /**
21 | * create by Weavey
22 | * on date 2016-03-12
23 | * TODO
24 | */
25 | public class LoadingLayout extends FrameLayout {
26 |
27 | public final static int Success = 0;
28 | public final static int Empty = 1;
29 | public final static int Error = 2;
30 | public final static int No_Network = 3;
31 | public final static int Loading = 4;
32 | private int state;
33 |
34 | private Context mContext;
35 | private View loadingPage;
36 | private View errorPage;
37 | private View emptyPage;
38 | private View networkPage;
39 | private View defineLoadingPage;
40 |
41 | private ImageView errorImg;
42 | private ImageView emptyImg;
43 | private ImageView networkImg;
44 |
45 | private TextView errorText;
46 | private TextView emptyText;
47 | private TextView networkText;
48 |
49 | private TextView errorReloadBtn;
50 | private TextView networkReloadBtn;
51 |
52 | private View contentView;
53 | private OnReloadListener listener;
54 | private boolean isFirstVisible; //是否一开始显示contentview,默认不显示
55 | private int pageBackground;
56 | private static Config mConfig = new Config(); //配置
57 |
58 | public LoadingLayout(Context context, AttributeSet attrs) {
59 | super(context, attrs);
60 | this.mContext = context;
61 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LoadingLayout);
62 | isFirstVisible = a.getBoolean(R.styleable.LoadingLayout_isFirstVisible, false);
63 | pageBackground = a.getColor(R.styleable.LoadingLayout_pageBackground, Utils.getColor(mContext, R.color
64 | .base_loading_background));
65 | a.recycle();
66 | }
67 |
68 | public LoadingLayout(Context context, AttributeSet attrs, int defStyleAttr) {
69 | super(context, attrs, defStyleAttr);
70 | this.mContext = context;
71 | }
72 |
73 | public LoadingLayout(Context context) {
74 | super(context);
75 | this.mContext = context;
76 | }
77 |
78 | @Override
79 | protected void onFinishInflate() {
80 | super.onFinishInflate();
81 | if (getChildCount() > 1) {
82 | throw new IllegalStateException("LoadingLayout can host only one direct child");
83 | }
84 | contentView = this.getChildAt(0);
85 | if (!isFirstVisible) {
86 | contentView.setVisibility(View.GONE);
87 | }
88 | build();
89 | }
90 |
91 | private void build() {
92 |
93 | if (mConfig.loadingView == null) {
94 | loadingPage = LayoutInflater.from(mContext).inflate(mConfig.loadingLayoutId, null);
95 | } else {
96 | loadingPage = mConfig.loadingView;
97 | }
98 | errorPage = LayoutInflater.from(mContext).inflate(R.layout.widget_error_page, null);
99 | emptyPage = LayoutInflater.from(mContext).inflate(R.layout.widget_empty_page, null);
100 | networkPage = LayoutInflater.from(mContext).inflate(R.layout.widget_nonetwork_page, null);
101 | defineLoadingPage = null;
102 |
103 | loadingPage.setBackgroundColor(pageBackground);
104 | errorPage.setBackgroundColor(pageBackground);
105 | emptyPage.setBackgroundColor(pageBackground);
106 | networkPage.setBackgroundColor(pageBackground);
107 |
108 | errorText = Utils.findViewById(errorPage, R.id.error_text);
109 | emptyText = Utils.findViewById(emptyPage, R.id.empty_text);
110 | networkText = Utils.findViewById(networkPage, R.id.no_network_text);
111 |
112 | errorImg = Utils.findViewById(errorPage, R.id.error_img);
113 | emptyImg = Utils.findViewById(emptyPage, R.id.empty_img);
114 | networkImg = Utils.findViewById(networkPage, R.id.no_network_img);
115 |
116 | errorReloadBtn = Utils.findViewById(errorPage, R.id.error_reload_btn);
117 | networkReloadBtn = Utils.findViewById(networkPage, R.id.no_network_reload_btn);
118 |
119 | errorReloadBtn.setOnClickListener(new OnClickListener() {
120 | @Override
121 | public void onClick(View v) {
122 |
123 | if (listener != null) {
124 | listener.onReload(v);
125 | }
126 | }
127 | });
128 | networkReloadBtn.setOnClickListener(new OnClickListener() {
129 | @Override
130 | public void onClick(View v) {
131 |
132 | if (listener != null) {
133 | listener.onReload(v);
134 | }
135 | }
136 | });
137 |
138 | errorText.setText(mConfig.errorStr);
139 | emptyText.setText(mConfig.emptyStr);
140 | networkText.setText(mConfig.netwrokStr);
141 |
142 | errorText.setTextSize(mConfig.tipTextSize);
143 | emptyText.setTextSize(mConfig.tipTextSize);
144 | networkText.setTextSize(mConfig.tipTextSize);
145 |
146 | errorText.setTextColor(Utils.getColor(mContext, mConfig.tipTextColor));
147 | emptyText.setTextColor(Utils.getColor(mContext, mConfig.tipTextColor));
148 | networkText.setTextColor(Utils.getColor(mContext, mConfig.tipTextColor));
149 |
150 | errorImg.setImageResource(mConfig.errorImgId);
151 | emptyImg.setImageResource(mConfig.emptyImgId);
152 | networkImg.setImageResource(mConfig.networkImgId);
153 |
154 |
155 | errorReloadBtn.setBackgroundResource(mConfig.reloadBtnId);
156 | networkReloadBtn.setBackgroundResource(mConfig.reloadBtnId);
157 |
158 | errorReloadBtn.setText(mConfig.reloadBtnStr);
159 | networkReloadBtn.setText(mConfig.reloadBtnStr);
160 |
161 | errorReloadBtn.setTextSize(mConfig.buttonTextSize);
162 | networkReloadBtn.setTextSize(mConfig.buttonTextSize);
163 |
164 | errorReloadBtn.setTextColor(Utils.getColor(mContext, mConfig.buttonTextColor));
165 | networkReloadBtn.setTextColor(Utils.getColor(mContext, mConfig.buttonTextColor));
166 |
167 | if (mConfig.buttonHeight != -1) {
168 |
169 | errorReloadBtn.setHeight(Utils.dp2px(mContext, mConfig.buttonHeight));
170 | networkReloadBtn.setHeight(Utils.dp2px(mContext, mConfig.buttonHeight));
171 | }
172 | if (mConfig.buttonWidth != -1) {
173 |
174 | errorReloadBtn.setWidth(Utils.dp2px(mContext, mConfig.buttonWidth));
175 | networkReloadBtn.setWidth(Utils.dp2px(mContext, mConfig.buttonWidth));
176 | }
177 |
178 | this.addView(networkPage);
179 | this.addView(emptyPage);
180 | this.addView(errorPage);
181 | this.addView(loadingPage);
182 | }
183 |
184 | public void setStatus(@Flavour int status) {
185 |
186 | this.state = status;
187 |
188 | switch (status) {
189 | case Success:
190 |
191 | contentView.setVisibility(View.VISIBLE);
192 | emptyPage.setVisibility(View.GONE);
193 | errorPage.setVisibility(View.GONE);
194 | networkPage.setVisibility(View.GONE);
195 | if (defineLoadingPage != null) {
196 |
197 | defineLoadingPage.setVisibility(View.GONE);
198 | } else {
199 | loadingPage.setVisibility(View.GONE);
200 | }
201 | break;
202 |
203 | case Loading:
204 |
205 | contentView.setVisibility(View.GONE);
206 | emptyPage.setVisibility(View.GONE);
207 | errorPage.setVisibility(View.GONE);
208 | networkPage.setVisibility(View.GONE);
209 | if (defineLoadingPage != null) {
210 | defineLoadingPage.setVisibility(View.VISIBLE);
211 | } else {
212 | loadingPage.setVisibility(View.VISIBLE);
213 | }
214 | break;
215 |
216 | case Empty:
217 |
218 | contentView.setVisibility(View.GONE);
219 | emptyPage.setVisibility(View.VISIBLE);
220 | errorPage.setVisibility(View.GONE);
221 | networkPage.setVisibility(View.GONE);
222 | if (defineLoadingPage != null) {
223 | defineLoadingPage.setVisibility(View.GONE);
224 | } else {
225 | loadingPage.setVisibility(View.GONE);
226 | }
227 | break;
228 |
229 | case Error:
230 |
231 | contentView.setVisibility(View.GONE);
232 | loadingPage.setVisibility(View.GONE);
233 | emptyPage.setVisibility(View.GONE);
234 | errorPage.setVisibility(View.VISIBLE);
235 | networkPage.setVisibility(View.GONE);
236 | if (defineLoadingPage != null) {
237 | defineLoadingPage.setVisibility(View.GONE);
238 | } else {
239 | loadingPage.setVisibility(View.GONE);
240 | }
241 | break;
242 |
243 | case No_Network:
244 |
245 | contentView.setVisibility(View.GONE);
246 | loadingPage.setVisibility(View.GONE);
247 | emptyPage.setVisibility(View.GONE);
248 | errorPage.setVisibility(View.GONE);
249 | networkPage.setVisibility(View.VISIBLE);
250 | if (defineLoadingPage != null) {
251 |
252 | defineLoadingPage.setVisibility(View.GONE);
253 | } else {
254 | loadingPage.setVisibility(View.GONE);
255 | }
256 | break;
257 |
258 | default:
259 | break;
260 | }
261 |
262 | }
263 |
264 | /**
265 | * 返回当前状态{Success, Empty, Error, No_Network, Loading}
266 | *
267 | * @return
268 | */
269 | public int getStatus() {
270 |
271 | return state;
272 | }
273 |
274 | /**
275 | * 设置Empty状态提示文本,仅对当前所在的地方有效
276 | *
277 | * @param text
278 | * @return
279 | */
280 | public LoadingLayout setEmptyText(String text) {
281 |
282 | emptyText.setText(text);
283 | return this;
284 | }
285 |
286 | /**
287 | * 设置Error状态提示文本,仅对当前所在的地方有效
288 | *
289 | * @param text
290 | * @return
291 | */
292 | public LoadingLayout setErrorText(String text) {
293 |
294 | errorText.setText(text);
295 | return this;
296 | }
297 |
298 | /**
299 | * 设置No_Network状态提示文本,仅对当前所在的地方有效
300 | *
301 | * @param text
302 | * @return
303 | */
304 | public LoadingLayout setNoNetworkText(String text) {
305 |
306 | networkText.setText(text);
307 | return this;
308 | }
309 |
310 | /**
311 | * 设置Empty状态显示图片,仅对当前所在的地方有效
312 | *
313 | * @param id
314 | * @return
315 | */
316 | public LoadingLayout setEmptyImage(@DrawableRes int id) {
317 |
318 |
319 | emptyImg.setImageResource(id);
320 | return this;
321 | }
322 |
323 | /**
324 | * 设置Error状态显示图片,仅对当前所在的地方有效
325 | *
326 | * @param id
327 | * @return
328 | */
329 | public LoadingLayout setErrorImage(@DrawableRes int id) {
330 |
331 | errorImg.setImageResource(id);
332 | return this;
333 | }
334 |
335 | /**
336 | * 设置No_Network状态显示图片,仅对当前所在的地方有效
337 | *
338 | * @param id
339 | * @return
340 | */
341 | public LoadingLayout setNoNetworkImage(@DrawableRes int id) {
342 |
343 | networkImg.setImageResource(id);
344 | return this;
345 | }
346 |
347 | /**
348 | * 设置Empty状态提示文本的字体大小,仅对当前所在的地方有效
349 | *
350 | * @param sp
351 | * @return
352 | */
353 | public LoadingLayout setEmptyTextSize(int sp) {
354 |
355 | emptyText.setTextSize(sp);
356 | return this;
357 | }
358 |
359 | /**
360 | * 设置Error状态提示文本的字体大小,仅对当前所在的地方有效
361 | *
362 | * @param sp
363 | * @return
364 | */
365 | public LoadingLayout setErrorTextSize(int sp) {
366 |
367 | errorText.setTextSize(sp);
368 | return this;
369 | }
370 |
371 | /**
372 | * 设置No_Network状态提示文本的字体大小,仅对当前所在的地方有效
373 | *
374 | * @param sp
375 | * @return
376 | */
377 | public LoadingLayout setNoNetworkTextSize(int sp) {
378 |
379 | networkText.setTextSize(sp);
380 | return this;
381 | }
382 |
383 | /**
384 | * 设置Empty状态图片的显示与否,仅对当前所在的地方有效
385 | *
386 | * @param bool
387 | * @return
388 | */
389 | public LoadingLayout setEmptyImageVisible(boolean bool) {
390 |
391 | if (bool) {
392 | emptyImg.setVisibility(View.VISIBLE);
393 | } else {
394 | emptyImg.setVisibility(View.GONE);
395 | }
396 | return this;
397 | }
398 |
399 | /**
400 | * 设置Error状态图片的显示与否,仅对当前所在的地方有效
401 | *
402 | * @param bool
403 | * @return
404 | */
405 | public LoadingLayout setErrorImageVisible(boolean bool) {
406 |
407 | if (bool) {
408 | errorImg.setVisibility(View.VISIBLE);
409 | } else {
410 | errorImg.setVisibility(View.GONE);
411 | }
412 | return this;
413 | }
414 |
415 | /**
416 | * 设置No_Network状态图片的显示与否,仅对当前所在的地方有效
417 | *
418 | * @param bool
419 | * @return
420 | */
421 | public LoadingLayout setNoNetworkImageVisible(boolean bool) {
422 |
423 | if (bool) {
424 | networkImg.setVisibility(View.VISIBLE);
425 | } else {
426 | networkImg.setVisibility(View.GONE);
427 | }
428 | return this;
429 | }
430 |
431 | /**
432 | * 设置ReloadButton的文本,仅对当前所在的地方有效
433 | *
434 | * @param text
435 | * @return
436 | */
437 | public LoadingLayout setReloadButtonText(@NonNull String text) {
438 |
439 | errorReloadBtn.setText(text);
440 | networkReloadBtn.setText(text);
441 | return this;
442 | }
443 |
444 | /**
445 | * 设置ReloadButton的文本字体大小,仅对当前所在的地方有效
446 | *
447 | * @param sp
448 | * @return
449 | */
450 | public LoadingLayout setReloadButtonTextSize(int sp) {
451 |
452 | errorReloadBtn.setTextSize(sp);
453 | networkReloadBtn.setTextSize(sp);
454 | return this;
455 | }
456 |
457 | /**
458 | * 设置ReloadButton的文本颜色,仅对当前所在的地方有效
459 | *
460 | * @param id
461 | * @return
462 | */
463 | public LoadingLayout setReloadButtonTextColor(@ColorRes int id) {
464 |
465 | errorReloadBtn.setTextColor(Utils.getColor(mContext, id));
466 | networkReloadBtn.setTextSize(Utils.getColor(mContext, id));
467 | return this;
468 | }
469 |
470 | /**
471 | * 设置ReloadButton的背景,仅对当前所在的地方有效
472 | *
473 | * @param id
474 | * @return
475 | */
476 | public LoadingLayout setReloadButtonBackgroundResource(@DrawableRes int id) {
477 |
478 | errorReloadBtn.setBackgroundResource(id);
479 | networkReloadBtn.setBackgroundResource(id);
480 | return this;
481 | }
482 |
483 | /**
484 | * 设置ReloadButton的监听器
485 | *
486 | * @param listener
487 | * @return
488 | */
489 | public LoadingLayout setOnReloadListener(OnReloadListener listener) {
490 |
491 | this.listener = listener;
492 | return this;
493 | }
494 |
495 | /**
496 | * 自定义加载页面,仅对当前所在的Activity有效
497 | *
498 | * @param view
499 | * @return
500 | */
501 | public LoadingLayout setLoadingPage(View view) {
502 |
503 | defineLoadingPage = view;
504 | this.removeView(loadingPage);
505 | defineLoadingPage.setVisibility(View.GONE);
506 | this.addView(view);
507 | return this;
508 | }
509 |
510 | /**
511 | * 自定义加载页面,仅对当前所在的地方有效
512 | *
513 | * @param id
514 | * @return
515 | */
516 | public LoadingLayout setLoadingPage(@LayoutRes int id) {
517 |
518 | this.removeView(loadingPage);
519 | View view = LayoutInflater.from(mContext).inflate(id, null);
520 | defineLoadingPage = view;
521 | defineLoadingPage.setVisibility(View.GONE);
522 | this.addView(view);
523 | return this;
524 | }
525 |
526 | /**
527 | * 设置各种状态下view的背景色,仅对当前所在的地方有效
528 | *
529 | * @param color
530 | * @return
531 | */
532 | public LoadingLayout setDefineBackgroundColor(@ColorRes int color) {
533 |
534 | if (defineLoadingPage == null) {
535 | loadingPage.setBackgroundColor(Utils.getColor(mContext, color));
536 | } else {
537 | defineLoadingPage.setBackgroundColor(Utils.getColor(mContext, color));
538 | }
539 | errorPage.setBackgroundColor(Utils.getColor(mContext, color));
540 | emptyPage.setBackgroundColor(Utils.getColor(mContext, color));
541 | networkPage.setBackgroundColor(Utils.getColor(mContext, color));
542 | return this;
543 | }
544 |
545 | /**
546 | * 获取当前自定义的loadingpage
547 | *
548 | * @return
549 | */
550 | public View getLoadingPage() {
551 |
552 | return defineLoadingPage;
553 | }
554 |
555 | /**
556 | * 获取全局使用的loadingpage
557 | *
558 | * @return
559 | */
560 | public View getGlobalLoadingPage() {
561 |
562 | return loadingPage;
563 | }
564 |
565 | @IntDef({Success, Empty, Error, No_Network, Loading})
566 | public @interface Flavour {
567 |
568 | }
569 |
570 | public interface OnReloadListener {
571 |
572 | void onReload(View v);
573 | }
574 |
575 | /**
576 | * 获取全局配置的class
577 | *
578 | * @return
579 | */
580 | public static Config getConfig() {
581 |
582 | return mConfig;
583 | }
584 |
585 | /**
586 | * 全局配置的Class,对所有使用到的地方有效
587 | */
588 | public static class Config {
589 |
590 | String emptyStr = "暂无数据";
591 | String errorStr = "加载失败,请稍后重试···";
592 | String netwrokStr = "无网络连接,请检查网络···";
593 | String reloadBtnStr = "点击重试";
594 | int emptyImgId = R.mipmap.empty;
595 | int errorImgId = R.mipmap.error;
596 | int networkImgId = R.mipmap.no_network;
597 | int reloadBtnId = R.drawable.selector_btn_back_gray;
598 | int tipTextSize = 14;
599 | int buttonTextSize = 14;
600 | int tipTextColor = R.color.base_text_color_light;
601 | int buttonTextColor = R.color.base_text_color_light;
602 | int buttonWidth = -1;
603 | int buttonHeight = -1;
604 | int loadingLayoutId = R.layout.widget_loading_page;
605 | View loadingView = null;
606 | int backgroundColor = R.color.base_loading_background;
607 |
608 | public Config setErrorText(@NonNull String text) {
609 |
610 | errorStr = text;
611 | return mConfig;
612 | }
613 |
614 | public Config setEmptyText(@NonNull String text) {
615 |
616 | emptyStr = text;
617 | return mConfig;
618 | }
619 |
620 | public Config setNoNetworkText(@NonNull String text) {
621 |
622 | netwrokStr = text;
623 | return mConfig;
624 | }
625 |
626 | public Config setReloadButtonText(@NonNull String text) {
627 |
628 | reloadBtnStr = text;
629 | return mConfig;
630 | }
631 |
632 | /**
633 | * 设置所有提示文本的字体大小
634 | *
635 | * @param sp
636 | * @return
637 | */
638 | public Config setAllTipTextSize(int sp) {
639 |
640 | tipTextSize = sp;
641 | return mConfig;
642 | }
643 |
644 | /**
645 | * 设置所有提示文本的字体颜色
646 | *
647 | * @param color
648 | * @return
649 | */
650 | public Config setAllTipTextColor(@ColorRes int color) {
651 |
652 | tipTextColor = color;
653 | return mConfig;
654 | }
655 |
656 | public Config setReloadButtonTextSize(int sp) {
657 |
658 | buttonTextSize = sp;
659 | return mConfig;
660 | }
661 |
662 | public Config setReloadButtonTextColor(@ColorRes int color) {
663 |
664 | buttonTextColor = color;
665 | return mConfig;
666 | }
667 |
668 | public Config setReloadButtonBackgroundResource(@DrawableRes int id) {
669 |
670 | reloadBtnId = id;
671 | return mConfig;
672 | }
673 |
674 | public Config setReloadButtonWidthAndHeight(int width_dp, int height_dp) {
675 |
676 | buttonWidth = width_dp;
677 | buttonHeight = height_dp;
678 | return mConfig;
679 | }
680 |
681 | public Config setErrorImage(@DrawableRes int id) {
682 |
683 | errorImgId = id;
684 | return mConfig;
685 | }
686 |
687 | public Config setEmptyImage(@DrawableRes int id) {
688 |
689 | emptyImgId = id;
690 | return this;
691 | }
692 |
693 | public Config setNoNetworkImage(@DrawableRes int id) {
694 |
695 | networkImgId = id;
696 | return mConfig;
697 | }
698 |
699 | public Config setLoadingPageLayout(@LayoutRes int id) {
700 |
701 | loadingLayoutId = id;
702 | return mConfig;
703 | }
704 |
705 | public Config setLoadingPageView(View view) {
706 |
707 | this.loadingView = view;
708 | return mConfig;
709 | }
710 |
711 | public Config setAllPageBackgroundColor(@ColorRes int color) {
712 |
713 | backgroundColor = color;
714 | return mConfig;
715 | }
716 | }
717 | }
718 |
--------------------------------------------------------------------------------
/loadinglib/src/main/java/com/weavey/loading/lib/Utils.java:
--------------------------------------------------------------------------------
1 | package com.weavey.loading.lib;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.Drawable;
5 | import android.support.annotation.ColorRes;
6 | import android.support.annotation.DrawableRes;
7 | import android.support.annotation.StringRes;
8 | import android.support.v4.content.ContextCompat;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 |
13 | /**
14 | * create by Weavey
15 | * on date 2016-01-06
16 | * TODO
17 | */
18 |
19 | public class Utils {
20 |
21 |
22 | public static Drawable getDrawble(Context conetxt, @DrawableRes int id){
23 | return ContextCompat.getDrawable(conetxt,id);
24 | }
25 |
26 | public static int getColor(Context conetxt,@ColorRes int id){
27 | return ContextCompat.getColor(conetxt,id);
28 | }
29 |
30 | public static String getString(Context conetxt,@StringRes int id){
31 | return conetxt.getResources().getString(id);
32 | }
33 |
34 | public static int sp2px(Context context,float spValue) {
35 | final float fontScale = context.getResources().getDisplayMetrics()
36 | .scaledDensity;
37 | return (int) (spValue * fontScale + 0.5f);
38 | }
39 |
40 | public static int dp2px(Context context,int dip) {
41 | final float scale = context.getResources().getDisplayMetrics().density;
42 | return (int) (dip * scale + 0.5f);
43 | }
44 |
45 | public static T findViewById(View v, int id) {
46 |
47 |
48 | return (T) v.findViewById(id);
49 | }
50 |
51 | }
--------------------------------------------------------------------------------
/loadinglib/src/main/res/drawable/selector_btn_back_gray.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
11 |
12 |
13 |
14 | -
15 |
16 |
17 |
18 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/loadinglib/src/main/res/layout/widget_empty_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
16 |
17 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/loadinglib/src/main/res/layout/widget_error_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
24 |
25 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/loadinglib/src/main/res/layout/widget_loading_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/loadinglib/src/main/res/layout/widget_nonetwork_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
24 |
25 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/loadinglib/src/main/res/mipmap-xhdpi/empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/loadinglib/src/main/res/mipmap-xhdpi/empty.png
--------------------------------------------------------------------------------
/loadinglib/src/main/res/mipmap-xhdpi/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/loadinglib/src/main/res/mipmap-xhdpi/error.png
--------------------------------------------------------------------------------
/loadinglib/src/main/res/mipmap-xhdpi/no_network.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weavey/LoadingLayoutDemo/6f42822e68725ad05ad5616b2d2639a6dd0d24d1/loadinglib/src/main/res/mipmap-xhdpi/no_network.png
--------------------------------------------------------------------------------
/loadinglib/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/loadinglib/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #909090
4 | #f7f7f7
5 |
--------------------------------------------------------------------------------
/loadinglib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | loadinglib
3 |
4 |
--------------------------------------------------------------------------------
/loadinglib/src/test/java/com/weavey/loading/lib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.weavey.loading.lib;
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 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':loadinglib'
2 |
--------------------------------------------------------------------------------