├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ └── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── lzw
│ │ │ └── applicationhelper
│ │ │ ├── App.java
│ │ │ ├── IInitWrapper.java
│ │ │ ├── Contants.java
│ │ │ ├── IInitMethods.java
│ │ │ ├── ApplicationHelper.java
│ │ │ └── InitWrapperImpl.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── lzw
│ │ │ └── applicationhelper
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── lzw
│ │ └── applicationhelper
│ │ └── ExampleInstrumentedTest.java
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── .gitignore
├── gradle.properties
├── README.md
├── gradlew.bat
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ApplicationHelper
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AweiLoveAndroid/ApplicationHelper/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AweiLoveAndroid/ApplicationHelper/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AweiLoveAndroid/ApplicationHelper/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AweiLoveAndroid/ApplicationHelper/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AweiLoveAndroid/ApplicationHelper/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AweiLoveAndroid/ApplicationHelper/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AweiLoveAndroid/ApplicationHelper/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AweiLoveAndroid/ApplicationHelper/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AweiLoveAndroid/ApplicationHelper/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AweiLoveAndroid/ApplicationHelper/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/test/java/com/lzw/applicationhelper/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.lzw.applicationhelper;
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 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/lzw/applicationhelper/App.java:
--------------------------------------------------------------------------------
1 | package com.lzw.applicationhelper;
2 |
3 | import android.app.Application;
4 |
5 | /**
6 | * 自定义的Application
7 | * @author lzw
8 | * @date 2017/12/25
9 | */
10 | public class App extends Application {
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | initThirdLibs();
16 |
17 | }
18 |
19 | /**
20 | * 这里对三方库的进行初始化
21 | * 比如网络框架、图片加载、即时通讯、数据库框架等
22 | * 很简单的几行代码搞定,维护起来也很方便。
23 | */
24 | private void initThirdLibs() {
25 | ApplicationHelper.init(this)
26 | .initNetWork()
27 | .initImageLoader()
28 | .initIM()
29 | .initDataBase();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/lzw/applicationhelper/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.lzw.applicationhelper;
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.lzw.applicationhelper", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.3"
6 | defaultConfig {
7 | applicationId "com.lzw.applicationhelper"
8 | minSdkVersion 19
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.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(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | testCompile 'junit:junit:4.12'
28 | }
29 |
--------------------------------------------------------------------------------
/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 E:\develop\sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lzw/applicationhelper/IInitWrapper.java:
--------------------------------------------------------------------------------
1 | package com.lzw.applicationhelper;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * 具体的执行过程公用的一些接口方法
7 | * @author lzw
8 | * @date 2017/12/25
9 | */
10 | public interface IInitWrapper {
11 | /**
12 | * 初始化传入上下文
13 | * @param context
14 | */
15 | void init(Context context);
16 |
17 | /**
18 | * 设置是哪个库
19 | * @param libName 类型 这个可以在具体的实现类里面定义
20 | */
21 | void setLib(String libName);
22 |
23 | /**
24 | * 获取库
25 | * @return 返回库名
26 | */
27 | String getLib();
28 |
29 | /**
30 | * 设置lib库的版本号
31 | * 比如v2.X就就设置层2.X
32 | * @param version 版本号
33 | */
34 | void setLibVersion(String version);
35 |
36 | /**
37 | * 获取库的版本号
38 | * 通过这个方法就可以判断当前用的库是哪个版本的
39 | * @return 版本号
40 | */
41 | String getLibVersion();
42 |
43 | /**
44 | * 执行库的初始化的具体操作
45 | */
46 | void onExecute();
47 |
48 | /**
49 | * 执行库的初始化的具体操作
50 | * @param type 类型,用于区分是什么类型的框架,比如网络框架还是数据库框架
51 | * @param libName 库名
52 | * @param versionName 库的版本号
53 | */
54 | void execute(int type,String libName,String versionName);
55 | }
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ApplicationHelper
2 |
3 | ----
4 |
5 | #### 快速解耦Application的逻辑,教你实现Application的隔离型框架。当你的项目的Application中要用到很多初始化操作的时候,这个库就能派上用场。目前这个库只针对普通项目,对于组件化或者插件化还没做测试,目前不适用于组件化或者插件化,后续慢慢完善吧。
6 |
7 | ### 详细介绍请看我的博客: [一行代码快速解耦Application逻辑,让Application更简洁好维护](https://www.jianshu.com/p/23b9ba9b685d)
8 |
9 | ----
10 |
11 | ###### 【前言】很多人在开发中使用了大量的第三放的库,或者自己封装的库,很多库都是需要在Application里面配置的,如果配置过多,导致Application过于臃肿,代码不好维护,可读性比较差。下面是我写的一个简单的库,帮你快速解耦Application,让你的Application显得更简洁,更好维护。
12 |
13 | ----
14 |
15 | >###### 1.首先来一张调用的图,如下,是不是很简单:
16 |
17 | 
18 |
19 | ----
20 |
21 | >###### 2.下面看一下ApplicationHelper这个类做了什么事情:
22 |
23 | 这是一个单例的类,调用init方法传入上下文,然后调用init开头的方法,比如initNetWork()就表示初始化网络操作的一些逻辑。
24 |
25 | 
26 |
27 |
28 | ----
29 |
30 | >###### 3.ApplicationHelper实现了IInitMethods接口,这个接口主要用来规范有哪些逻辑要处理,它是初始化的所有方法的顶层接口,用于规范有哪些逻辑需要做,比如网络库,图片库等。
31 |
32 | 
33 |
34 |
35 | ----
36 |
37 | >###### 4.ApplicationHelper类调用了InitWrapperImpl这个类,通过InitWrapperImpl.getInstance()返回一个实例对象,然后调用了init(mContext)方法,传入一个上下文,最后调用execute(XX,XX,XX)执行库的初始化的具体操作。
38 |
39 | 
40 |
41 |
42 |
43 | ----
44 |
45 | >###### 5.InitWrapperImpl这个类里面用到了常量类Contants,主要保存type类型,和库的名字的信息。
46 |
47 | 
48 |
49 | ----
50 |
51 | >###### 6.InitWrapperImpl这个类它是实现了IInitWrapper接口,规范了具体的执行过程公用的一些接口方法。
52 |
53 | 
54 |
55 | ----
56 | ###### 到此,这个库基本就介绍完了,是不是很简单?赶紧用起来吧。
57 |
58 |
59 | ----
60 |
61 | # 觉得不错的朋友们 ,给个`star`支持一下吧。
62 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lzw/applicationhelper/Contants.java:
--------------------------------------------------------------------------------
1 | package com.lzw.applicationhelper;
2 |
3 | /**
4 | * 常量类,主要保存type类型,和库的名字的信息
5 | * @author lzw
6 | * @date 2017/12/25
7 | */
8 | public class Contants {
9 |
10 | public static final int TYPE_NETWORK = 0x0001;
11 | public static final int TYPE_DATABASE = 0x0002;
12 | public static final int TYPE_IMAGE = 0x0003;
13 | public static final int TYPE_SHARE = 0x0004;
14 | public static final int TYPE_PUSH = 0x0005;
15 | public static final int TYPE_LOGIN = 0x0006;
16 | public static final int TYPE_STATISTICS = 0x0007;
17 | public static final int TYPE_IM = 0x0008;
18 | public static final int TYPE_ANNOTATIONS = 0x0009;
19 | public static final int TYPE_INJECTION = 0x0010;
20 | public static final int TYPE_EVENT = 0x0011;
21 | public static final int TYPE_MAP = 0x0012;
22 | public static final int TYPE_PULLREFERSH = 0x0013;
23 | public static final int TYPE_RECYCLERVIRE_HELPER = 0x0014;
24 | public static final int TYPE_SLIDESCROLLMENU = 0x0015;
25 | public static final int TYPE_NOTICESVIEW = 0x0016;
26 | public static final int TYPE_CALENDARVIEW = 0x0017;
27 | public static final int TYPE_DATETIMEVIEW = 0x0018;
28 | public static final int TYPE_CHART = 0x0019;
29 | public static final int TYPE_LOG = 0x0020;
30 | public static final int TYPE_QRCODE = 0x0021;
31 | public static final int TYPE_CARLICENSE_IDENTIFICATION = 0x0022;
32 | public static final int TYPE_FACE_IDENTIFICATION = 0x0023;
33 | public static final int TYPE_IDCARD_IDENTIFICATION = 0x0024;
34 | public static final int TYPE_PHONENUM_IDENTIFICATION = 0x0025;
35 | public static final int TYPE_VOICE = 0x0026;
36 | public static final int TYPE_VIDEO = 0x0027;
37 | public static final int TYPE_VOICEANDVIDEO = 0x0028;
38 | public static final int TYPE_PAY = 0x0029;
39 | public static final int TYPE_OTHER = 0x0030;
40 |
41 | /**
42 | * 网络框架
43 | */
44 | public static final String LIB_NAME_NETWORK_VOLLEY = "Volley";
45 | public static final String LIB_NAME_NETWORK_OKHTTP = "OkHttp";
46 | public static final String LIB_NAME_NETWORK_OKGO = "OkGo";
47 | public static final String LIB_NAME_NETWORK_RETROFIT = "Retrofit";
48 |
49 | /**
50 | * 图片加载框架
51 | */
52 | public static final String LIB_NAME_IMAGE_IMAGELOADER = "ImageLoader";
53 | public static final String LIB_NAME_IMAGE_PICASSO = "Picasso";
54 | public static final String LIB_NAME_IMAGE_GLIDE = "Glide";
55 | /**
56 | * 数据库框架
57 | */
58 | public static final String LIB_NAME_DATABASE_GREENDAO = "GreenDao";
59 | public static final String LIB_NAME_DATABASE_ORMLITE = "OrmLite";
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lzw/applicationhelper/IInitMethods.java:
--------------------------------------------------------------------------------
1 | package com.lzw.applicationhelper;
2 |
3 | /**
4 | * 初始化的所有方法的顶层接口
5 | * @author lzw
6 | * @date 2017/12/25
7 | */
8 | public interface IInitMethods {
9 | /**
10 | * 初始化网络框架的库
11 | */
12 | IInitMethods initNetWork();
13 | /**
14 | * 初始化数据库框架的库
15 | */
16 | IInitMethods initDataBase();
17 | /**
18 | * 初始化图片加载框架的库
19 | */
20 | IInitMethods initImageLoader();
21 | /**
22 | * 初始化分享有关的
23 | */
24 | IInitMethods initShare();
25 | /**
26 | * 初始化推送有关的
27 | */
28 | IInitMethods initPush();
29 | /**
30 | * 初始化第三方登录有关的
31 | */
32 | IInitMethods initLogin();
33 | /**
34 | * 初始化统计有关的
35 | */
36 | IInitMethods initStatistics();
37 | /**
38 | * 初始化即时通讯
39 | */
40 | IInitMethods initIM();
41 | /**
42 | * 初始化注解框架
43 | */
44 | IInitMethods initAnnotationsLib();
45 | /**
46 | * 初始化依赖注入框架
47 | */
48 | IInitMethods initInjectionLib();
49 | /**
50 | * 初始化事件有关的库
51 | */
52 | IInitMethods initEventsLib();
53 | /**
54 | * 初始化地图
55 | */
56 | IInitMethods initMapLib();
57 | /**
58 | * 初始化下拉刷新的库
59 | */
60 | IInitMethods initPullRefresh();
61 | /**
62 | * 初始化RecyclerView的库
63 | */
64 | IInitMethods initRecyclerViewHelper();
65 | /**
66 | * 初始化侧滑菜单的库
67 | */
68 | IInitMethods initSlideScrollMenu();
69 | /**
70 | * 初始化的吐司,弹窗,进度条等提醒性的控件
71 | */
72 | IInitMethods initNoticesView();
73 | /**
74 | * 初始日历的库
75 | */
76 | IInitMethods initCalendarView();
77 | /**
78 | * 初始化日期时间的库
79 | */
80 | IInitMethods initDateTimeView();
81 | /**
82 | * 初始化图表的库
83 | */
84 | IInitMethods initChartLib();
85 | /**
86 | * 初始化打log的库
87 | */
88 | IInitMethods initLogLib();
89 | /**
90 | * 初始化二维码的库
91 | */
92 | IInitMethods initQRCodeLib();
93 | /**
94 | * 初始化车牌识别的库
95 | */
96 | IInitMethods initCarLicenseIdentification();
97 | /**
98 | * 初始化人脸识别的库
99 | */
100 | IInitMethods initFaceIdentification();
101 | /**
102 | * 初始化身份证识别的库
103 | */
104 | IInitMethods initIDCardIdentification();
105 | /**
106 | * 初始化手机号码识别的库
107 | */
108 | IInitMethods initPhoneNumberIdentification();
109 | /**
110 | * 初始化声音有关的库
111 | */
112 | IInitMethods initVoiceLib();
113 | /**
114 | * 初始化视频有关的库
115 | */
116 | IInitMethods initVideoLib();
117 | /**
118 | * 初始化音视频有关的库
119 | */
120 | IInitMethods initVoiceAndVideoLib();
121 | /**
122 | * 初始化支付有关的库
123 | */
124 | IInitMethods initPayLib();
125 | /**
126 | * 初始化其他的库,这里没有列举的可以在这里做初始化操作
127 | */
128 | IInitMethods initOther();
129 | }
130 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lzw/applicationhelper/ApplicationHelper.java:
--------------------------------------------------------------------------------
1 | package com.lzw.applicationhelper;
2 |
3 |
4 | import android.content.Context;
5 |
6 | /**
7 | * 由于开发中Application里面会有很多初始化操作,
8 | * 所以写了一个ApplicationHelper帮助类把这些操作隔离出来。
9 | * @author lzw
10 | * @date 2017/12/25
11 | */
12 | public class ApplicationHelper implements IInitMethods{
13 |
14 | /**
15 | * 【tips】这样写可能会导致内存泄漏。。。
16 | * 【欢迎高手提出更好的解决方案】
17 | */
18 | private static Context mContext;
19 | private static ApplicationHelper mInstance;
20 | private static InitWrapperImpl sInstance;
21 |
22 | private ApplicationHelper(){
23 | if(mInstance == null){
24 | mInstance = new ApplicationHelper();
25 | }
26 | }
27 |
28 | public static ApplicationHelper init(Context context){
29 | mContext = context;
30 | sInstance = InitWrapperImpl.getInstance();
31 | sInstance.init(mContext);
32 | return mInstance;
33 | }
34 |
35 | @Override
36 | public IInitMethods initNetWork() {
37 | sInstance.execute(Contants.TYPE_NETWORK,Contants.LIB_NAME_NETWORK_OKHTTP,"2");
38 | return mInstance;
39 | }
40 |
41 | @Override
42 | public IInitMethods initDataBase() {
43 | sInstance.execute(Contants.TYPE_DATABASE,Contants.LIB_NAME_DATABASE_GREENDAO,"3");
44 | return mInstance;
45 | }
46 |
47 | @Override
48 | public IInitMethods initImageLoader() {
49 | sInstance.execute(Contants.TYPE_IMAGE,Contants.LIB_NAME_IMAGE_GLIDE,"3");
50 | return mInstance;
51 | }
52 |
53 | @Override
54 | public IInitMethods initShare() {
55 | return mInstance;
56 | }
57 |
58 | @Override
59 | public IInitMethods initPush() {
60 | return mInstance;
61 | }
62 |
63 | @Override
64 | public IInitMethods initLogin() {
65 | return mInstance;
66 | }
67 |
68 | @Override
69 | public IInitMethods initStatistics() {
70 | return mInstance;
71 | }
72 |
73 | @Override
74 | public IInitMethods initIM() {
75 | return mInstance;
76 | }
77 |
78 | @Override
79 | public IInitMethods initAnnotationsLib() {
80 | return mInstance;
81 | }
82 |
83 | @Override
84 | public IInitMethods initInjectionLib() {
85 | return mInstance;
86 | }
87 |
88 | @Override
89 | public IInitMethods initEventsLib() {
90 | return mInstance;
91 | }
92 |
93 | @Override
94 | public IInitMethods initMapLib() {
95 | return mInstance;
96 | }
97 |
98 | @Override
99 | public IInitMethods initPullRefresh() {
100 | return mInstance;
101 | }
102 |
103 | @Override
104 | public IInitMethods initRecyclerViewHelper() {
105 | return mInstance;
106 | }
107 |
108 | @Override
109 | public IInitMethods initSlideScrollMenu() {
110 | return mInstance;
111 | }
112 |
113 | @Override
114 | public IInitMethods initNoticesView() {
115 | return mInstance;
116 | }
117 |
118 | @Override
119 | public IInitMethods initCalendarView() {
120 | return mInstance;
121 | }
122 |
123 | @Override
124 | public IInitMethods initDateTimeView() {
125 | return mInstance;
126 | }
127 |
128 | @Override
129 | public IInitMethods initChartLib() {
130 | return mInstance;
131 | }
132 |
133 | @Override
134 | public IInitMethods initLogLib() {
135 | return mInstance;
136 | }
137 |
138 | @Override
139 | public IInitMethods initQRCodeLib() {
140 | return mInstance;
141 | }
142 |
143 | @Override
144 | public IInitMethods initCarLicenseIdentification() {
145 | return mInstance;
146 | }
147 |
148 | @Override
149 | public IInitMethods initFaceIdentification() {
150 | return mInstance;
151 | }
152 |
153 | @Override
154 | public IInitMethods initIDCardIdentification() {
155 | return mInstance;
156 | }
157 |
158 | @Override
159 | public IInitMethods initPhoneNumberIdentification() {
160 | return mInstance;
161 | }
162 |
163 | @Override
164 | public IInitMethods initVoiceLib() {
165 | return mInstance;
166 | }
167 |
168 | @Override
169 | public IInitMethods initVideoLib() {
170 | return mInstance;
171 | }
172 |
173 | @Override
174 | public IInitMethods initVoiceAndVideoLib() {
175 | return mInstance;
176 | }
177 |
178 | @Override
179 | public IInitMethods initPayLib() {
180 | return mInstance;
181 | }
182 |
183 | @Override
184 | public IInitMethods initOther() {
185 | return mInstance;
186 | }
187 | }
188 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lzw/applicationhelper/InitWrapperImpl.java:
--------------------------------------------------------------------------------
1 | package com.lzw.applicationhelper;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * 操作逻辑写在这里
7 | * 【注意】这里只是提供一种思路,具体的初始化逻辑需要你自己去写上去,我就不一一去写了。
8 | * @author lzw
9 | * @date 2017/12/25
10 | */
11 | public class InitWrapperImpl implements IInitWrapper{
12 |
13 | private static InitWrapperImpl mInstance;
14 | private String mLibName = Contants.LIB_NAME_NETWORK_OKHTTP;
15 | private String mVersionName = "3";
16 | public Context mContext;
17 |
18 | private InitWrapperImpl(){}
19 |
20 | public static InitWrapperImpl getInstance(){
21 | if(mInstance == null){
22 | mInstance = new InitWrapperImpl();
23 | }
24 | return mInstance;
25 | }
26 |
27 | @Override
28 | public void init(Context context) {
29 | mContext = context;
30 | }
31 |
32 | @Override
33 | public void setLib(String libName) {
34 | mLibName = libName;
35 | }
36 |
37 | @Override
38 | public String getLib() {
39 | return mLibName;
40 | }
41 |
42 | @Override
43 | public void setLibVersion(String version) {
44 | mVersionName = version;
45 | }
46 |
47 | @Override
48 | public String getLibVersion() {
49 | return mVersionName;
50 | }
51 |
52 | @Override
53 | public void onExecute() {
54 |
55 | }
56 |
57 | /**
58 | * 这样就可以针对不用版本的api可以同时做一些操作了,代码维护起来很方便
59 | */
60 | @Override
61 | public void execute(int type, String libName, String versionName) {
62 | //如果是网络框架
63 | if(type == Contants.TYPE_NETWORK){
64 | initNewWorkWrapper(libName,versionName);
65 | }else if(type == Contants.TYPE_DATABASE){
66 | initDataBaseWrapper(libName,versionName);
67 | }else if(type == Contants.TYPE_IMAGE){
68 | initImageWrapper(libName,versionName);
69 | }else if(type == Contants.TYPE_SHARE){
70 | initShareWrapper(libName,versionName);
71 | }else if(type == Contants.TYPE_PUSH){
72 | initPushWrapper(libName,versionName);
73 | }else if(type == Contants.TYPE_LOGIN){
74 | initLoginWrapper(libName,versionName);
75 | }else if(type == Contants.TYPE_STATISTICS){
76 | initStaticsWrapper(libName,versionName);
77 | }else if(type == Contants.TYPE_IM){
78 | initIMWrapper(libName,versionName);
79 | }else if(type == Contants.TYPE_ANNOTATIONS){
80 | initAnnotationsWrapper(libName,versionName);
81 | }else if(type == Contants.TYPE_INJECTION){
82 | initInjectionWrapper(libName,versionName);
83 | }else if(type == Contants.TYPE_EVENT){
84 | initEventWrapper(libName,versionName);
85 | }else if(type == Contants.TYPE_MAP){
86 | initMapWrapper(libName,versionName);
87 | }else if(type == Contants.TYPE_PULLREFERSH){
88 | initPullRefreshWrapper(libName,versionName);
89 | }else if(type == Contants.TYPE_RECYCLERVIRE_HELPER){
90 | initRecyclerViewHelperWrapper(libName,versionName);
91 | }else if(type == Contants.TYPE_SLIDESCROLLMENU){
92 | initSlideScrollMenuWrapper(libName,versionName);
93 | }else if(type == Contants.TYPE_NOTICESVIEW){
94 | initNoticesViewWrapper(libName,versionName);
95 | }else if(type == Contants.TYPE_CALENDARVIEW){
96 | initCalendarViewWrapper(libName,versionName);
97 | }else if(type == Contants.TYPE_DATETIMEVIEW){
98 | initDateTimeViewWrapper(libName,versionName);
99 | }else if(type == Contants.TYPE_CHART){
100 | initChartWrapper(libName,versionName);
101 | }else if(type == Contants.TYPE_LOG){
102 | initLogWrapper(libName,versionName);
103 | }else if(type == Contants.TYPE_QRCODE){
104 | initQRCodeWrapper(libName,versionName);
105 | }else if(type == Contants.TYPE_CARLICENSE_IDENTIFICATION){
106 | initCarLicenseIdentificationWrapper(libName,versionName);
107 | }else if(type == Contants.TYPE_FACE_IDENTIFICATION){
108 | initFaceIdentificationWrapper(libName,versionName);
109 | }else if(type == Contants.TYPE_IDCARD_IDENTIFICATION){
110 | initIDCardIdentificationWrapper(libName,versionName);
111 | }else if(type == Contants.TYPE_PHONENUM_IDENTIFICATION){
112 | initPhoneNumberIdentificationWrapper(libName,versionName);
113 | }else if(type == Contants.TYPE_VOICE){
114 | initVoiceLibWrapper(libName,versionName);
115 | }else if(type == Contants.TYPE_VIDEO){
116 | initVideoLibWrapper(libName,versionName);
117 | }else if(type == Contants.TYPE_VOICEANDVIDEO){
118 | initVoiceAndVideoLibWrapper(libName,versionName);
119 | }else if(type == Contants.TYPE_PAY){
120 | initPayLibWrapper(libName,versionName);
121 | }else if(type == Contants.TYPE_OTHER){
122 | initOtherLibWrapper(libName,versionName);
123 | }else{
124 | throw new IllegalArgumentException("type类型输入有误。");
125 | }
126 | }
127 |
128 |
129 | private void initNewWorkWrapper(String libName, String versionName){
130 | if(libName.equals(Contants.LIB_NAME_NETWORK_OKHTTP)){
131 | if(versionName.startsWith("2")){
132 | //对okhttp做初始化操作
133 | }
134 | }
135 | if(libName.equals(Contants.LIB_NAME_NETWORK_OKGO)){
136 | //对OkGo做初始化操作
137 | }
138 | }
139 |
140 |
141 | private void initDataBaseWrapper(String libName, String versionName) {
142 |
143 | }
144 |
145 | private void initImageWrapper(String libName, String versionName) {
146 |
147 | }
148 |
149 | private void initShareWrapper(String libName, String versionName) {
150 |
151 | }
152 |
153 | private void initPushWrapper(String libName, String versionName) {
154 |
155 | }
156 |
157 | private void initLoginWrapper(String libName, String versionName) {
158 |
159 | }
160 |
161 | private void initStaticsWrapper(String libName, String versionName) {
162 |
163 | }
164 |
165 | private void initIMWrapper(String libName, String versionName) {
166 |
167 | }
168 |
169 | private void initAnnotationsWrapper(String libName, String versionName) {
170 |
171 | }
172 |
173 | private void initInjectionWrapper(String libName, String versionName) {
174 |
175 | }
176 |
177 | private void initEventWrapper(String libName, String versionName) {
178 |
179 | }
180 |
181 | private void initMapWrapper(String libName, String versionName) {
182 |
183 | }
184 |
185 | private void initPullRefreshWrapper(String libName, String versionName) {
186 |
187 | }
188 |
189 | private void initRecyclerViewHelperWrapper(String libName, String versionName) {
190 |
191 | }
192 |
193 | private void initSlideScrollMenuWrapper(String libName, String versionName) {
194 |
195 | }
196 |
197 | private void initNoticesViewWrapper(String libName, String versionName) {
198 |
199 | }
200 |
201 | private void initCalendarViewWrapper(String libName, String versionName) {
202 |
203 | }
204 |
205 | private void initDateTimeViewWrapper(String libName, String versionName) {
206 |
207 | }
208 |
209 | private void initChartWrapper(String libName, String versionName) {
210 |
211 | }
212 |
213 | private void initLogWrapper(String libName, String versionName) {
214 |
215 | }
216 |
217 | private void initQRCodeWrapper(String libName, String versionName) {
218 |
219 | }
220 |
221 | private void initCarLicenseIdentificationWrapper(String libName, String versionName) {
222 |
223 | }
224 |
225 | private void initFaceIdentificationWrapper(String libName, String versionName) {
226 |
227 | }
228 |
229 | private void initIDCardIdentificationWrapper(String libName, String versionName) {
230 |
231 | }
232 |
233 | private void initPhoneNumberIdentificationWrapper(String libName, String versionName) {
234 |
235 | }
236 |
237 | private void initVoiceLibWrapper(String libName, String versionName) {
238 |
239 | }
240 |
241 | private void initVideoLibWrapper(String libName, String versionName) {
242 |
243 | }
244 |
245 | private void initVoiceAndVideoLibWrapper(String libName, String versionName) {
246 |
247 | }
248 |
249 | private void initPayLibWrapper(String libName, String versionName) {
250 |
251 | }
252 |
253 | private void initOtherLibWrapper(String libName, String versionName) {
254 |
255 | }
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 | }
265 |
--------------------------------------------------------------------------------
/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 [AWeiLoveAndroid] [AWeiLoveAndroid]
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 |
--------------------------------------------------------------------------------