├── .gitignore ├── .idea ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kun │ │ └── componentjava │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.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 │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── kun │ └── componentjava │ └── ExampleUnitTest.java ├── baselib ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kun │ │ └── baselib │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── kun │ │ │ └── baselib │ │ │ ├── base │ │ │ ├── ApplicationImpl.java │ │ │ ├── BaseActivity.java │ │ │ ├── BaseActivityView.java │ │ │ ├── BaseApplication.java │ │ │ ├── BaseDataCache.java │ │ │ ├── BasePresenter.java │ │ │ └── BaseResponse.java │ │ │ ├── config │ │ │ └── ModuleConfig.java │ │ │ ├── dagger │ │ │ ├── AppComponent.java │ │ │ ├── AppModule.java │ │ │ ├── NetModule.java │ │ │ └── PerActivity.java │ │ │ ├── net │ │ │ ├── HttpSubscriber.java │ │ │ └── NetParams.java │ │ │ └── utils │ │ │ ├── RxHelper.java │ │ │ └── ToastUtil.java │ └── res │ │ ├── anim │ │ ├── activity_start_in.xml │ │ ├── activity_start_in_scale.xml │ │ ├── activity_start_out.xml │ │ └── activity_start_out_scale.xml │ │ ├── color │ │ └── black_bg.xml │ │ ├── drawable │ │ ├── back.xml │ │ └── divider_line.xml │ │ ├── layout │ │ ├── line.xml │ │ ├── view_input.xml │ │ └── view_titlebar.xml │ │ ├── mipmap-hdpi │ │ ├── default_avatar.png │ │ ├── ic_back.png │ │ ├── ic_back_press.png │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── default_avatar.png │ │ ├── ic_back.png │ │ ├── ic_back_press.png │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ ├── default_avatar.png │ │ ├── ic_back.png │ │ ├── ic_back_press.png │ │ └── ic_launcher.png │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── kun │ └── baselib │ └── ExampleUnitTest.java ├── build.gradle ├── config.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── modulea ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kun │ │ └── modulea │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── kun │ │ │ └── modulea │ │ │ ├── ModuleA.java │ │ │ ├── atest │ │ │ ├── ATestActivity.java │ │ │ ├── ATestContract.java │ │ │ └── ATestPresenter.java │ │ │ ├── dagger │ │ │ ├── AmoduleComponent.java │ │ │ └── AmoduleModule.java │ │ │ └── net │ │ │ └── AmoduleApi.java │ ├── module │ │ └── AndroidManifest.xml │ └── res │ │ ├── layout │ │ └── activity_atest.xml │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── kun │ └── modulea │ └── ExampleUnitTest.java ├── moduleb ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kun │ │ └── moduleb │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── kun │ │ │ └── moduleb │ │ │ ├── ModuleB.java │ │ │ ├── btest │ │ │ ├── BTestActivity.java │ │ │ ├── BTestContract.java │ │ │ └── BTestPresenter.java │ │ │ ├── dagger │ │ │ ├── BmoduleComponent.java │ │ │ └── BmoduleModule.java │ │ │ └── net │ │ │ └── BmoduleApi.java │ ├── module │ │ └── AndroidManifest.xml │ └── res │ │ ├── layout │ │ └── activity_btest.xml │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── kun │ └── moduleb │ └── ExampleUnitTest.java └── settings.gradle /.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 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 1.8 38 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def config = rootProject.ext 4 | android { 5 | compileSdkVersion config.android.compileSdkVersion 6 | buildToolsVersion config.android.buildToolsVersion 7 | defaultConfig { 8 | minSdkVersion config.android.minSdkVersion 9 | targetSdkVersion config.android.targetSdkVersion 10 | applicationId "com.kun.componentjava" 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation fileTree(include: ['*.jar'], dir: 'libs') 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 28 | if(!isModule.toBoolean()) { 29 | implementation project(':modulea') 30 | implementation project(':moduleb') 31 | }else { 32 | implementation project(':baselib') 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/kun/componentjava/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.kun.componentjava; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.kun.componentjava", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ComponentJava 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/kun/componentjava/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.kun.componentjava; 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 | } -------------------------------------------------------------------------------- /baselib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /baselib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | //android配置 4 | def config = rootProject.ext 5 | android { 6 | compileSdkVersion config.android.compileSdkVersion 7 | buildToolsVersion config.android.buildToolsVersion 8 | 9 | defaultConfig { 10 | minSdkVersion config.android.minSdkVersion 11 | targetSdkVersion config.android.targetSdkVersion 12 | versionCode 1 13 | versionName "1.0.0" 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { 28 | exclude group: 'com.android.support', module: 'support-annotations' 29 | }) 30 | annotationProcessor "com.google.dagger:dagger-compiler:${config.dependencies.dagger}" 31 | implementation 'com.jakewharton.byteunits:byteunits:0.9.1' 32 | api "com.android.support:appcompat-v7:${config.supportLibrary}" 33 | api "com.android.support:recyclerview-v7:${config.supportLibrary}" 34 | api "com.jakewharton:butterknife:${config.dependencies.butterknife}" 35 | api "com.google.dagger:dagger:${config.dependencies.dagger}" 36 | api ('com.alibaba:arouter-api:1.2.4') { exclude module: 'support-v4' } 37 | api 'com.android.support.constraint:constraint-layout:1.0.2' 38 | api 'com.squareup.retrofit2:retrofit:2.2.0' 39 | api 'com.squareup.retrofit2:converter-gson:2.2.0' 40 | api 'com.squareup.okhttp3:logging-interceptor:3.4.1' 41 | api 'com.squareup.okhttp3:okhttp:3.8.0' 42 | api 'io.reactivex.rxjava2:rxjava:2.0.5' 43 | api 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0' 44 | //permission 45 | api 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar' 46 | // RxLifecycle 47 | api 'com.trello.rxlifecycle2:rxlifecycle:2.0.1' 48 | api 'com.trello.rxlifecycle2:rxlifecycle-android:2.0.1' 49 | api 'com.trello.rxlifecycle2:rxlifecycle-components:2.0.1' 50 | api 'com.zhy:base-rvadapter:3.0.3' 51 | testImplementation 'junit:junit:4.12' 52 | } 53 | -------------------------------------------------------------------------------- /baselib/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 /Users/lirongkun/Library/Android/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 | -------------------------------------------------------------------------------- /baselib/src/androidTest/java/com/kun/baselib/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.chiyang.baselib.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /baselib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/base/ApplicationImpl.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.base; 2 | 3 | /** 4 | * @author kun 5 | * @date 2017/12/11 6 | */ 7 | 8 | public interface ApplicationImpl { 9 | /** 10 | * Module`s Application onCreate 11 | * @param application 12 | */ 13 | void onCreate(BaseApplication application); 14 | } 15 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.base; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.os.Handler; 7 | import android.support.annotation.LayoutRes; 8 | import android.support.annotation.Nullable; 9 | import android.util.Log; 10 | 11 | import com.kun.baselib.dagger.AppComponent; 12 | import com.trello.rxlifecycle2.LifecycleProvider; 13 | import com.trello.rxlifecycle2.android.ActivityEvent; 14 | import com.trello.rxlifecycle2.components.support.RxAppCompatActivity; 15 | 16 | import javax.inject.Inject; 17 | 18 | import butterknife.ButterKnife; 19 | 20 | /** 21 | * Created by kun on 2017/4/10 22 | */ 23 | 24 | public abstract class BaseActivity extends RxAppCompatActivity implements BaseActivityView{ 25 | 26 | @Inject 27 | protected T mPresenter; 28 | 29 | protected Context mContext; 30 | protected final String TAG = "Activity"; 31 | 32 | protected abstract void daggerInit(); 33 | 34 | @Override 35 | protected void onCreate(@Nullable Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | Log.i(TAG, "CurrentActivity: " + getClass().getSimpleName()); 38 | mContext = this; 39 | } 40 | 41 | @Override 42 | public void setContentView(@LayoutRes int layoutResID) { 43 | super.setContentView(layoutResID); 44 | //绑定view 45 | ButterKnife.bind(this); 46 | daggerInit(); 47 | } 48 | 49 | /** 50 | * 延时退出 51 | */ 52 | protected void finishDelay(){ 53 | new Handler().postDelayed(new Runnable() { 54 | @Override 55 | public void run() { 56 | finish(); 57 | } 58 | }, 500); 59 | } 60 | 61 | @Override 62 | public LifecycleProvider getLifecycleProvider() { 63 | return this; 64 | } 65 | 66 | /** 67 | * 页面跳转 68 | * @param activityClass 跳转的Activity 69 | */ 70 | public void startActivity(Class activityClass) { 71 | Intent intent = new Intent(this, activityClass); 72 | mContext.startActivity(intent); 73 | } 74 | 75 | protected AppComponent getAppComponent(){ 76 | return BaseApplication.getAppComponent(); 77 | } 78 | 79 | @Override 80 | public BaseActivity getActivity() { 81 | return this; 82 | } 83 | 84 | @Override 85 | protected void onDestroy() { 86 | super.onDestroy(); 87 | if (mPresenter!=null) { 88 | mPresenter.destroyView(); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/base/BaseActivityView.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.base; 2 | 3 | import com.trello.rxlifecycle2.LifecycleProvider; 4 | import com.trello.rxlifecycle2.android.ActivityEvent; 5 | 6 | /** 7 | * Created by lirongkun on 2017/3/8 8 | */ 9 | 10 | public interface BaseActivityView{ 11 | BaseActivity getActivity(); 12 | LifecycleProvider getLifecycleProvider(); 13 | } 14 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/base/BaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.base; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.util.Log; 6 | 7 | import com.alibaba.android.arouter.launcher.ARouter; 8 | import com.kun.baselib.BuildConfig; 9 | import com.kun.baselib.config.ModuleConfig; 10 | import com.kun.baselib.dagger.AppComponent; 11 | import com.kun.baselib.dagger.AppModule; 12 | import com.kun.baselib.dagger.DaggerAppComponent; 13 | 14 | /** 15 | * Created by lirongkun on 2017/3/19 16 | */ 17 | 18 | public class BaseApplication extends Application { 19 | private static BaseApplication instance; 20 | private static AppComponent appComponent; 21 | 22 | @Override 23 | public void onCreate() { 24 | super.onCreate(); 25 | initializeInjector(); 26 | instance = this; 27 | if (BuildConfig.DEBUG) { 28 | ARouter.openLog(); // 打印日志 29 | ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险) 30 | } 31 | ARouter.init(this); // 尽可能早,推荐在Application中初始化 32 | modulesApplicationInit(); 33 | } 34 | 35 | public static BaseApplication getInstance(){ 36 | return instance; 37 | } 38 | 39 | public static Context getContext() { 40 | return getInstance().getApplicationContext(); 41 | } 42 | 43 | public static AppComponent getAppComponent() { 44 | return appComponent; 45 | } 46 | 47 | //初始化component 48 | private void initializeInjector() { 49 | appComponent = DaggerAppComponent.builder() 50 | .appModule(new AppModule(this)) 51 | .build(); 52 | } 53 | 54 | private void modulesApplicationInit(){ 55 | for (String moduleImpl : ModuleConfig.MODULESLIST){ 56 | try { 57 | Class clazz = Class.forName(moduleImpl); 58 | Object obj = clazz.newInstance(); 59 | if (obj instanceof ApplicationImpl){ 60 | ((ApplicationImpl) obj).onCreate(this); 61 | } 62 | } catch (ClassNotFoundException e) { 63 | e.printStackTrace(); 64 | } catch (IllegalAccessException e) { 65 | e.printStackTrace(); 66 | } catch (InstantiationException e) { 67 | e.printStackTrace(); 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/base/BaseDataCache.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.base; 2 | 3 | /** 4 | * Created by kun on 2017/8/17. 5 | */ 6 | 7 | public class BaseDataCache { 8 | /** 9 | * 这里可以存储缓存信息,如用户session等 10 | */ 11 | private static BaseDataCache instance; 12 | 13 | public static BaseDataCache getInstance() { 14 | if (instance == null) { 15 | synchronized (BaseDataCache.class) { 16 | if (instance == null) { 17 | instance = new BaseDataCache(); 18 | } 19 | } 20 | } 21 | return instance; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/base/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.base; 2 | 3 | /** 4 | * @author kun 5 | * @date 2017/11/14 6 | */ 7 | 8 | public class BasePresenter{ 9 | protected V mView; 10 | public void attachView(V mView){ 11 | this.mView = mView; 12 | } 13 | public void destroyView(){ 14 | mView = null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/base/BaseResponse.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.base; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | 6 | /** 7 | * Created by kun on 16/10/17 8 | */ 9 | public class BaseResponse { 10 | 11 | @Expose 12 | private String message; 13 | @Expose 14 | private int status; 15 | @Expose 16 | private T data; 17 | 18 | public String getMessage() { 19 | return message; 20 | } 21 | 22 | public void setMessage(String message) { 23 | this.message = message; 24 | } 25 | 26 | public int getStatus() { 27 | return status; 28 | } 29 | 30 | public void setStatus(int status) { 31 | this.status = status; 32 | } 33 | 34 | public T getData() { 35 | return data; 36 | } 37 | 38 | public void setData(T data) { 39 | this.data = data; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/config/ModuleConfig.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.config; 2 | 3 | /** 4 | * @author kun 5 | * @date 2017/12/12 6 | */ 7 | 8 | public class ModuleConfig { 9 | public static final String[] MODULESLIST = 10 | {"com.kun.modulea.ModuleA", 11 | "com.kun.moduleb.ModuleB"}; 12 | } 13 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/dagger/AppComponent.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.dagger; 2 | 3 | 4 | import com.kun.baselib.base.BaseApplication; 5 | import com.kun.baselib.base.BaseDataCache; 6 | 7 | import javax.inject.Singleton; 8 | 9 | import dagger.Component; 10 | import retrofit2.Retrofit; 11 | 12 | /** 13 | * Created by kun on 16/10/10 14 | */ 15 | 16 | @Singleton 17 | @Component(modules = {AppModule.class, NetModule.class}) 18 | public interface AppComponent { 19 | Retrofit provideRetrofit(); 20 | 21 | BaseApplication providesApplication(); 22 | 23 | BaseDataCache provideDataCache(); 24 | } 25 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/dagger/AppModule.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.dagger; 2 | 3 | import com.kun.baselib.base.BaseApplication; 4 | import com.kun.baselib.base.BaseDataCache; 5 | 6 | import javax.inject.Singleton; 7 | 8 | import dagger.Module; 9 | import dagger.Provides; 10 | 11 | /** 12 | * Created by kun on 16/10/10 13 | */ 14 | 15 | @Module 16 | public class AppModule { 17 | private BaseApplication baseApplication; 18 | 19 | public AppModule(BaseApplication baseApplication) { 20 | this.baseApplication = baseApplication; 21 | } 22 | 23 | @Provides 24 | @Singleton 25 | BaseApplication providesApplication() { 26 | return baseApplication; 27 | } 28 | 29 | @Provides 30 | @Singleton 31 | BaseDataCache provideDataCache(){return BaseDataCache.getInstance();} 32 | } 33 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/dagger/NetModule.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.dagger; 2 | 3 | 4 | import android.util.Log; 5 | 6 | import com.kun.baselib.base.BaseApplication; 7 | import com.kun.baselib.net.NetParams; 8 | import com.google.gson.Gson; 9 | import com.google.gson.GsonBuilder; 10 | import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 11 | import java.io.File; 12 | import javax.inject.Singleton; 13 | import dagger.Module; 14 | import dagger.Provides; 15 | import okhttp3.Cache; 16 | import okhttp3.OkHttpClient; 17 | import okhttp3.logging.HttpLoggingInterceptor; 18 | import retrofit2.Retrofit; 19 | import retrofit2.converter.gson.GsonConverterFactory; 20 | import static com.jakewharton.byteunits.DecimalByteUnit.MEGABYTES; 21 | 22 | @Module 23 | public class NetModule { 24 | 25 | private static final int DISK_CACHE_SIZE = (int) MEGABYTES.toBytes(50); 26 | 27 | @Provides 28 | @Singleton 29 | Retrofit provideRetrofit(OkHttpClient client) { 30 | Gson gson = new GsonBuilder().create(); 31 | return new Retrofit.Builder() 32 | .client(client) 33 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 34 | .addConverterFactory(GsonConverterFactory.create(gson)) 35 | .baseUrl(NetParams.BASE_URL).build(); 36 | } 37 | 38 | 39 | /** 40 | * client with interceptor 41 | * 42 | * @return 43 | */ 44 | @Provides 45 | @Singleton 46 | OkHttpClient provideOkHttpClient(BaseApplication app) { 47 | return createOkHttpClient(app).build(); 48 | } 49 | 50 | 51 | private static OkHttpClient.Builder createOkHttpClient(BaseApplication app) { 52 | // Install an HTTP cache in the application cache directory. 53 | File cacheDir = new File(app.getCacheDir(), "http"); 54 | Cache cache = new Cache(cacheDir, DISK_CACHE_SIZE); 55 | return new OkHttpClient.Builder().cache(cache).addInterceptor(getLoggingInterceptor()); 56 | } 57 | //截取网络访问信息,打印retrofit日志 58 | private static HttpLoggingInterceptor getLoggingInterceptor(){ 59 | HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() { 60 | @Override 61 | public void log(String message) { 62 | Log.i("retrofit","retrofit:"+message); 63 | } 64 | }); 65 | loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); 66 | return loggingInterceptor; 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/dagger/PerActivity.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.dagger; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import javax.inject.Scope; 7 | 8 | /** 9 | * Created by kun on 2017/1/17 10 | * Explain: 11 | */ 12 | @Documented 13 | @Scope 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface PerActivity { 16 | } 17 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/net/HttpSubscriber.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.net; 2 | 3 | import android.util.Log; 4 | import com.kun.baselib.base.BaseResponse; 5 | import com.kun.baselib.utils.ToastUtil; 6 | import java.net.ConnectException; 7 | import java.net.SocketTimeoutException; 8 | import java.net.UnknownHostException; 9 | import io.reactivex.subscribers.DisposableSubscriber; 10 | 11 | /** 12 | * 将成功之后的操作方法抽象出去,其他方法有默认实现 13 | */ 14 | public abstract class HttpSubscriber extends DisposableSubscriber { 15 | 16 | private static final String TAG = "NET"; 17 | 18 | @Override 19 | public void onNext(T t) { 20 | if (t != null && t.getStatus() == 200) { 21 | onSuccess(t); 22 | } else { 23 | onFail(t); 24 | } 25 | } 26 | 27 | @Override 28 | public void onError(Throwable e) { 29 | e.printStackTrace(); 30 | if (e instanceof UnknownHostException) { 31 | toast("请检查您的网络设置"); 32 | noNet(); 33 | } else if (e instanceof SocketTimeoutException) { 34 | toast("连接超时"); 35 | } else if (e instanceof ConnectException) { 36 | toast("连接出错"); 37 | }else{ 38 | toast("访问出错"); 39 | } 40 | } 41 | 42 | @Override 43 | public void onComplete() { 44 | } 45 | 46 | public abstract void onSuccess(T t); 47 | 48 | public void onFail(T t) { 49 | if (t == null) { 50 | toast("服务器访问失败"); 51 | } else { 52 | Log.i(TAG,"code:"+t.getStatus()); 53 | toast(t.getMessage()); 54 | } 55 | } 56 | 57 | public void noNet(){} 58 | 59 | private void toast(final String str){ 60 | ToastUtil.toastShort(str); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/net/NetParams.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.net; 2 | 3 | 4 | public class NetParams { 5 | public static final String BASE_URL = "http://www.sojson.com/"; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/utils/RxHelper.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.utils; 2 | 3 | import org.reactivestreams.Publisher; 4 | 5 | import io.reactivex.Flowable; 6 | import io.reactivex.FlowableTransformer; 7 | import io.reactivex.Observable; 8 | import io.reactivex.ObservableTransformer; 9 | import io.reactivex.android.schedulers.AndroidSchedulers; 10 | import io.reactivex.schedulers.Schedulers; 11 | 12 | /** 13 | * Created by lirongkun on 2017/3/9 14 | */ 15 | 16 | public class RxHelper { 17 | /** 18 | * 将线程调度进行封装,在io线程观察,在主线程订阅 19 | * 20 | * @param 当前观察者的类型 21 | * @return 作为参数用于 {@link Observable#compose(ObservableTransformer)} 中 22 | */ 23 | public static FlowableTransformer io_main() { 24 | return new FlowableTransformer() { 25 | @Override 26 | public Publisher apply(Flowable upstream) { 27 | return upstream 28 | .subscribeOn(Schedulers.io()) 29 | .observeOn(AndroidSchedulers.mainThread()); 30 | } 31 | }; 32 | } 33 | 34 | /** 35 | * 将线程调度进行封装,在io线程观察,在computation线程订阅 36 | * 37 | * @param 当前观察者的类型 38 | * @return 作为参数用于 {@link Observable#compose(ObservableTransformer)} 中 39 | */ 40 | public static FlowableTransformer io_computation() { 41 | return new FlowableTransformer() { 42 | @Override 43 | public Publisher apply(Flowable upstream) { 44 | return upstream 45 | .subscribeOn(Schedulers.computation()) 46 | .observeOn(AndroidSchedulers.mainThread()); 47 | } 48 | }; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /baselib/src/main/java/com/kun/baselib/utils/ToastUtil.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib.utils; 2 | 3 | import android.content.Context; 4 | import android.widget.Toast; 5 | 6 | import com.kun.baselib.base.BaseApplication; 7 | 8 | /** 9 | * Created by kun on 2015/12/6 10 | */ 11 | public class ToastUtil { 12 | private static long lastClickTime = 0; 13 | public static final int MIN_CLICK_DELAY_TIME = 3000; 14 | 15 | public static void toastLong(Context ct, String msg) { 16 | Toast.makeText(ct, msg, Toast.LENGTH_LONG).show(); 17 | } 18 | 19 | public static void toastShort(Context ct, String msg) { 20 | Toast.makeText(ct, msg, Toast.LENGTH_SHORT).show(); 21 | } 22 | 23 | public static void toastLong(Context ct, int StringId) { 24 | Toast.makeText(ct, StringId, Toast.LENGTH_LONG).show(); 25 | } 26 | 27 | public static void toastShort(Context ct, int StringId) { 28 | Toast.makeText(ct, StringId, Toast.LENGTH_SHORT).show(); 29 | } 30 | 31 | public static void toastLimit(Context ct, int StringId){ 32 | long currentTime = System.currentTimeMillis(); 33 | if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) { 34 | lastClickTime = currentTime; 35 | Toast.makeText(ct, StringId, Toast.LENGTH_SHORT).show(); 36 | } 37 | } 38 | 39 | public static void toastLimit(Context ct, String msg){ 40 | long currentTime = System.currentTimeMillis(); 41 | if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) { 42 | lastClickTime = currentTime; 43 | Toast.makeText(ct, msg, Toast.LENGTH_SHORT).show(); 44 | } 45 | } 46 | 47 | public static void toastShort(String msg){ 48 | Toast.makeText(BaseApplication.getContext(), msg, Toast.LENGTH_SHORT).show(); 49 | } 50 | 51 | public static void toastShort(int StringId){ 52 | Toast.makeText(BaseApplication.getContext(), StringId, Toast.LENGTH_SHORT).show(); 53 | } 54 | /** 55 | * 56 | * @param ct 上下文 57 | * @param time 间隔时间 单位ms 58 | * @param StringId Stringid 59 | */ 60 | public static void toastLimit(Context ct,int time, int StringId){ 61 | long currentTime = System.currentTimeMillis(); 62 | if (currentTime - lastClickTime > time) { 63 | lastClickTime = currentTime; 64 | Toast.makeText(ct, StringId, Toast.LENGTH_SHORT).show(); 65 | } 66 | } 67 | /** 68 | * 69 | * @param ct 上下文 70 | * @param time 间隔时间 单位ms 71 | * @param msg String 72 | */ 73 | public static void toastLimit(Context ct,int time, String msg){ 74 | long currentTime = System.currentTimeMillis(); 75 | if (currentTime - lastClickTime > time) { 76 | lastClickTime = currentTime; 77 | Toast.makeText(ct, msg, Toast.LENGTH_SHORT).show(); 78 | } 79 | } 80 | 81 | // public static void toastCenter(Context mContext, String msg){ 82 | // new CenterToast(mContext, msg).showDatePicker(); 83 | // } 84 | // public static void toastCenter(Context mContext, int StringId){ 85 | // new CenterToast(mContext, mContext.getString(StringId)).showDatePicker(); 86 | // } 87 | // public static void showToastLongDebug(Context mContext, String msg) { 88 | // if (!BuildConfig.ISOPEN) 89 | // Toast.makeText(mContext, "debug:" + msg, Toast.LENGTH_LONG).showDatePicker(); 90 | // } 91 | // 92 | // public static void showToastShortDebug(Context mContext, String msg) { 93 | // if (!BuildConfig.ISOPEN) 94 | // Toast.makeText(mContext, "debug:" + msg, Toast.LENGTH_SHORT).showDatePicker(); 95 | // } 96 | } 97 | -------------------------------------------------------------------------------- /baselib/src/main/res/anim/activity_start_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | -------------------------------------------------------------------------------- /baselib/src/main/res/anim/activity_start_in_scale.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 16 | -------------------------------------------------------------------------------- /baselib/src/main/res/anim/activity_start_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /baselib/src/main/res/anim/activity_start_out_scale.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /baselib/src/main/res/color/black_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /baselib/src/main/res/drawable/back.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /baselib/src/main/res/drawable/divider_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /baselib/src/main/res/layout/line.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /baselib/src/main/res/layout/view_input.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | -------------------------------------------------------------------------------- /baselib/src/main/res/layout/view_titlebar.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 26 | 27 | 35 | 36 | 37 | 38 | 46 | 47 | 54 | 55 | 64 | 65 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-hdpi/default_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-hdpi/default_avatar.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-hdpi/ic_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-hdpi/ic_back.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-hdpi/ic_back_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-hdpi/ic_back_press.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-xhdpi/default_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-xhdpi/default_avatar.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-xhdpi/ic_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-xhdpi/ic_back.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-xhdpi/ic_back_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-xhdpi/ic_back_press.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-xxhdpi/default_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-xxhdpi/default_avatar.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-xxhdpi/ic_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-xxhdpi/ic_back.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-xxhdpi/ic_back_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-xxhdpi/ic_back_press.png -------------------------------------------------------------------------------- /baselib/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/baselib/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /baselib/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /baselib/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #03cbb9 4 | #03cbb9 5 | #03cbb9 6 | 7 | #02cbba 8 | #01ab9c 9 | #e0e0e0 10 | #999999 11 | #101010 12 | 13 | #ff8a33 14 | #aaff8a33 15 | #ffffff 16 | #333333 17 | 18 | #999999 19 | #f0eeee 20 | #f7f5f5 21 | 22 | #ffffff 23 | #cef2f0 24 | -------------------------------------------------------------------------------- /baselib/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2px 4 | 2px 5 | -------------------------------------------------------------------------------- /baselib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | WifiSpice 3 | 服务器访问失败 4 | 5 | -------------------------------------------------------------------------------- /baselib/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 19 | -------------------------------------------------------------------------------- /baselib/src/test/java/com/kun/baselib/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.kun.baselib; 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 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | apply from: "config.gradle" 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.1' 11 | 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /config.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | ext{ 3 | 4 | android = [ 5 | compileSdkVersion: 26, 6 | buildToolsVersion: "27.0.1", 7 | minSdkVersion : 14, 8 | targetSdkVersion : 25 9 | ] 10 | dependencies = [ 11 | dagger : "2.11", 12 | arouter: "1.1.4", 13 | butterknife : "8.6.0" 14 | ] 15 | 16 | //Version 17 | supportLibrary = "27.0.2" 18 | } -------------------------------------------------------------------------------- /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 | 19 | isModule = false 20 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rongkun/ComponentJava/5596e5bd5eb13e56946d387a37271b7a019f3066/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 11 18:03:03 CST 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-4.1-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 | -------------------------------------------------------------------------------- /modulea/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /modulea/build.gradle: -------------------------------------------------------------------------------- 1 | if (isModule.toBoolean()) { 2 | apply plugin: 'com.android.application' 3 | } else { 4 | apply plugin: 'com.android.library' 5 | } 6 | 7 | def config = rootProject.ext 8 | android { 9 | compileSdkVersion config.android.compileSdkVersion 10 | buildToolsVersion config.android.buildToolsVersion 11 | 12 | defaultConfig { 13 | minSdkVersion config.android.minSdkVersion 14 | targetSdkVersion config.android.targetSdkVersion 15 | versionCode 1 16 | versionName "1.0" 17 | 18 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 19 | javaCompileOptions { 20 | annotationProcessorOptions { 21 | arguments = [ moduleName : project.getName() ] 22 | } 23 | } 24 | } 25 | 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | } 31 | } 32 | 33 | sourceSets { 34 | main { 35 | if (isModule.toBoolean()) { 36 | manifest.srcFile 'src/main/module/AndroidManifest.xml' 37 | } else { 38 | manifest.srcFile 'src/main/AndroidManifest.xml' 39 | } 40 | } 41 | } 42 | } 43 | 44 | dependencies { 45 | implementation fileTree(include: ['*.jar'], dir: 'libs') 46 | testImplementation 'junit:junit:4.12' 47 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 48 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 49 | annotationProcessor "com.alibaba:arouter-compiler:${config.dependencies.arouter}" 50 | annotationProcessor "com.google.dagger:dagger-compiler:${config.dependencies.dagger}" 51 | api project(':baselib') 52 | } 53 | -------------------------------------------------------------------------------- /modulea/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /modulea/src/androidTest/java/com/kun/modulea/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.kun.modulea; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.kun.modulea.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /modulea/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /modulea/src/main/java/com/kun/modulea/ModuleA.java: -------------------------------------------------------------------------------- 1 | package com.kun.modulea; 2 | 3 | import android.util.Log; 4 | 5 | import com.kun.baselib.base.ApplicationImpl; 6 | import com.kun.baselib.base.BaseApplication; 7 | 8 | /** 9 | * @author kun 10 | * @date 2017/12/11 11 | */ 12 | 13 | public class ModuleA implements ApplicationImpl { 14 | @Override 15 | public void onCreate(BaseApplication application) { 16 | Log.i("aaa","AModule"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /modulea/src/main/java/com/kun/modulea/atest/ATestActivity.java: -------------------------------------------------------------------------------- 1 | package com.kun.modulea.atest; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.widget.Button; 6 | 7 | import com.alibaba.android.arouter.launcher.ARouter; 8 | import com.kun.baselib.base.BaseActivity; 9 | import com.kun.modulea.R; 10 | import com.kun.modulea.dagger.DaggerAmoduleComponent; 11 | 12 | public class ATestActivity extends BaseActivity implements ATestContract.View { 13 | private Button btn; 14 | @Override 15 | protected void daggerInit() { 16 | DaggerAmoduleComponent.builder() 17 | .appComponent(getAppComponent()) 18 | .build() 19 | .inject(this); 20 | } 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_atest ); 26 | mPresenter.attachView(this); 27 | btn = findViewById(R.id.btnTest); 28 | btn.setOnClickListener(new View.OnClickListener() { 29 | @Override 30 | public void onClick(View v) { 31 | ARouter.getInstance() 32 | .build("/bmodule/test") 33 | .navigation(mContext); 34 | } 35 | }); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /modulea/src/main/java/com/kun/modulea/atest/ATestContract.java: -------------------------------------------------------------------------------- 1 | package com.kun.modulea.atest; 2 | 3 | import com.kun.baselib.base.BaseActivityView; 4 | 5 | public class ATestContract { 6 | public interface View extends BaseActivityView { 7 | 8 | } 9 | 10 | public interface Present { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /modulea/src/main/java/com/kun/modulea/atest/ATestPresenter.java: -------------------------------------------------------------------------------- 1 | package com.kun.modulea.atest; 2 | 3 | import com.kun.baselib.base.BasePresenter; 4 | 5 | import javax.inject.Inject; 6 | 7 | public class ATestPresenter extends BasePresenter implements ATestContract.Present { 8 | @Inject 9 | ATestPresenter() { 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /modulea/src/main/java/com/kun/modulea/dagger/AmoduleComponent.java: -------------------------------------------------------------------------------- 1 | package com.kun.modulea.dagger; 2 | 3 | import com.kun.baselib.dagger.AppComponent; 4 | import com.kun.baselib.dagger.PerActivity; 5 | import com.kun.modulea.atest.ATestActivity; 6 | 7 | import dagger.Component; 8 | 9 | /** 10 | * @author kun 11 | * @date 2017/12/7 12 | */ 13 | 14 | @PerActivity 15 | @Component(dependencies = AppComponent.class,modules = {AmoduleModule.class}) 16 | public interface AmoduleComponent { 17 | void inject(ATestActivity aTestActivity); 18 | } 19 | -------------------------------------------------------------------------------- /modulea/src/main/java/com/kun/modulea/dagger/AmoduleModule.java: -------------------------------------------------------------------------------- 1 | package com.kun.modulea.dagger; 2 | 3 | import com.kun.baselib.dagger.PerActivity; 4 | import com.kun.modulea.net.AmoduleApi; 5 | 6 | import dagger.Module; 7 | import dagger.Provides; 8 | import retrofit2.Retrofit; 9 | 10 | @Module 11 | public class AmoduleModule { 12 | @PerActivity 13 | @Provides 14 | AmoduleApi providesNetApi(Retrofit retrofit) { 15 | return retrofit.create(AmoduleApi.class); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /modulea/src/main/java/com/kun/modulea/net/AmoduleApi.java: -------------------------------------------------------------------------------- 1 | package com.kun.modulea.net; 2 | 3 | import com.kun.baselib.base.BaseResponse; 4 | 5 | import io.reactivex.Flowable; 6 | import retrofit2.http.GET; 7 | import retrofit2.http.Query; 8 | 9 | /** 10 | * Created by kun on 2017/8/14. 11 | */ 12 | 13 | public interface AmoduleApi { 14 | @GET("open/api/weather/json.shtml?") 15 | Flowable> getWeather(@Query("city") String city); 16 | } 17 | -------------------------------------------------------------------------------- /modulea/src/main/module/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /modulea/src/main/res/layout/activity_atest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 |