├── .gitignore
├── .idea
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── dbnavigator.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
└── runConfigurations.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── alien
│ │ └── pluto
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── alien
│ │ │ └── pluto
│ │ │ ├── App.kt
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── color
│ │ └── tab_color.xml
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable-xhdpi
│ │ ├── btn_tab_dongtai_active.png
│ │ ├── btn_tab_dongtai_normal.png
│ │ ├── btn_tab_home_active.png
│ │ ├── btn_tab_home_normal.png
│ │ ├── btn_tab_live_active.png
│ │ ├── btn_tab_live_normal.png
│ │ ├── btn_tab_me_active.png
│ │ ├── btn_tab_me_normal.png
│ │ ├── btn_tab_message_active.png
│ │ └── btn_tab_message_normal.png
│ │ ├── drawable
│ │ ├── btn_tab_dynamic.xml
│ │ ├── btn_tab_home.xml
│ │ ├── btn_tab_live.xml
│ │ ├── btn_tab_me.xml
│ │ ├── btn_tab_message.xml
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.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
│ └── alien
│ └── pluto
│ └── ExampleUnitTest.kt
├── baselib
├── .gitignore
├── build.gradle
├── libs
│ ├── alin.jar
│ └── open_sdk_r6008_lite.jar
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── alien
│ │ └── baselib
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── alien
│ │ │ └── baselib
│ │ │ ├── ExData.kt
│ │ │ ├── ExtendFun.kt
│ │ │ ├── support
│ │ │ ├── AppBarStateChangeListener.kt
│ │ │ ├── LineItemDecoration.kt
│ │ │ ├── RecyclerScrollStateListener.kt
│ │ │ ├── ScaleTransformer.kt
│ │ │ └── ViewPagerAdapter.kt
│ │ │ └── widget
│ │ │ ├── IconTabView.kt
│ │ │ ├── StrokeTextView.kt
│ │ │ ├── SwipeRefresh.kt
│ │ │ ├── TabRadioLayout.kt
│ │ │ ├── TitleBar.kt
│ │ │ └── TitleItem.kt
│ └── res
│ │ ├── anim
│ │ ├── in_bottom.xml
│ │ └── out_bottom.xml
│ │ ├── drawable-v21
│ │ └── bg_list_item.xml
│ │ ├── drawable-xhdpi
│ │ ├── ic_qq.png
│ │ ├── ic_qzone.png
│ │ ├── ic_sina.png
│ │ └── ic_wx.png
│ │ ├── drawable
│ │ ├── bg_comm_button.xml
│ │ ├── bg_frame.xml
│ │ ├── bg_list_item.xml
│ │ ├── bg_qq.xml
│ │ ├── bg_qzone.xml
│ │ ├── bg_sina.xml
│ │ ├── bg_wx.xml
│ │ ├── btn_blue.xml
│ │ ├── btn_blue_round.xml
│ │ ├── ic_add_white_24dp.xml
│ │ ├── ic_avatar.xml
│ │ ├── ic_delete_white_24dp.xml
│ │ ├── ic_edit_white_24dp.xml
│ │ ├── ic_left_black_34dp.xml
│ │ ├── ic_left_white_34dp.xml
│ │ ├── ic_menu_white_24dp.xml
│ │ ├── ic_next_right_gray_24dp.xml
│ │ ├── red_dot.xml
│ │ ├── red_round_dot.xml
│ │ ├── shape_circle.xml
│ │ ├── shape_cover.xml
│ │ └── shape_tag.xml
│ │ ├── layout
│ │ ├── layout_comm_with_title.xml
│ │ └── layout_recycler_view.xml
│ │ └── values
│ │ ├── app_themes.xml
│ │ ├── arrays.xml
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── ids.xml
│ │ ├── material_colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── alien
│ └── baselib
│ └── ExampleUnitTest.java
├── basemodule
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── alien
│ │ └── base
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── alien
│ │ │ └── base
│ │ │ ├── BaseApplication.kt
│ │ │ ├── Constants.kt
│ │ │ ├── Platform.kt
│ │ │ ├── data
│ │ │ ├── entity
│ │ │ │ └── User.kt
│ │ │ ├── network
│ │ │ │ └── BaseRequestBody.kt
│ │ │ └── pref
│ │ │ │ ├── AppSp.kt
│ │ │ │ └── UserSp.kt
│ │ │ ├── di
│ │ │ ├── AppComponent.kt
│ │ │ ├── AppModule.kt
│ │ │ ├── BaseAppComponent.kt
│ │ │ ├── BaseViewComponent.kt
│ │ │ ├── BaseViewModule.kt
│ │ │ ├── OtherModule.kt
│ │ │ ├── SingletonModule.kt
│ │ │ └── scope
│ │ │ │ ├── AppScope.kt
│ │ │ │ └── PerView.kt
│ │ │ ├── event
│ │ │ ├── BaseEvent.kt
│ │ │ └── RxBus.kt
│ │ │ ├── http
│ │ │ ├── ApiError.kt
│ │ │ ├── HttpApiService.kt
│ │ │ ├── HttpConfig.kt
│ │ │ ├── HttpResponse.kt
│ │ │ ├── HttpResponseObserver.kt
│ │ │ ├── HttpResult.kt
│ │ │ ├── HttpThrowable.kt
│ │ │ ├── JsonResponseObserver.kt
│ │ │ ├── RestApi.kt
│ │ │ └── interceptor
│ │ │ │ ├── HttpCacheInterceptor.kt
│ │ │ │ └── HttpHeaderInterceptor.kt
│ │ │ ├── image
│ │ │ ├── Compressor.kt
│ │ │ └── GlideLoader.kt
│ │ │ ├── modulekit
│ │ │ ├── AModuleKit.kt
│ │ │ ├── AppModuleComponentDelegate.kt
│ │ │ ├── BModuleKit.kt
│ │ │ ├── BaseModuleKit.kt
│ │ │ ├── CModuleKit.kt
│ │ │ ├── DModuleKit.kt
│ │ │ └── EModuleKit.kt
│ │ │ ├── mvp
│ │ │ ├── BasePresenter.kt
│ │ │ ├── BaseRepository.kt
│ │ │ ├── BaseView.kt
│ │ │ ├── MVPRepository.kt
│ │ │ └── MVPView.kt
│ │ │ ├── share
│ │ │ ├── BaseSharePresenter.kt
│ │ │ ├── ShareActivity.kt
│ │ │ ├── ShareCallbackView.kt
│ │ │ ├── SharePresenter.kt
│ │ │ ├── WXCallbackActivity.kt
│ │ │ ├── data
│ │ │ │ ├── ShareConstant.kt
│ │ │ │ ├── ShareEntity.kt
│ │ │ │ └── ShareType.kt
│ │ │ └── manager
│ │ │ │ ├── BaseSharer.kt
│ │ │ │ ├── QQShareView.kt
│ │ │ │ ├── QQSharer.kt
│ │ │ │ ├── ShareManager.kt
│ │ │ │ ├── ShareView.kt
│ │ │ │ ├── SinaSharer.kt
│ │ │ │ ├── WXShareView.kt
│ │ │ │ └── WXSharer.kt
│ │ │ ├── tools
│ │ │ ├── ActivityListManager.kt
│ │ │ ├── AppUtil.kt
│ │ │ ├── NetWorkUtils.kt
│ │ │ ├── SchedulerProvider.kt
│ │ │ ├── StringUtils.kt
│ │ │ ├── TimeUtils.kt
│ │ │ └── permission
│ │ │ │ ├── PermissionListener.kt
│ │ │ │ └── PermissionManager.kt
│ │ │ └── ui
│ │ │ ├── AbstractActivity.kt
│ │ │ ├── ActionBottomSheet.kt
│ │ │ ├── BaseActivity.kt
│ │ │ ├── BaseDialogFragment.kt
│ │ │ ├── BaseFragment.kt
│ │ │ ├── activity
│ │ │ ├── ActivityLife.kt
│ │ │ ├── ActivityLifeCallback.kt
│ │ │ ├── IActivityLife.kt
│ │ │ └── IBaseActivity.kt
│ │ │ └── fragment
│ │ │ ├── FragmentLife.kt
│ │ │ ├── FragmentLifeCallback.kt
│ │ │ ├── IBaseFragment.kt
│ │ │ └── IFragmentLife.kt
│ └── res
│ │ ├── drawable
│ │ ├── selector_action_bottom_sheet_bottom.xml
│ │ ├── selector_action_bottom_sheet_middle.xml
│ │ ├── selector_action_bottom_sheet_single.xml
│ │ └── selector_action_bottom_sheet_top.xml
│ │ └── values
│ │ ├── actionsheet_attrs.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── alien
│ └── base
│ └── ExampleUnitTest.java
├── build.gradle
├── componentlib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── android
│ │ └── componentlib
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── android
│ │ │ └── componentlib
│ │ │ ├── applicationlike
│ │ │ └── IApplicationLike.kt
│ │ │ └── router
│ │ │ ├── Jumper.kt
│ │ │ ├── Router.kt
│ │ │ └── RouterPath.kt
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── android
│ └── componentlib
│ └── ExampleUnitTest.java
├── componentservice
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── android
│ │ └── componentservice
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── android
│ │ │ └── componentservice
│ │ │ ├── CoreService.kt
│ │ │ ├── modulea
│ │ │ └── BusinessAService.kt
│ │ │ ├── moduleb
│ │ │ └── BusinessBService.kt
│ │ │ ├── modulec
│ │ │ └── BusinessCService.kt
│ │ │ ├── moduled
│ │ │ └── BusinessDService.kt
│ │ │ └── modulee
│ │ │ └── BusinessEService.kt
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── android
│ └── componentservice
│ └── ExampleUnitTest.java
├── gradle.properties
├── gradle
├── versions.gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── modulea
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── alien
│ │ └── modulea
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── debug
│ │ └── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── alien
│ │ │ └── modulea
│ │ │ ├── AAppLike.kt
│ │ │ ├── di
│ │ │ ├── ActivityComponent.kt
│ │ │ ├── FragmentComponent.kt
│ │ │ ├── ModuleAAppComponent.kt
│ │ │ └── ModuleAAppModule.kt
│ │ │ ├── serviceimpl
│ │ │ └── BusinessAServiceImpl.kt
│ │ │ └── ui
│ │ │ ├── activity
│ │ │ └── MainActivity.kt
│ │ │ └── fragment
│ │ │ ├── BaseInjectFragment.kt
│ │ │ ├── FragmentA.kt
│ │ │ └── FragmentE.kt
│ ├── release
│ │ └── AndroidManifest.xml
│ └── res
│ │ ├── layout
│ │ ├── modulea_activity_main.xml
│ │ ├── modulea_fragment_a.xml
│ │ └── modulea_fragment_e.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── alien
│ └── modulea
│ └── ExampleUnitTest.java
├── moduleb
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── alien
│ │ └── modulea
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── debug
│ │ └── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── alien
│ │ │ └── moduleb
│ │ │ ├── BAppLike.kt
│ │ │ ├── di
│ │ │ ├── ActivityComponent.kt
│ │ │ ├── FragmentComponent.kt
│ │ │ ├── ModuleBAppComponent.kt
│ │ │ └── ModuleBAppModule.kt
│ │ │ ├── serviceimpl
│ │ │ └── BusinessBServiceImpl.kt
│ │ │ └── ui
│ │ │ ├── activity
│ │ │ └── MainActivity.kt
│ │ │ └── fragment
│ │ │ └── FragmentB.kt
│ ├── release
│ │ └── AndroidManifest.xml
│ └── res
│ │ ├── layout
│ │ ├── moduleb_activity_main.xml
│ │ └── moduleb_fragment_b.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── alien
│ └── modulea
│ └── ExampleUnitTest.java
├── modulec
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── alien
│ │ └── modulea
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── debug
│ │ └── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── alien
│ │ │ └── modulec
│ │ │ ├── CAppLike.kt
│ │ │ ├── di
│ │ │ ├── ActivityComponent.kt
│ │ │ ├── FragmentComponent.kt
│ │ │ ├── ModuleCAppComponent.kt
│ │ │ └── ModuleCAppModule.kt
│ │ │ ├── serviceimpl
│ │ │ └── BusinessCServiceImpl.kt
│ │ │ └── ui
│ │ │ ├── activity
│ │ │ └── MainActivity.kt
│ │ │ └── fragment
│ │ │ └── FragmentC.kt
│ ├── release
│ │ └── AndroidManifest.xml
│ └── res
│ │ ├── layout
│ │ ├── modulec_activity_main.xml
│ │ └── modulec_fragment_c.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── alien
│ └── modulea
│ └── ExampleUnitTest.java
├── moduled
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── alien
│ │ └── modulea
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── debug
│ │ └── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── alien
│ │ │ └── moduled
│ │ │ ├── DAppLike.kt
│ │ │ ├── di
│ │ │ ├── ActivityComponent.kt
│ │ │ ├── FragmentComponent.kt
│ │ │ ├── ModuleDAppComponent.kt
│ │ │ └── ModuleDAppModule.kt
│ │ │ ├── serviceimpl
│ │ │ └── BusinessDServiceImpl.kt
│ │ │ └── ui
│ │ │ ├── activity
│ │ │ └── MainActivity.kt
│ │ │ └── fragment
│ │ │ └── FragmentD.kt
│ ├── release
│ │ └── AndroidManifest.xml
│ └── res
│ │ ├── layout
│ │ ├── moduled_activity_main.xml
│ │ └── moduled_fragment_d.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── alien
│ └── modulea
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches/build_file_checksums.ser
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | .DS_Store
9 | /build
10 | /captures
11 | .externalNativeBuild
12 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
25 |
26 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion build_version.target_sdk
7 | defaultConfig {
8 | applicationId "com.alien.pluto"
9 | minSdkVersion build_version.min_lib_sdk
10 | targetSdkVersion build_version.target_sdk
11 | versionCode rootProject.ext.app_version_code
12 | versionName rootProject.ext.app_version_name
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | multiDexEnabled true
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | compileOptions {
24 | sourceCompatibility JavaVersion.VERSION_1_8
25 | targetCompatibility JavaVersion.VERSION_1_8
26 | }
27 |
28 | splits {
29 | abi{
30 | enable true
31 | reset()
32 | include 'armeabi-v7a', 'arm64-v8a'
33 | universalApk true
34 | }
35 | }
36 | }
37 |
38 | dependencies {
39 | implementation project(':modulea')
40 | implementation project(':moduleb')
41 | implementation project(':modulec')
42 | implementation project(':moduled')
43 | }
44 |
--------------------------------------------------------------------------------
/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/alien/pluto/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.alien.pluto
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.alien.pluto", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/alien/pluto/App.kt:
--------------------------------------------------------------------------------
1 | package com.alien.pluto
2 |
3 | import com.alien.base.BaseApplication
4 | import com.android.componentlib.router.Jumper
5 | import com.android.componentlib.router.Router
6 |
7 |
8 | class App : BaseApplication(){
9 |
10 | companion object {
11 | private var instance: App? = null
12 | fun getInstance(): App = instance!!
13 | }
14 |
15 | override fun onCreate() {
16 | super.onCreate()
17 | instance = this
18 | Router.registerComponent("com.alien.modulea.AAppLike")
19 | Router.registerComponent("com.alien.moduleb.BAppLike")
20 | Router.registerComponent("com.alien.modulec.CAppLike")
21 | Router.registerComponent("com.alien.moduled.DAppLike")
22 | }
23 |
24 | override fun initComponentDi() {
25 |
26 | }
27 |
28 | override fun registerRouter() {
29 | Jumper.init(BuildConfig.DEBUG, this)
30 | }
31 | }
--------------------------------------------------------------------------------
/app/src/main/res/color/tab_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/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-xhdpi/btn_tab_dongtai_active.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/drawable-xhdpi/btn_tab_dongtai_active.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/btn_tab_dongtai_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/drawable-xhdpi/btn_tab_dongtai_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/btn_tab_home_active.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/drawable-xhdpi/btn_tab_home_active.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/btn_tab_home_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/drawable-xhdpi/btn_tab_home_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/btn_tab_live_active.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/drawable-xhdpi/btn_tab_live_active.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/btn_tab_live_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/drawable-xhdpi/btn_tab_live_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/btn_tab_me_active.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/drawable-xhdpi/btn_tab_me_active.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/btn_tab_me_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/drawable-xhdpi/btn_tab_me_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/btn_tab_message_active.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/drawable-xhdpi/btn_tab_message_active.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/btn_tab_message_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/drawable-xhdpi/btn_tab_message_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_tab_dynamic.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_tab_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_tab_live.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_tab_me.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_tab_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/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/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @android:color/white
4 | @android:color/white
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Pluto
3 |
4 | 首页
5 | 直播
6 | 发现
7 | 消息
8 | 我
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/alien/pluto/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.alien.pluto
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/baselib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/baselib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 28
7 |
8 |
9 |
10 | defaultConfig {
11 | minSdkVersion 16
12 | targetSdkVersion 28
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 |
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | api fileTree(include: ['*.jar'], dir: 'libs')
31 | api project(':componentlib')
32 | api deps.constraint_layout
33 | api deps.support.recyclerview
34 | api deps.support.cardview
35 | api deps.support.design
36 | api deps.support.app_compat
37 | api deps.appcompat_extension
38 | api deps.roundedimageview
39 | api deps.glide.runtime
40 | api deps.glide.transformations
41 | api deps.dagger.runtime
42 | api deps.dagger.android_support
43 | api deps.kotlin.stdlib
44 | api deps.rxjava2
45 | api deps.rx_android
46 | api deps.rxlifecycle
47 | api deps.rxlifecycle_android
48 | api deps.rxpermissions
49 | api deps.retrofit.runtime
50 | api deps.retrofit.gson
51 | api deps.retrofit.adapter
52 | api deps.ultimatebar
53 | api deps.nine_android
54 | api deps.basequickadapter
55 | api deps.logger
56 | api deps.guava
57 | api deps.fastjson
58 | api deps.luban
59 | }
60 |
--------------------------------------------------------------------------------
/baselib/libs/alin.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/baselib/libs/alin.jar
--------------------------------------------------------------------------------
/baselib/libs/open_sdk_r6008_lite.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/baselib/libs/open_sdk_r6008_lite.jar
--------------------------------------------------------------------------------
/baselib/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 |
--------------------------------------------------------------------------------
/baselib/src/androidTest/java/com/alien/baselib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.alien.baselib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/baselib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/alien/baselib/ExData.kt:
--------------------------------------------------------------------------------
1 | package com.alien.baselib
2 |
3 | object ExData{
4 |
5 | const val EXTRA_DATA = "extra_data"
6 | const val EXTRA_STRING = "extra_string"
7 | const val EXTRA_INT = "extra_int"
8 | const val EXTRA_LONG = "extra_long"
9 | const val EXTRA_OTHER = "extra_other"
10 | const val EXTRA_PARCELABLE = "extra_parcelable_data"
11 | }
--------------------------------------------------------------------------------
/baselib/src/main/java/com/alien/baselib/ExtendFun.kt:
--------------------------------------------------------------------------------
1 | package com.alien.baselib
2 |
3 | import android.app.Activity
4 | import android.content.Context
5 | import android.support.v4.app.Fragment
6 | import android.support.v7.widget.DefaultItemAnimator
7 | import android.support.v7.widget.LinearLayoutManager
8 | import android.support.v7.widget.RecyclerView
9 | import android.view.View
10 | import android.widget.Toast
11 | import com.chad.library.adapter.base.BaseViewHolder
12 |
13 | /**
14 | * Created by ReeseLuo on 2019/1/6.
15 | */
16 | object ExtendFun {
17 |
18 | fun View.dp2px(dp: Float): Int =
19 | (this.context.resources.displayMetrics.density * dp + 0.5f).toInt()
20 |
21 | fun Activity.dp2px(dp: Float): Int =
22 | (this.resources.displayMetrics.density * dp + 0.5f).toInt()
23 |
24 | fun Fragment.toast(msg: String){
25 | Toast.makeText(this.context, msg, Toast.LENGTH_SHORT).show()
26 | }
27 |
28 | fun Context.toast(msg: String){
29 | Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
30 | }
31 |
32 | fun Fragment.setupRecyclerView(recyclerView: RecyclerView,
33 | layoutManager: RecyclerView.LayoutManager = LinearLayoutManager(recyclerView.context),
34 | adapter: RecyclerView.Adapter){
35 | recyclerView.setHasFixedSize(true)
36 | recyclerView.itemAnimator = DefaultItemAnimator()
37 | recyclerView.layoutManager = layoutManager
38 | recyclerView.adapter = adapter
39 | }
40 |
41 | fun Activity.setupRecyclerView(recyclerView: RecyclerView,
42 | layoutManager: RecyclerView.LayoutManager = LinearLayoutManager(recyclerView.context),
43 | adapter: RecyclerView.Adapter){
44 | recyclerView.setHasFixedSize(true)
45 | recyclerView.itemAnimator = DefaultItemAnimator()
46 | recyclerView.layoutManager = layoutManager
47 | recyclerView.adapter = adapter
48 | }
49 | }
--------------------------------------------------------------------------------
/baselib/src/main/java/com/alien/baselib/support/AppBarStateChangeListener.kt:
--------------------------------------------------------------------------------
1 | package com.alien.baselib.support
2 |
3 | import android.support.annotation.IntDef
4 | import android.support.design.widget.AppBarLayout
5 |
6 | abstract class AppBarStateChangeListener: AppBarLayout.OnOffsetChangedListener {
7 |
8 | private var state = IDLE
9 |
10 | companion object {
11 | const val EXPANDED = 0
12 | const val COLLAPSED = 1
13 | const val IDLE = 2
14 | }
15 |
16 | @IntDef(EXPANDED, COLLAPSED, IDLE)
17 | @Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER)
18 | @Retention(AnnotationRetention.SOURCE)
19 | annotation class State{}
20 |
21 | abstract fun onStateChanged(appBar: AppBarLayout, @State state: Int, offset: Int)
22 |
23 | override fun onOffsetChanged(appBar: AppBarLayout, offset: Int) {
24 | if (offset == 0){
25 | if (state != EXPANDED){
26 | onStateChanged(appBar, EXPANDED, offset)
27 | }
28 | state = EXPANDED
29 | }else if (Math.abs(offset) >= appBar.totalScrollRange){
30 | if (state != COLLAPSED){
31 | onStateChanged(appBar, COLLAPSED, offset)
32 | }
33 | state = COLLAPSED
34 | }else{
35 | onStateChanged(appBar, IDLE, offset)
36 | state = IDLE
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/baselib/src/main/java/com/alien/baselib/support/LineItemDecoration.kt:
--------------------------------------------------------------------------------
1 | package com.alien.baselib.support
2 |
3 | import android.graphics.Canvas
4 | import android.graphics.Rect
5 | import android.graphics.drawable.ColorDrawable
6 | import android.support.annotation.ColorInt
7 | import android.support.v7.widget.LinearLayoutManager
8 | import android.support.v7.widget.RecyclerView
9 | import android.view.View
10 |
11 | class LineItemDecoration(var leftRight: Int, var topBottom: Int, @ColorInt var color: Int): RecyclerView.ItemDecoration() {
12 |
13 | private var mDrawable = ColorDrawable(color)
14 |
15 | override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
16 | super.onDraw(c, parent, state)
17 | var layoutManager: LinearLayoutManager? = null
18 | if (parent.layoutManager is LinearLayoutManager){
19 | layoutManager = parent.layoutManager as LinearLayoutManager
20 | }
21 |
22 | if (layoutManager == null || layoutManager.childCount == 0)
23 | return
24 |
25 | val childCount = parent.childCount
26 |
27 | var left = 0
28 | var right = 0
29 | var top = 0
30 | var bottom = 0
31 | var i = 0
32 | while (i < childCount - 1){
33 | val child = parent.getChildAt(i)
34 | val params: RecyclerView.LayoutParams = child.layoutParams as RecyclerView.LayoutParams
35 | if (layoutManager.orientation == LinearLayoutManager.VERTICAL) {
36 | val center = (layoutManager.getTopDecorationHeight(child) - topBottom) / 2
37 | left = layoutManager.getLeftDecorationWidth(child)
38 | right = parent.width - layoutManager.getLeftDecorationWidth(child)
39 | top = child.bottom + params.bottomMargin + center
40 | bottom = top + topBottom;
41 | mDrawable.setBounds(left, top, right, bottom)
42 | mDrawable.draw(c)
43 | }else{
44 | val center = (layoutManager.getLeftDecorationWidth(child) - leftRight) / 2
45 | left = child.right + params.rightMargin + center
46 | right = left + leftRight
47 | top = layoutManager.getTopDecorationHeight(child)
48 | bottom = parent.height - layoutManager.getTopDecorationHeight(child)
49 | mDrawable.setBounds(left, top, right, bottom)
50 | mDrawable.draw(c)
51 | }
52 | i++
53 | }
54 | }
55 |
56 | override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
57 | outRect.set(leftRight, topBottom, 0,0)
58 | }
59 |
60 | }
--------------------------------------------------------------------------------
/baselib/src/main/java/com/alien/baselib/support/ScaleTransformer.kt:
--------------------------------------------------------------------------------
1 | package com.alien.baselib.support
2 |
3 | import android.support.v4.view.ViewPager
4 | import android.view.View
5 |
6 | class ScaleTransformer: ViewPager.PageTransformer {
7 |
8 | private val SCALE_MAX = 0.90f
9 | private val ALPHA_MAX = 0.85f
10 |
11 | override fun transformPage(page: View, position: Float) {
12 | val scale = if (position < 0)
13 | (1 - SCALE_MAX) * position + 1
14 | else
15 | (SCALE_MAX - 1) * position + 1
16 | val alpha = if (position < 0)
17 | (1 - ALPHA_MAX) * position + 1
18 | else
19 | (ALPHA_MAX - 1) * position + 1
20 | if (position < 0) {
21 | page.pivotX = page.width.toFloat()
22 | page.pivotY = (page.height / 2).toFloat()
23 | } else {
24 | page.pivotX = 0f
25 | page.pivotY = (page.height / 2).toFloat()
26 | }
27 | page.scaleX = scale
28 | page.scaleY = scale
29 | page.alpha = Math.abs(alpha)
30 | }
31 | }
--------------------------------------------------------------------------------
/baselib/src/main/java/com/alien/baselib/support/ViewPagerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.alien.baselib.support
2 |
3 | import android.support.v4.app.Fragment
4 | import android.support.v4.app.FragmentManager
5 | import android.support.v4.app.FragmentPagerAdapter
6 | import android.support.v4.view.PagerAdapter
7 |
8 | class ViewPagerAdapter(fm: FragmentManager,
9 | private val fragments: MutableList,
10 | private val titles: MutableList = mutableListOf()): FragmentPagerAdapter(fm) {
11 |
12 | override fun getItem(position: Int): Fragment = fragments[position]
13 |
14 | override fun getCount(): Int = fragments.size
15 |
16 | override fun getPageTitle(position: Int): CharSequence? {
17 | return if (titles.isEmpty()){
18 | super.getPageTitle(position)
19 | }else{
20 | titles[position]
21 | }
22 | }
23 |
24 | override fun getItemPosition(`object`: Any): Int = PagerAdapter.POSITION_NONE
25 | }
--------------------------------------------------------------------------------
/baselib/src/main/java/com/alien/baselib/widget/StrokeTextView.kt:
--------------------------------------------------------------------------------
1 | package com.alien.baselib.widget
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.graphics.Color
6 | import android.graphics.Paint
7 | import android.support.v7.widget.AppCompatTextView
8 | import android.util.AttributeSet
9 | import com.alien.baselib.R
10 |
11 | open class StrokeTextView : AppCompatTextView {
12 |
13 | private var strokeWidth: Float = 6f
14 | private var strokeColor = Color.WHITE
15 | private var textColorInt = Color.WHITE
16 |
17 | constructor(context: Context): super(context)
18 |
19 | constructor(context: Context, attrs: AttributeSet): super(context, attrs){
20 | val typedArray = context.obtainStyledAttributes(attrs, R.styleable.StrokeTextView)
21 | strokeWidth = typedArray.getDimensionPixelOffset(R.styleable.StrokeTextView_stroke_width, 3).toFloat()
22 | strokeColor = typedArray.getColor(R.styleable.StrokeTextView_stroke_color, Color.WHITE)
23 | typedArray.recycle()
24 | }
25 |
26 | fun setStrokeColor(strokeColor: Int, textColor: Int){
27 | this.strokeColor = strokeColor
28 | this.textColorInt = textColor
29 | invalidate()
30 | }
31 |
32 | override fun onDraw(canvas: Canvas?) {
33 | paint.style = Paint.Style.STROKE
34 | paint.strokeJoin = Paint.Join.ROUND
35 | paint.strokeMiter = 10f
36 | paint.strokeWidth = strokeWidth
37 |
38 | setTextColor(strokeColor)
39 |
40 | super.onDraw(canvas)
41 |
42 | paint.style = Paint.Style.FILL
43 | setTextColor(textColorInt)
44 | super.onDraw(canvas)
45 | }
46 | }
--------------------------------------------------------------------------------
/baselib/src/main/java/com/alien/baselib/widget/TitleItem.kt:
--------------------------------------------------------------------------------
1 | package com.alien.baselib.widget
2 |
3 | import android.content.Context
4 | import android.support.annotation.DrawableRes
5 | import android.util.AttributeSet
6 | import android.util.TypedValue
7 | import android.view.Gravity
8 | import android.view.View
9 | import android.widget.ImageView
10 | import android.widget.LinearLayout
11 | import android.widget.TextView
12 | import com.alien.baselib.ExtendFun.dp2px
13 | import com.alien.baselib.R
14 |
15 | class TitleItem : LinearLayout{
16 |
17 | private var itemName: String? = null
18 | private var itemDes: String? = null
19 | private var itemNext = true
20 | private var itemIcon = 0
21 |
22 | private var iconIv: ImageView = ImageView(context)
23 | private var nextIv: ImageView = ImageView(context)
24 | private var nameTv: TextView = TextView(context)
25 | private var desTv: TextView = TextView(context)
26 |
27 | constructor(context: Context) : super(context){
28 | init()
29 | }
30 |
31 | constructor(context: Context, attributeSet: AttributeSet): super(context, attributeSet){
32 | val ta = context.obtainStyledAttributes(attributeSet, R.styleable.TitleItem)
33 | itemName = ta.getString(R.styleable.TitleItem_item_name)
34 | itemDes = ta.getString(R.styleable.TitleItem_item_des)
35 | itemNext = ta.getBoolean(R.styleable.TitleItem_item_next, true)
36 | itemIcon = ta.getResourceId(R.styleable.TitleItem_item_icon, R.drawable.ic_next_right_gray_24dp)
37 | ta.recycle()
38 | init()
39 | }
40 |
41 | private fun init(){
42 | val params = LayoutParams(0, LayoutParams.WRAP_CONTENT)
43 | params.weight = 1f
44 |
45 | desTv.setPadding(dp2px(10f), 0, dp2px(10f), 0)
46 |
47 | setBackgroundResource(R.drawable.bg_list_item)
48 | nameTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18f)
49 | desTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15f)
50 | setPadding(dp2px(12f), 0, dp2px(12f), 0)
51 | gravity = Gravity.CENTER_VERTICAL
52 |
53 | addView(iconIv)
54 | addView(nameTv, params)
55 | addView(desTv)
56 | addView(nextIv)
57 |
58 | nameTv.text = itemName
59 | desTv.text = itemDes
60 | nextIv.visibility = if (itemNext) View.VISIBLE else View.GONE
61 | nextIv.setImageResource(itemIcon)
62 | }
63 |
64 | fun setItemName(name: String) {
65 | nameTv.text = name
66 | }
67 |
68 | fun setItemDes(des: String){
69 | desTv.text = des
70 | }
71 |
72 | fun setItemIcon(@DrawableRes resId: Int){
73 | iconIv.setImageResource(resId)
74 | }
75 |
76 | fun setItemNext(next: Boolean){
77 | nextIv.visibility = if (next) View.VISIBLE else View.GONE
78 | }
79 | }
--------------------------------------------------------------------------------
/baselib/src/main/res/anim/in_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/baselib/src/main/res/anim/out_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable-v21/bg_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
8 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable-xhdpi/ic_qq.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/baselib/src/main/res/drawable-xhdpi/ic_qq.png
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable-xhdpi/ic_qzone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/baselib/src/main/res/drawable-xhdpi/ic_qzone.png
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable-xhdpi/ic_sina.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/baselib/src/main/res/drawable-xhdpi/ic_sina.png
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable-xhdpi/ic_wx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/baselib/src/main/res/drawable-xhdpi/ic_wx.png
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/bg_comm_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/bg_frame.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/bg_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/bg_qq.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/bg_qzone.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/bg_sina.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/bg_wx.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/btn_blue.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/btn_blue_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/ic_add_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/ic_avatar.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/ic_delete_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/ic_edit_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/ic_left_black_34dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/ic_left_white_34dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/ic_menu_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/ic_next_right_gray_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/red_dot.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/red_round_dot.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/shape_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/shape_cover.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/shape_tag.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/baselib/src/main/res/layout/layout_comm_with_title.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/baselib/src/main/res/layout/layout_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/baselib/src/main/res/values/app_themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
--------------------------------------------------------------------------------
/baselib/src/main/res/values/arrays.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/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/baselib/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @android:color/white
4 | @android:color/white
5 | @color/material_indigo
6 |
7 |
8 | @color/md_indigo_500
9 | #ffeb3b
10 | #4caf50
11 | #2196f3
12 | #1976d2
13 | #d34836
14 |
15 | #aaa
16 | #333
17 | #666
18 | #999
19 | #7F000000
20 | #33000000
21 | #C8000000
22 | #20FFFFFF
23 | #66FFFFFF
24 | #99FFFFFF
25 | #C8FFFFFF
26 | #f0f0f0
27 | #ebebeb
28 |
29 |
30 |
--------------------------------------------------------------------------------
/baselib/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 44dp
5 | 4dp
6 | 6dp
7 | 8dp
8 | 10dp
9 | 12dp
10 | 50dp
11 | 12sp
12 | 13sp
13 | 14sp
14 | 15sp
15 | 16sp
16 | 18sp
17 | 20sp
18 | 22sp
19 | 56dp
20 | 294dp
21 | 16dp
22 | 250dp
23 |
--------------------------------------------------------------------------------
/baselib/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/baselib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BaseLib
3 | Mini Book
4 | Mini Music
5 | Mini Live
6 |
7 | 请输入手机号码
8 | 请输入验证码
9 | 这个人比较懒没有留下签名
10 | 分类
11 | 取消
12 | 确定
13 |
14 |
--------------------------------------------------------------------------------
/baselib/src/test/java/com/alien/baselib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/basemodule/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/basemodule/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion build_version.target_sdk
8 |
9 | defaultConfig {
10 | minSdkVersion build_version.min_lib_sdk
11 | targetSdkVersion build_version.target_sdk
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | kapt deps.dagger.compiler
30 | kapt deps.dagger.android_support_compiler
31 |
32 | api project(':baselib')
33 | implementation deps.multidex
34 | implementation deps.okhttp_logging_interceptor
35 | implementation 'org.ligboy.retrofit2:converter-fastjson-android:2.1.0'
36 | api 'com.sina.weibo.sdk:core:4.3.6:openDefaultRelease@aar'
37 | api 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
38 | }
39 |
--------------------------------------------------------------------------------
/basemodule/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 |
--------------------------------------------------------------------------------
/basemodule/src/androidTest/java/com/alien/base/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.base;
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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.alien.base.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/basemodule/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/BaseApplication.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base
2 |
3 | import android.content.Context
4 | import android.support.multidex.MultiDex
5 | import android.support.multidex.MultiDexApplication
6 | import com.alien.base.di.BaseAppComponent
7 | import com.alien.base.modulekit.BaseModuleKit
8 | import com.orhanobut.logger.AndroidLogAdapter
9 | import com.orhanobut.logger.Logger
10 | import com.orhanobut.logger.PrettyFormatStrategy
11 |
12 | abstract class BaseApplication : MultiDexApplication() {
13 |
14 | private var baseAppComponent: BaseAppComponent? = null
15 |
16 | fun baseAppComponent(): BaseAppComponent {
17 | if (baseAppComponent == null)
18 | baseAppComponent = BaseModuleKit.getInstance().getComponent()
19 |
20 | return baseAppComponent!!
21 | }
22 |
23 | override fun onCreate() {
24 | super.onCreate()
25 | instance = this
26 | Logger.addLogAdapter(AndroidLogAdapter(PrettyFormatStrategy.newBuilder()
27 | .tag("LOG_TAG")
28 | .build()))
29 | initComponentDi()
30 | registerRouter()
31 | registerActivityLifecycleCallbacks(baseAppComponent()?.activityLifeCallback())
32 |
33 | // 配置httpHeaders
34 | baseAppComponent().httpConfig().setHttpHeaders(mutableMapOf())
35 | }
36 |
37 | override fun attachBaseContext(base: Context?) {
38 | super.attachBaseContext(base)
39 | MultiDex.install(this)
40 | }
41 |
42 | companion object {
43 | private var instance: BaseApplication? = null
44 |
45 | fun getInstance(): BaseApplication = instance!!
46 | }
47 |
48 | abstract fun initComponentDi()
49 |
50 | abstract fun registerRouter()
51 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/Constants.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base
2 |
3 | object Constants {
4 |
5 | const val BASE_URL = "http://apicloud.mob.com"
6 |
7 | const val START_PAGE = 1
8 |
9 | const val PAGE_MAX_SIZE = 20
10 |
11 | const val TAB_INDEX_0 = 0
12 | const val TAB_INDEX_1 = 1
13 | const val TAB_INDEX_2 = 2
14 |
15 | const val PLATFORM = "a"
16 |
17 | const val OTHER_VERSION_CODE = 10
18 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/Platform.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base
2 |
3 | object Platform {
4 |
5 | const val PF_A = 0
6 | const val PF_B = 1
7 | const val PF_C = 2
8 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/data/entity/User.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.data.entity
2 |
3 | class User(val uid: Long) {
4 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/data/network/BaseRequestBody.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.data.network
2 |
3 | class BaseRequestBody(val uid: Long) {
4 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/di/AppComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.di
2 |
3 | interface AppComponent {
4 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.di
2 |
3 | import android.app.Application
4 | import android.content.Context
5 | import com.alien.base.tools.SchedulerProvider
6 | import dagger.Module
7 | import dagger.Provides
8 | import io.reactivex.disposables.CompositeDisposable
9 | import javax.inject.Singleton
10 |
11 | @Module(includes = [(SingletonModule::class)])
12 | class AppModule(val application: Application) {
13 |
14 | @Provides
15 | @Singleton
16 | fun provideContext(): Context = application
17 |
18 | @Provides
19 | fun provideSchedulerProvider(): SchedulerProvider = SchedulerProvider()
20 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/di/BaseAppComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.di
2 |
3 | import com.alien.base.event.RxBus
4 | import com.alien.base.http.HttpApiService
5 | import com.alien.base.http.HttpConfig
6 | import com.alien.base.http.RestApi
7 | import com.alien.base.tools.ActivityListManager
8 | import com.alien.base.tools.SchedulerProvider
9 | import com.alien.base.tools.permission.PermissionManager
10 | import com.alien.base.ui.activity.ActivityLifeCallback
11 | import com.alien.base.ui.fragment.FragmentLifeCallback
12 | import dagger.Component
13 | import javax.inject.Singleton
14 |
15 | @Singleton
16 | @Component(modules = [(AppModule::class), (SingletonModule::class), (OtherModule::class)])
17 | interface BaseAppComponent {
18 |
19 | fun restApi(): RestApi
20 |
21 | fun rxBus(): RxBus
22 |
23 | fun apiService(): HttpApiService
24 |
25 | fun permissionManager(): PermissionManager
26 |
27 | fun activityListManager(): ActivityListManager
28 |
29 | fun activityLifeCallback(): ActivityLifeCallback
30 |
31 | fun fragmentLifeCallback(): FragmentLifeCallback
32 |
33 | fun schedulerProvider(): SchedulerProvider
34 |
35 | fun httpConfig(): HttpConfig
36 |
37 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/di/BaseViewComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.di
2 |
3 | import android.app.Activity
4 | import com.alien.base.di.scope.PerView
5 | import com.alien.base.ui.AbstractActivity
6 | import com.alien.base.ui.BaseFragment
7 | import dagger.Component
8 |
9 | @PerView
10 | @Component(modules = [(BaseViewModule::class)])
11 | interface BaseViewComponent {
12 |
13 | fun activity(): Activity
14 |
15 | fun inject(activity: AbstractActivity)
16 |
17 | fun inject(fragment: BaseFragment)
18 |
19 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/di/BaseViewModule.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.di
2 |
3 | import android.app.Activity
4 | import com.alien.base.di.scope.PerView
5 | import dagger.Module
6 | import dagger.Provides
7 |
8 | @Module
9 | class BaseViewModule(val activity: Activity) {
10 |
11 | @Provides
12 | @PerView
13 | fun provideActivity() = activity
14 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/di/OtherModule.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.di
2 |
3 | import android.support.v4.util.SimpleArrayMap
4 | import com.alien.base.http.HttpConfig
5 | import com.alien.base.tools.ActivityListManager
6 | import com.alien.base.tools.permission.PermissionManager
7 | import com.alien.base.ui.activity.ActivityLife
8 | import com.alien.base.ui.activity.IActivityLife
9 | import com.alien.base.ui.fragment.FragmentLife
10 | import com.alien.base.ui.fragment.IFragmentLife
11 | import dagger.Module
12 | import dagger.Provides
13 | import javax.inject.Singleton
14 |
15 | @Module
16 | class OtherModule {
17 |
18 | @Provides
19 | fun httpConfig(): HttpConfig {
20 | return HttpConfig()
21 | }
22 |
23 | @Singleton
24 | @Provides
25 | fun permissionManager(): PermissionManager {
26 | return PermissionManager()
27 | }
28 |
29 | @Singleton
30 | @Provides
31 | fun activityListManager(): ActivityListManager {
32 | return ActivityListManager()
33 | }
34 |
35 | @Singleton
36 | @Provides
37 | fun iActivityLifes(): SimpleArrayMap {
38 | return SimpleArrayMap()
39 | }
40 |
41 | @Provides
42 | fun iActivityLife(): IActivityLife {
43 | return ActivityLife()
44 | }
45 |
46 | @Singleton
47 | @Provides
48 | fun iFragmentLifes(): SimpleArrayMap {
49 | return SimpleArrayMap()
50 | }
51 |
52 | @Provides
53 | fun iFragmentLife(): IFragmentLife {
54 | return FragmentLife()
55 | }
56 |
57 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/di/SingletonModule.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.di
2 |
3 | import com.alien.base.Constants
4 | import com.alien.base.event.RxBus
5 | import com.alien.base.http.HttpApiService
6 | import com.alien.base.http.RestApi
7 | import dagger.Module
8 | import dagger.Provides
9 | import javax.inject.Singleton
10 |
11 | @Module
12 | class SingletonModule {
13 |
14 | @Provides
15 | @Singleton
16 | fun rxBus(): RxBus = RxBus.getInstance()
17 |
18 | @Provides
19 | @Singleton
20 | fun provideHttpApiService(restApi: RestApi): HttpApiService {
21 | return restApi.retrofitNet(Constants.BASE_URL).create(HttpApiService::class.java)
22 | }
23 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/di/scope/AppScope.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.di.scope
2 |
3 | import javax.inject.Scope
4 |
5 | @Scope
6 | @Retention(AnnotationRetention.RUNTIME)
7 | @MustBeDocumented
8 | annotation class AppScope {
9 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/di/scope/PerView.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.di.scope
2 |
3 | import javax.inject.Scope
4 |
5 | @Scope
6 | @Retention(AnnotationRetention.RUNTIME)
7 | @MustBeDocumented
8 | annotation class PerView {
9 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/event/BaseEvent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.event
2 |
3 | data class BaseEvent(val type: Int, val any: Any? = null) {
4 |
5 | companion object {
6 | const val LOGIN_SUCCESS = 888
7 | }
8 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/http/ApiError.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.http
2 |
3 | import android.text.TextUtils
4 | import com.google.gson.Gson
5 | import com.google.gson.JsonSyntaxException
6 | import com.orhanobut.logger.Logger
7 | import retrofit2.HttpException
8 | import java.io.IOException
9 | import java.net.ConnectException
10 |
11 | class ApiError(e: Throwable?): Exception() {
12 |
13 | companion object {
14 | const val ERROR_TYPE_UNKNOWN = -1
15 | const val ERROR_TYPE_CONNECT = -2 // 连接超时
16 | const val ERROR_TYPE_HTTP = -3 // 连接超时
17 |
18 | const val ERROR_BAD_QEQUEST = 400
19 | const val ERROR_UNAUTHORIZED = 401
20 | const val ERROR_FORBIDDEN = 403
21 | }
22 |
23 | var error: Error? = null
24 | var msg: String = ""
25 | var code: Int = 0
26 | var errorType: Int = 0
27 |
28 | init {
29 | if (e is HttpThrowable) {
30 | this.errorType = ERROR_TYPE_HTTP
31 | this.code = e.code
32 | this.msg = e.message!!
33 | }else if (e is HttpException) {
34 | this.errorType = ERROR_TYPE_HTTP
35 | this.code = e.code()
36 | this.msg = e.message()
37 | try {
38 | val error = e.response().errorBody()!!.string()
39 | Logger.e("value %s", error)
40 | parseErrorBody(error)
41 | } catch (e1: IOException) {
42 | Logger.e("get message %s", e1)
43 | } catch (e2: JsonSyntaxException) {
44 | e2.printStackTrace()
45 | } catch (e3: Exception) {
46 | e3.printStackTrace()
47 | }
48 |
49 | } else if (e is RuntimeException) {
50 | val exception = e
51 | this.msg = e.message!!
52 | } else if (e is ConnectException) {
53 | this.errorType = ERROR_TYPE_CONNECT
54 | this.msg = e.message!!
55 | }else {
56 | this.errorType = ERROR_TYPE_UNKNOWN
57 | this.msg = e?.message!!
58 | Logger.e("error %s", this)
59 | }
60 | }
61 |
62 | private fun parseErrorBody(errorBody: String) {
63 | Logger.e("error %s", errorBody)
64 | if (TextUtils.isEmpty(errorBody)) {
65 | return
66 | }
67 | }
68 |
69 | override fun toString(): String {
70 | return Gson().toJson(this)
71 | }
72 |
73 | inner class Error {
74 | var code: Int = 0
75 | var message: String? = null
76 | var extra: String? = null
77 | }
78 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/http/HttpApiService.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.http
2 |
3 | import io.reactivex.Observable
4 | import retrofit2.http.*
5 |
6 | interface HttpApiService {
7 |
8 | @GET
9 | fun getFromHttpServer(@Url interfaceUrl: String, @QueryMap options: Map): Observable
10 |
11 | @POST
12 | fun postFromHttpServer(@Url interfaceUrl: String, @Body options: Map): Observable
13 |
14 | @PUT
15 | fun putFromHttpServer(@Url interfaceUrl: String, @Body options: Map): Observable
16 |
17 | @DELETE
18 | fun deleteFromHttpServer(@Url interfaceUrl: String): Observable
19 |
20 | @GET
21 | fun getFromHttpServerVoid(@Url interfaceUrl: String, @QueryMap options: Map): Observable
22 |
23 | @POST
24 | fun postFromHttpServerVoid(@Url interfaceUrl: String, @Body options: Map): Observable
25 |
26 | @PUT
27 | fun putFromHttpServerVoid(@Url interfaceUrl: String, @Body options: Map): Observable
28 |
29 | @DELETE
30 | fun deleteFromHttpServerVoid(@Url interfaceUrl: String): Observable
31 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/http/HttpConfig.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.http
2 |
3 | import android.support.annotation.NonNull
4 | import com.alien.base.Platform
5 |
6 | class HttpConfig() {
7 |
8 | var platform: Int = Platform.PF_A
9 |
10 | var headerMap: MutableMap = mutableMapOf()
11 |
12 | fun setHttpHeaders(@NonNull map: MutableMap){
13 | headerMap = map
14 | }
15 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/http/HttpResponse.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.http
2 |
3 | open class HttpResponse() {
4 |
5 | open var result: Int = 0
6 | open var state: Boolean = false
7 | open var msg: String = ""
8 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/http/HttpResponseObserver.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.http
2 |
3 | import com.alien.base.event.RxBus
4 | import com.orhanobut.logger.Logger
5 | import io.reactivex.Observer
6 | import io.reactivex.disposables.Disposable
7 |
8 | abstract class HttpResponseObserver : Observer {
9 |
10 | override fun onSubscribe(d: Disposable) {
11 |
12 | }
13 |
14 | override fun onNext(t: T) {
15 | if(t is HttpResult<*>){
16 | val result = t as HttpResult<*>
17 | if(result.state){
18 | if (result.data != null)
19 | onResult(t)
20 | else{
21 | val httpThrowable = HttpThrowable(result.result, result.msg)
22 | onError(ApiError(httpThrowable))
23 | }
24 | }else{
25 | val httpThrowable = HttpThrowable(result.result, result.msg)
26 | onError(ApiError(httpThrowable))
27 | }
28 | }else if (t is HttpResponse){
29 | val response = t as HttpResponse
30 | if(response.state){
31 | onResult(t)
32 | }else{
33 | val httpThrowable = HttpThrowable(response.result, response.msg)
34 | onError(ApiError(httpThrowable))
35 | }
36 | }else{
37 | onResult(t)
38 | }
39 | }
40 |
41 | override fun onComplete() {
42 |
43 | }
44 |
45 | override fun onError(e: Throwable) {
46 | Logger.e(e, "error message : %s", e.message)
47 | val error = ApiError(e)
48 | onError(error)
49 | }
50 |
51 | abstract fun onResult(result: T)
52 |
53 | abstract fun onError(error: ApiError)
54 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/http/HttpResult.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.http
2 |
3 | import com.google.gson.annotations.Expose
4 | import com.google.gson.annotations.SerializedName
5 |
6 | /**
7 | * Created by ReeseLuo on 2019/1/5.
8 | */
9 | data class HttpResult constructor(@Expose
10 | @SerializedName("result")
11 | val result: Int,
12 |
13 | @Expose
14 | @SerializedName("state")
15 | val state: Boolean,
16 |
17 | @Expose
18 | @SerializedName("msg")
19 | val msg: String,
20 |
21 | @Expose
22 | @SerializedName("data")
23 | val data: T) {
24 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/http/HttpThrowable.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.http
2 |
3 | class HttpThrowable(val code: Int, private val msg: String): Exception() {
4 |
5 | override val message: String?
6 | get() = msg
7 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/http/JsonResponseObserver.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.http
2 |
3 | import com.google.gson.GsonBuilder
4 | import com.orhanobut.logger.Logger
5 | import io.reactivex.Observer
6 | import io.reactivex.disposables.Disposable
7 | import java.lang.reflect.ParameterizedType
8 |
9 | abstract class JsonResponseObserver : Observer {
10 |
11 | override fun onSubscribe(d: Disposable) {
12 |
13 | }
14 |
15 | override fun onNext(str: String) {
16 | try {
17 | val type = javaClass.genericSuperclass as ParameterizedType
18 | val clazz = type.actualTypeArguments[0] as Class
19 | val t = GsonBuilder().create().fromJson(str, clazz)
20 |
21 | if(t is HttpResult<*>){
22 | val result = t as HttpResult<*>
23 | if(result.state){
24 | if (result.data != null)
25 | onResult(t as T)
26 | else{
27 | val httpThrowable = HttpThrowable(result.result, result.msg)
28 | onError(ApiError(httpThrowable))
29 | }
30 | }else{
31 | val httpThrowable = HttpThrowable(result.result, result.msg)
32 | onError(ApiError(httpThrowable))
33 | }
34 | }else if (t is HttpResponse){
35 | val response = t as HttpResponse
36 | if(response.state){
37 | onResult(t as T)
38 | }else{
39 | val httpThrowable = HttpThrowable(response.result, response.msg)
40 | onError(ApiError(httpThrowable))
41 | }
42 | }else{
43 | onResult(t as T)
44 | }
45 | } catch (e: Exception) {
46 | onError(ApiError(e))
47 | }
48 | }
49 |
50 | override fun onComplete() {
51 |
52 | }
53 |
54 | override fun onError(e: Throwable) {
55 | Logger.e(e, "error message : %s", e.message)
56 | val error = ApiError(e)
57 | onError(error)
58 | }
59 |
60 | abstract fun onResult(result: T)
61 |
62 | abstract fun onError(error: ApiError)
63 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/http/interceptor/HttpCacheInterceptor.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.http.interceptor
2 |
3 | import android.content.Context
4 | import com.alien.base.tools.NetWorkUtils
5 | import okhttp3.CacheControl
6 | import okhttp3.Interceptor
7 | import okhttp3.Response
8 | import java.io.IOException
9 |
10 | /**
11 | * Created by ReeseLuo on 2019/1/6.
12 | */
13 | class HttpCacheInterceptor(val context: Context, private val mCacheTimeWithNet: Int = 0, private val mCacheTimeWithoutNet: Int = 0): Interceptor {
14 |
15 | @Throws(IOException::class)
16 | override fun intercept(chain: Interceptor.Chain): Response {
17 | var request = chain.request()
18 | if (!NetWorkUtils.isNetAvailable(context)) {
19 | request = request.newBuilder().cacheControl(CacheControl.FORCE_CACHE).build()
20 | }
21 |
22 | val response = chain.proceed(request)
23 | if (NetWorkUtils.isNetAvailable(context)) {
24 | val maxAge = if (mCacheTimeWithNet > 0) mCacheTimeWithNet else 60
25 | val cacheControl = "public,max-age=$maxAge"
26 | return response.newBuilder().header("Cache-Control", cacheControl).removeHeader("Pragma").build()
27 | } else {
28 | val maxStale = if (mCacheTimeWithoutNet > 0) mCacheTimeWithoutNet else 60 * 60 * 24 * 7 * 1
29 | return response.newBuilder().header("Cache-Control", "public,only-if-cached,max-stale=$maxStale").removeHeader("Pragma").build()
30 | }
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/http/interceptor/HttpHeaderInterceptor.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.http.interceptor
2 |
3 | import okhttp3.Interceptor
4 | import okhttp3.Response
5 |
6 | class HttpHeaderInterceptor(val headers: Map): Interceptor {
7 |
8 | override fun intercept(chain: Interceptor.Chain): Response {
9 | val originalRequest = chain.request()
10 | val originalBuilder = originalRequest.newBuilder()
11 | for (entry in headers.entries) {
12 | originalBuilder.header(entry.key, entry.value)
13 | }
14 |
15 | val newBuilder = originalBuilder.method(originalRequest.method(), originalRequest.body())
16 | return chain.proceed(newBuilder.build())
17 | }
18 |
19 |
20 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/image/Compressor.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.image
2 |
3 | object Compressor {
4 |
5 | fun computeSize(originalWidth: Int, originalHeight: Int): Int {
6 | val srcWidth = if (originalWidth % 2 == 1) originalWidth + 1 else originalWidth
7 | val srcHeight = if (originalHeight % 2 == 1) originalHeight + 1 else originalHeight
8 |
9 | val longSide = Math.max(srcWidth, srcHeight)
10 | val shortSide = Math.min(srcWidth, srcHeight)
11 |
12 | val scale = shortSide.toFloat() / longSide
13 | return if (scale <= 1 && scale > 0.5625) {
14 | if (longSide < 1664) {
15 | 1
16 | } else if (longSide < 4990) {
17 | 2
18 | } else if (longSide in 4991..10239) {
19 | 4
20 | } else {
21 | if (longSide / 1280 == 0) 1 else longSide / 1280
22 | }
23 | } else if (scale <= 0.5625 && scale > 0.5) {
24 | if (longSide / 1280 == 0) 1 else longSide / 1280
25 | } else {
26 | Math.ceil(longSide / (1280.0 / scale)).toInt()
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/image/GlideLoader.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.image
2 |
3 | import android.support.annotation.DrawableRes
4 | import android.widget.ImageView
5 | import com.alien.base.R
6 | import com.bumptech.glide.Glide
7 | import com.bumptech.glide.request.RequestOptions
8 | import jp.wasabeef.glide.transformations.BlurTransformation
9 |
10 | object GlideLoader {
11 |
12 | fun load(url: String?, imageView: ImageView){
13 | Glide.with(imageView.context)
14 | .load(url)
15 | .into(imageView)
16 | }
17 |
18 | fun loadBlur(url: String?, imageView: ImageView){
19 | Glide.with(imageView.context)
20 | .load(url)
21 | .apply(RequestOptions().transform(BlurTransformation(25, 6)))
22 | .into(imageView)
23 | }
24 |
25 | fun loadBlur(url: String?, imageView: ImageView, sampling: Int = 3, placeholder: Int = android.R.color.transparent){
26 | Glide.with(imageView.context)
27 | .load(url)
28 | .apply(RequestOptions()
29 | .transform(BlurTransformation(25, sampling))
30 | .placeholder(placeholder))
31 | .into(imageView)
32 | }
33 |
34 | fun loadRes(resId: Int, imageView: ImageView) {
35 | Glide.with(imageView.context)
36 | .load(resId)
37 | .apply(RequestOptions()
38 | .placeholder(resId))
39 | .into(imageView)
40 | }
41 |
42 | fun loadCircle(url: String?, imageView: ImageView, @DrawableRes resId: Int = R.drawable.ic_avatar){
43 | Glide.with(imageView.context)
44 | .load(url)
45 | .apply(RequestOptions()
46 | .circleCrop()
47 | .placeholder(resId))
48 | .into(imageView)
49 | }
50 |
51 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/modulekit/AModuleKit.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.modulekit
2 |
3 | import com.alien.base.di.AppComponent
4 |
5 | class AModuleKit {
6 |
7 | private var component: AppComponent? = null
8 |
9 | companion object {
10 | private var instance: AModuleKit? = null
11 |
12 | fun getInstance(): AModuleKit{
13 | if (instance == null){
14 | synchronized(AModuleKit::class.java){
15 | if (instance == null){
16 | instance = AModuleKit()
17 | }
18 | }
19 | }
20 | return instance!!
21 | }
22 | }
23 |
24 | fun init(delegate: AppModuleComponentDelegate){
25 | component = delegate.initAppComponent()
26 | }
27 |
28 | fun getComponent() = component
29 |
30 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/modulekit/AppModuleComponentDelegate.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.modulekit
2 |
3 | import com.alien.base.di.AppComponent
4 |
5 | interface AppModuleComponentDelegate {
6 |
7 | fun initAppComponent(): AppComponent
8 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/modulekit/BModuleKit.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.modulekit
2 |
3 | import com.alien.base.di.AppComponent
4 |
5 | class BModuleKit {
6 |
7 | private var component: AppComponent? = null
8 |
9 | companion object {
10 | private var instance: BModuleKit? = null
11 |
12 | fun getInstance(): BModuleKit{
13 | if (instance == null){
14 | synchronized(BModuleKit::class.java){
15 | if (instance == null){
16 | instance = BModuleKit()
17 | }
18 | }
19 | }
20 | return instance!!
21 | }
22 | }
23 |
24 | fun init(delegate: AppModuleComponentDelegate){
25 | component = delegate.initAppComponent()
26 | }
27 |
28 | fun getComponent() = component
29 |
30 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/modulekit/BaseModuleKit.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.modulekit
2 |
3 | import android.app.Application
4 | import com.alien.base.BaseApplication
5 | import com.alien.base.di.AppModule
6 | import com.alien.base.di.BaseAppComponent
7 | import com.alien.base.di.DaggerBaseAppComponent
8 |
9 | class BaseModuleKit {
10 |
11 | private var component: BaseAppComponent? = null
12 | private var application: Application? = null
13 |
14 | companion object {
15 | private var instance: BaseModuleKit? = null
16 |
17 | fun getInstance(): BaseModuleKit{
18 | if (instance == null){
19 | synchronized(BaseModuleKit::class.java){
20 | if (instance == null){
21 | instance = BaseModuleKit()
22 | instance?.application = BaseApplication.getInstance()
23 | instance?.component = DaggerBaseAppComponent.builder()
24 | .appModule(AppModule(instance?.application!!))
25 | .build()
26 | }
27 | }
28 | }
29 |
30 | return instance!!
31 | }
32 | }
33 |
34 | fun getComponent() = component
35 |
36 | fun getApplication() = application
37 |
38 | fun activityListManager() = component?.activityListManager()
39 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/modulekit/CModuleKit.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.modulekit
2 |
3 | import com.alien.base.di.AppComponent
4 |
5 | class CModuleKit {
6 |
7 | private var component: AppComponent? = null
8 |
9 | companion object {
10 | private var instance: CModuleKit? = null
11 |
12 | fun getInstance(): CModuleKit{
13 | if (instance == null){
14 | synchronized(CModuleKit::class.java){
15 | if (instance == null){
16 | instance = CModuleKit()
17 | }
18 | }
19 | }
20 | return instance!!
21 | }
22 | }
23 |
24 | fun init(delegate: AppModuleComponentDelegate){
25 | component = delegate.initAppComponent()
26 | }
27 |
28 | fun getComponent() = component
29 |
30 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/modulekit/DModuleKit.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.modulekit
2 |
3 | import com.alien.base.di.AppComponent
4 |
5 | class DModuleKit {
6 |
7 | private var component: AppComponent? = null
8 |
9 | companion object {
10 | private var instance: DModuleKit? = null
11 |
12 | fun getInstance(): DModuleKit{
13 | if (instance == null){
14 | synchronized(DModuleKit::class.java){
15 | if (instance == null){
16 | instance = DModuleKit()
17 | }
18 | }
19 | }
20 | return instance!!
21 | }
22 | }
23 |
24 | fun init(delegate: AppModuleComponentDelegate){
25 | component = delegate.initAppComponent()
26 | }
27 |
28 | fun getComponent() = component
29 |
30 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/modulekit/EModuleKit.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.modulekit
2 |
3 | import com.alien.base.di.AppComponent
4 |
5 | class EModuleKit {
6 |
7 | private var component: AppComponent? = null
8 |
9 | companion object {
10 | private var instance: EModuleKit? = null
11 |
12 | fun getInstance(): EModuleKit{
13 | if (instance == null){
14 | synchronized(EModuleKit::class.java){
15 | if (instance == null){
16 | instance = EModuleKit()
17 | }
18 | }
19 | }
20 | return instance!!
21 | }
22 | }
23 |
24 | fun init(delegate: AppModuleComponentDelegate){
25 | component = delegate.initAppComponent()
26 | }
27 |
28 | fun getComponent() = component
29 |
30 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/mvp/BasePresenter.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.mvp
2 |
3 | interface BasePresenter{
4 |
5 | fun onAttach(view: T)
6 |
7 | fun onDetach()
8 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/mvp/BaseRepository.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.mvp
2 |
3 | import com.alien.base.data.pref.AppSp
4 | import com.alien.base.data.pref.UserSp
5 |
6 | abstract class BaseRepository: MVPRepository {
7 |
8 | override fun uid(): String = if (isUserLogin()) UserSp.uid().toString() else AppSp.uuid()
9 |
10 | override fun isUserLogin(): Boolean = UserSp.uid() != 0L
11 |
12 | override fun performUserLogout() = UserSp.clear()
13 |
14 | override fun isUuid(): String = if (isUserLogin()) UserSp.uid().toString() else AppSp.uuid()
15 |
16 | override fun isUid(): Long = UserSp.uid()
17 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/mvp/BaseView.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.mvp
2 |
3 | interface BaseView : MVPView{
4 |
5 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/mvp/MVPRepository.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.mvp
2 |
3 | interface MVPRepository {
4 |
5 | fun uid(): String
6 |
7 | fun isUserLogin(): Boolean
8 |
9 | fun isUuid(): String
10 |
11 | fun isUid(): Long
12 |
13 | fun performUserLogout()
14 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/mvp/MVPView.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.mvp
2 |
3 | import android.content.Context
4 | import com.alien.base.http.ApiError
5 |
6 | interface MVPView {
7 |
8 | fun onError(error: ApiError)
9 |
10 | fun context(): Context
11 |
12 | fun showToast(text: String)
13 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/BaseSharePresenter.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share
2 |
3 | import android.content.Intent
4 |
5 | interface BaseSharePresenter {
6 |
7 | fun shareWithQQ()
8 |
9 | fun shareWithQZone()
10 |
11 | fun shareWithWechat()
12 |
13 | fun shareWithSina()
14 |
15 | fun onNewIntent(intent: Intent?)
16 |
17 | fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)
18 |
19 | fun onDestroy()
20 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/ShareActivity.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import com.alien.base.share.data.ShareConstant
6 | import com.alien.base.share.data.ShareEntity
7 | import com.alien.base.share.manager.ShareManager
8 |
9 | class ShareActivity: WXCallbackActivity() {
10 |
11 | lateinit var mShareEntity: ShareEntity
12 | lateinit var mPresenter: SharePresenter
13 |
14 | override fun onCreateInit(savedInstanceState: Bundle?) {
15 | super.onCreateInit(savedInstanceState)
16 | ShareManager.initSinaSdk(this)
17 | mShareEntity = intent.getSerializableExtra(ShareConstant.DATA) as ShareEntity
18 | mPresenter = SharePresenter(this, mShareEntity)
19 | mPresenter.init(this)
20 | }
21 |
22 | override fun onNewIntent(intent: Intent?) {
23 | super.onNewIntent(intent)
24 | mPresenter.onNewIntent(intent)
25 | }
26 |
27 | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
28 | super.onActivityResult(requestCode, resultCode, data)
29 | mPresenter.onActivityResult(requestCode, resultCode, data)
30 | }
31 |
32 | override fun onDestroy() {
33 | mPresenter.onDestroy()
34 | super.onDestroy()
35 | }
36 |
37 | override fun onAuthSuccess(code: String?) {
38 |
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/ShareCallbackView.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share
2 |
3 | interface ShareCallbackView {
4 |
5 | fun onShareFail(err: String?)
6 |
7 | fun onShareCancel()
8 |
9 | fun onShareSuccess()
10 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/data/ShareConstant.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share.data
2 |
3 | object ShareConstant {
4 |
5 | const val TYPE_LOGIN = 0
6 | const val TYPE_SHARE = 1
7 | const val ACTIVITY_RESULT_CODE = 1000
8 | const val DATA = "data"
9 |
10 | const val APP_NAME = ""
11 |
12 | const val QQ_APP_ID = ""
13 |
14 | const val QQ_SCOPE = "get_user_info,get_simple_userinfo,get_user_profile,get_app_friends," + "add_share,add_topic,list_album,upload_pic,add_album,set_user_face,get_vip_info,get_vip_rich_info,get_intimate_friends_weibo,match_nick_tips_weibo,add_pic_t"
15 |
16 | const val SINA_APP_KEY = ""
17 |
18 | const val SINA_APP_SECRET = ""
19 |
20 | const val SINA_REDIRECT_URL = ""
21 |
22 | const val SINA_SCOPE = (
23 | "email,direct_messages_read,direct_messages_write,"
24 | + "friendships_groups_read,friendships_groups_write,statuses_to_me_read,"
25 | + "follow_app_official_microblog," + "invitation_write")
26 |
27 | const val WX_APP_ID = ""
28 |
29 | const val WX_APP_SECRET = ""
30 | }
31 |
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/data/ShareEntity.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share.data
2 |
3 | import com.google.gson.annotations.Expose
4 | import com.google.gson.annotations.SerializedName
5 | import java.io.Serializable
6 |
7 | data class ShareEntity constructor(
8 | @Expose
9 | @SerializedName("title")
10 | val title: String,
11 |
12 | @Expose
13 | @SerializedName("icon")
14 | val icon: String,
15 |
16 | @Expose
17 | @SerializedName("id")
18 | val id: Long,
19 |
20 | @Expose
21 | @SerializedName("text")
22 | val text: String,
23 |
24 | @Expose
25 | @SerializedName("url")
26 | val url: String,
27 |
28 | @Expose
29 | @SerializedName("type")
30 | val type: Int,
31 |
32 | @Expose
33 | @SerializedName("redirect")
34 | val redirect: String,
35 |
36 | val platformType: String,
37 |
38 | val isLocalUrl: Boolean
39 |
40 | ) : Serializable{
41 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/data/ShareType.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share.data
2 |
3 | object ShareType {
4 |
5 | const val QQ = "qq"
6 | const val QZONE = "qzone"
7 | const val WECHAT = "wechat"
8 | const val WECHATF = "wechatf"
9 | const val SINA = "weibo"
10 |
11 | const val TYPE_TEXT = 0
12 | const val TYPE_PIC = 1
13 | const val TYPE_MUSIC = 2
14 | const val TYPE_VIDEO = 3
15 | const val TYPE_WEB = 4
16 | const val TYPE_MINI = 5
17 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/manager/BaseSharer.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share.manager
2 |
3 | import android.graphics.Bitmap
4 | import android.graphics.BitmapFactory
5 | import android.support.annotation.NonNull
6 | import com.alien.base.image.Compressor
7 | import java.io.ByteArrayOutputStream
8 | import java.io.File
9 | import java.net.HttpURLConnection
10 | import java.net.URL
11 |
12 | abstract class BaseSharer: ShareView {
13 |
14 | override fun localToBitmap(path: String): Bitmap? {
15 | val file = File(path)
16 | return if (!file.exists()) {
17 | null
18 | } else {
19 | val originalBitmap = BitmapFactory.decodeFile(path)
20 | val options = BitmapFactory.Options()
21 | options.inPreferredConfig = Bitmap.Config.RGB_565
22 | options.inSampleSize = Compressor.computeSize(originalBitmap.width, originalBitmap.height)
23 | if (originalBitmap != null && !originalBitmap.isRecycled){
24 | originalBitmap.recycle()
25 | }
26 | BitmapFactory.decodeFile(path, options)
27 | }
28 | }
29 |
30 | override fun toBitmap(@NonNull url: String): Bitmap? {
31 | val url = URL(url)
32 | val httpURLConnection = url.openConnection() as HttpURLConnection
33 | httpURLConnection.connect()
34 | httpURLConnection.connectTimeout = 5 * 1000
35 | httpURLConnection.requestMethod = "GET"
36 | return BitmapFactory.decodeStream(httpURLConnection.inputStream)
37 | }
38 |
39 | override fun binaryToBytes(bitmap: Bitmap): ByteArray {
40 | val bos = ByteArrayOutputStream()
41 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos)
42 | if (!bitmap.isRecycled){
43 | bitmap.recycle()
44 | }
45 | return bos.toByteArray()
46 | }
47 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/manager/QQShareView.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share.manager
2 |
3 | interface QQShareView {
4 |
5 | fun share()
6 |
7 | fun shareDefault()
8 |
9 | fun sharePic()
10 |
11 | fun shareAudio()
12 |
13 | fun shareToQzone()
14 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/manager/ShareManager.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share.manager
2 |
3 | import android.app.Activity
4 | import android.content.Context
5 | import android.content.Intent
6 | import com.alien.base.share.ShareActivity
7 | import com.alien.base.share.data.ShareConstant
8 | import com.alien.base.share.data.ShareEntity
9 | import com.sina.weibo.sdk.WbSdk
10 | import com.sina.weibo.sdk.auth.AuthInfo
11 | import com.sina.weibo.sdk.share.WbShareHandler
12 | import com.tencent.mm.opensdk.openapi.IWXAPI
13 | import com.tencent.tauth.IUiListener
14 |
15 | object ShareManager {
16 |
17 | fun share(activity: Activity, shareEntity: ShareEntity){
18 | val intent = Intent(activity, ShareActivity::class.java)
19 | intent.putExtra(ShareConstant.DATA, shareEntity)
20 | intent.putExtra("type", ShareConstant.TYPE_SHARE)
21 | activity.startActivityForResult(intent, ShareConstant.ACTIVITY_RESULT_CODE)
22 | }
23 |
24 | fun initSinaSdk(context: Context){
25 | WbSdk.install(context, AuthInfo(context,
26 | ShareConstant.SINA_APP_KEY,
27 | ShareConstant.SINA_REDIRECT_URL,
28 | ShareConstant.SINA_SCOPE))
29 | }
30 |
31 |
32 | fun qqSharer(activity: Activity, iUiListener: IUiListener, shareEntity: ShareEntity) = QQSharer(activity, shareEntity, iUiListener)
33 |
34 | fun wxSharer(api: IWXAPI, shareEntity: ShareEntity) = WXSharer(api, shareEntity)
35 |
36 | fun sinaSharer(shareHandler: WbShareHandler, shareEntity: ShareEntity) = SinaSharer(shareHandler, shareEntity)
37 |
38 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/manager/ShareView.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share.manager
2 |
3 | import android.graphics.Bitmap
4 | import android.support.annotation.Nullable
5 | import com.alien.base.share.data.ShareEntity
6 |
7 | interface ShareView {
8 |
9 | fun onPreExecute(): String?
10 |
11 | fun doInBackground(): Bitmap?
12 |
13 | fun onPostExecute(bitmap: Bitmap?)
14 |
15 | fun share(shareEntity: ShareEntity, @Nullable bitmap: Bitmap?)
16 |
17 | fun binaryToBytes(bitmap: Bitmap) : ByteArray
18 |
19 | fun toBitmap(url: String) : Bitmap?
20 |
21 | fun localToBitmap(path: String) : Bitmap?
22 |
23 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/manager/SinaSharer.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share.manager
2 |
3 | import android.graphics.Bitmap
4 | import android.support.annotation.Nullable
5 | import com.alien.base.share.data.ShareEntity
6 | import com.sina.weibo.sdk.api.ImageObject
7 | import com.sina.weibo.sdk.api.TextObject
8 | import com.sina.weibo.sdk.api.WeiboMultiMessage
9 | import com.sina.weibo.sdk.share.WbShareHandler
10 |
11 | class SinaSharer(val shareHandler: WbShareHandler, val shareEntity: ShareEntity): BaseSharer() {
12 |
13 | override fun onPreExecute(): String? {
14 | return null
15 | }
16 |
17 | override fun doInBackground(): Bitmap? {
18 | return if (shareEntity.isLocalUrl) localToBitmap(shareEntity.icon)
19 | else toBitmap(shareEntity.icon)
20 | }
21 |
22 | override fun onPostExecute(bitmap: Bitmap?) {
23 | share(shareEntity, bitmap)
24 | }
25 |
26 | override fun share(shareEntity: ShareEntity, @Nullable bitmap: Bitmap?) {
27 | val weiboMessage = WeiboMultiMessage()
28 | val textObject = TextObject()
29 | textObject.text = shareEntity.text
30 | textObject.title = shareEntity.title
31 | textObject.actionUrl = shareEntity.url
32 | if (bitmap != null) {
33 | val imageObject = ImageObject()
34 | imageObject.setImageObject(bitmap)
35 | weiboMessage.imageObject = imageObject
36 | }
37 | weiboMessage.textObject = textObject
38 | shareHandler.shareMessage(weiboMessage, false)
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/share/manager/WXShareView.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.share.manager
2 |
3 | interface WXShareView {
4 |
5 | fun shareText()
6 |
7 | fun shareWeb()
8 |
9 | fun sharePic()
10 |
11 | fun shareMusic()
12 |
13 | fun shareVideo()
14 |
15 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/tools/AppUtil.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.tools
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.content.pm.ApplicationInfo
6 | import android.content.pm.PackageManager
7 | import android.content.res.Resources
8 | import android.os.Build
9 | import android.provider.Settings
10 | import android.telephony.TelephonyManager
11 | import android.text.TextUtils
12 | import com.alien.base.Constants
13 |
14 | object AppUtil {
15 |
16 | @SuppressLint("MissingPermission", "HardwareIds")
17 | fun getImei(context: Context) : String {
18 | var imei = ""
19 | try {
20 | val telephonyManager = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
21 | imei = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
22 | telephonyManager.imei
23 | }else{
24 | telephonyManager.deviceId
25 | }
26 | if (TextUtils.isEmpty(imei)){
27 | imei = getAndroidId(context)
28 | }
29 | } catch (e: Exception) {
30 | }
31 | return imei
32 | }
33 |
34 | fun getAndroidId(context: Context): String {
35 | var aId = ""
36 | try {
37 | aId = Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
38 | } catch (e: Exception) {
39 | }
40 |
41 | return aId
42 | }
43 |
44 | fun getChannel(context: Context) : String {
45 | val applicationInfo: ApplicationInfo = context.packageManager?.getApplicationInfo(context.packageName, PackageManager.GET_META_DATA)!!
46 | return applicationInfo.metaData.getString("umeng_channel", "")
47 | }
48 |
49 | fun getVersionCode(context: Context) : Int {
50 | val packageInfo = context.packageManager?.getPackageInfo(context.packageName, 0)
51 | return packageInfo?.versionCode!!
52 | }
53 |
54 | fun hasMore(list: MutableList<*>?) = list != null && list.size >= Constants.PAGE_MAX_SIZE
55 |
56 | fun statusBarHeight(): Int{
57 | return Resources.getSystem()
58 | .getDimensionPixelSize(Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android"));
59 | }
60 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/tools/NetWorkUtils.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.tools
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.net.ConnectivityManager
6 | import android.net.NetworkInfo
7 |
8 | @SuppressLint("MissingPermission")
9 | object NetWorkUtils {
10 |
11 |
12 | fun isWifiConnected(context: Context?): Boolean {
13 | if (context == null) return false
14 | val manager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
15 | val active = manager.activeNetworkInfo
16 | return active != null && active.type == ConnectivityManager.TYPE_WIFI
17 | }
18 |
19 | fun isNetConnected(context: Context?): Boolean {
20 | if (context == null) return false
21 | val manager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
22 | val info = manager.activeNetworkInfo
23 | return info != null && info.isConnected && info.state == NetworkInfo.State.CONNECTED
24 | }
25 |
26 | fun isNetAvailable(context: Context): Boolean {
27 | val networkInfo = getActiveNetworkInfo(context)
28 | return networkInfo?.isAvailable ?: false
29 | }
30 |
31 |
32 | private fun getActiveNetworkInfo(context: Context): NetworkInfo? {
33 | try {
34 | val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
35 | return cm.activeNetworkInfo
36 | } catch (e: Exception) {
37 | return null
38 | }
39 |
40 | }
41 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/tools/SchedulerProvider.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.tools
2 |
3 | import io.reactivex.*
4 | import io.reactivex.android.schedulers.AndroidSchedulers
5 | import io.reactivex.schedulers.Schedulers
6 |
7 | class SchedulerProvider {
8 |
9 | fun ioToMainObservableScheduler(): ObservableTransformer = ObservableTransformer {
10 | upstream -> upstream.subscribeOn(getIOThreadScheduler()).observeOn(getMainThreadScheduler())
11 | }
12 |
13 | fun ioToMainSingleScheduler(): SingleTransformer = SingleTransformer { upstream ->
14 | upstream.subscribeOn(getIOThreadScheduler())
15 | .observeOn(getMainThreadScheduler())
16 | }
17 |
18 |
19 | fun ioToMainCompletableScheduler(): CompletableTransformer = CompletableTransformer { upstream ->
20 | upstream.subscribeOn(getIOThreadScheduler())
21 | .observeOn(getMainThreadScheduler())
22 | }
23 |
24 |
25 | fun ioToMainFlowableScheduler(): FlowableTransformer = FlowableTransformer { upstream ->
26 | upstream.subscribeOn(getIOThreadScheduler())
27 | .observeOn(getMainThreadScheduler())
28 | }
29 |
30 |
31 | fun ioToMainMaybeScheduler(): MaybeTransformer = MaybeTransformer { upstream ->
32 | upstream.subscribeOn(getIOThreadScheduler())
33 | .observeOn(getMainThreadScheduler())
34 | }
35 |
36 | fun getIOThreadScheduler() = Schedulers.io()
37 |
38 | fun getMainThreadScheduler() = AndroidSchedulers.mainThread()
39 |
40 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/tools/StringUtils.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.tools
2 |
3 | import android.text.TextUtils
4 | import com.google.common.base.Objects
5 | import java.text.DecimalFormat
6 | import java.util.regex.Pattern
7 |
8 | object StringUtils{
9 |
10 | fun isMobile(mobiles: String): Boolean {
11 | val telRegex = "\\d{11}"
12 | return if (TextUtils.isEmpty(mobiles))
13 | false
14 | else
15 | mobiles.matches(telRegex.toRegex())
16 | }
17 |
18 | fun mobileEncr(mobiles: String): String? {
19 | return if (isMobile(mobiles)) {
20 | mobiles.substring(0, 3) + "****" + mobiles.substring(7, mobiles.length)
21 | } else null
22 | }
23 |
24 | fun equals(s1: String, s2: String): Boolean {
25 | return Objects.equal(s1, s2)
26 | }
27 |
28 | fun getLength(cs: CharSequence?): Int {
29 | return cs?.length ?: 0
30 | }
31 |
32 | fun isEmpty(str: String?): Boolean {
33 | return str == null || str.length == 0
34 | }
35 |
36 | //替换空格,tab,制表符,换行符 以及全角空格等
37 | fun replaceBlank(str: String?): String {
38 | var dest = ""
39 | if (str != null) {
40 | val p = Pattern.compile("\u3000|\\s*|\t|\r|\n")// \u3000表示全角空格
41 | val m = p.matcher(str)
42 | dest = m.replaceAll("")
43 | }
44 | return dest
45 | }
46 |
47 | fun formatValue(value: Int?): String {
48 | val format = DecimalFormat(",###")
49 | return format.format(value)
50 | }
51 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/tools/TimeUtils.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.tools
2 |
3 | import java.text.SimpleDateFormat
4 | import java.util.*
5 |
6 | object TimeUtils {
7 |
8 | fun getToday(): String{
9 | val format = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
10 | return format.format(Date())
11 | }
12 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/tools/permission/PermissionListener.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.tools.permission
2 |
3 | interface PermissionListener {
4 |
5 | fun onGranted(permissionName: String?)
6 |
7 | fun onDenied(permissionName: String?)
8 |
9 | fun onDeniedWithNeverAsk(permissionName: String?)
10 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/tools/permission/PermissionManager.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.tools.permission
2 |
3 | import android.annotation.SuppressLint
4 | import android.support.v4.app.FragmentActivity
5 | import com.tbruyelle.rxpermissions2.RxPermissions
6 |
7 | class PermissionManager {
8 |
9 | @SuppressLint("CheckResult")
10 | fun requestEach(activity: FragmentActivity?, listener: PermissionListener?, permissions: String) {
11 | if (activity != null) {
12 | val rxPermissions = RxPermissions(activity)
13 | rxPermissions.requestEach(permissions).subscribe { permission ->
14 | if (permission.granted) {
15 | listener?.onGranted(permission.name)
16 | } else if (permission.shouldShowRequestPermissionRationale) {
17 | listener?.onDenied(permission.name)
18 | } else {
19 | listener?.onDeniedWithNeverAsk(permission.name)
20 | }
21 | }
22 | }
23 | }
24 |
25 | @SuppressLint("CheckResult")
26 | fun requestEachCombined(activity: FragmentActivity?, listener: PermissionListener?, vararg permissions: String) {
27 | if (activity != null) {
28 | val rxPermissions = RxPermissions(activity)
29 | rxPermissions.requestEachCombined(*permissions).subscribe { permission ->
30 | if (permission.granted) {
31 | listener?.onGranted(permission.name)
32 | } else if (permission.shouldShowRequestPermissionRationale) {
33 | listener?.onDenied(permission.name)
34 | } else {
35 | listener?.onDeniedWithNeverAsk(permission.name)
36 | }
37 | }
38 | }
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/ui/AbstractActivity.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.ui
2 |
3 | import android.graphics.Color
4 | import android.graphics.drawable.ColorDrawable
5 | import android.os.Bundle
6 | import android.support.v7.app.AppCompatActivity
7 | import android.util.DisplayMetrics
8 | import android.view.WindowManager
9 | import com.alien.base.di.BaseViewComponent
10 | import com.alien.base.di.BaseViewModule
11 | import com.alien.base.di.DaggerBaseViewComponent
12 | import com.alien.base.mvp.MVPView
13 | import com.alien.base.ui.activity.IBaseActivity
14 | import com.github.zackratos.ultimatebar.ultimateBarBuilder
15 |
16 | abstract class AbstractActivity : AppCompatActivity(), IBaseActivity, MVPView {
17 | private var mBaseViewComponent: BaseViewComponent? = null
18 |
19 | fun component(): BaseViewComponent? {
20 | if (mBaseViewComponent == null) {
21 | mBaseViewComponent = DaggerBaseViewComponent.builder()
22 | .baseViewModule(BaseViewModule(this))
23 | .build()
24 | }
25 | return mBaseViewComponent
26 | }
27 |
28 | override fun onCreate(savedInstanceState: Bundle?) {
29 | super.onCreate(savedInstanceState)
30 | initFontScale()
31 | component()!!.inject(this)
32 | ultimateBarBuilder().statusDark(true)
33 | .statusDrawable(ColorDrawable(statusColor()))
34 | .create()
35 | .drawableBar()
36 |
37 | if (isFullScreen()) {
38 | window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
39 | }
40 | }
41 |
42 | private fun initFontScale() {
43 | val configuration = resources.configuration
44 | configuration.fontScale = 1.toFloat()
45 | //0.85 小, 1 标准大小, 1.15 大,1.3 超大 ,1.45 特大
46 | val metrics = DisplayMetrics()
47 | windowManager.defaultDisplay.getMetrics(metrics)
48 | metrics.scaledDensity = configuration.fontScale * metrics.density
49 | baseContext.resources.updateConfiguration(configuration, metrics)
50 | }
51 |
52 | override fun statusColor(): Int = Color.WHITE
53 |
54 | override fun isFullScreen(): Boolean = false
55 |
56 | override fun isImmersionBar(): Boolean = false
57 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/ui/BaseActivity.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.ui
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import com.alien.base.Constants
6 | import com.alien.base.data.pref.UserSp
7 | import com.alien.base.http.ApiError
8 | import com.alien.baselib.ExtendFun.toast
9 | import com.android.componentlib.router.Jumper
10 |
11 | abstract class BaseActivity: AbstractActivity() {
12 |
13 | var page: Int = Constants.START_PAGE
14 |
15 | companion object {
16 | const val RESULT_DELETE = 2
17 | const val RESULT_QR_SUCCESS = 3
18 | const val RESULT_EDIT = 5
19 | }
20 |
21 | override fun onCreate(savedInstanceState: Bundle?) {
22 | super.onCreate(savedInstanceState)
23 | if(getResLayout() != 0) {
24 | setContentView(getResLayout())
25 | }
26 | onCreateInit(savedInstanceState)
27 | }
28 |
29 | abstract fun onCreateInit(savedInstanceState: Bundle?)
30 |
31 | abstract fun getResLayout(): Int
32 |
33 | override fun isUseEventBus(): Boolean = false
34 |
35 | override fun isUseFragment(): Boolean = false
36 |
37 | override fun onError(error: ApiError){
38 | if(error.code == 1){
39 | UserSp.clear()
40 | Jumper.login(context = this)
41 | }
42 | toast(error.msg)
43 | page--
44 | }
45 |
46 | override fun context(): Context = this
47 |
48 | override fun showToast(text: String) {
49 | toast(text)
50 | }
51 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/ui/BaseDialogFragment.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.ui
2 |
3 | import android.os.Bundle
4 | import android.support.v4.app.DialogFragment
5 | import com.alien.base.R
6 |
7 | abstract class BaseDialogFragment : DialogFragment() {
8 |
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setStyle(DialogFragment.STYLE_NO_TITLE, R.style.DialogStyle)
12 | }
13 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/ui/activity/ActivityLife.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.ui.activity
2 |
3 | import android.app.Activity
4 | import android.os.Bundle
5 | import com.alien.base.modulekit.BaseModuleKit
6 | import com.alien.base.tools.ActivityListManager
7 | import com.trello.rxlifecycle2.android.ActivityEvent
8 | import io.reactivex.subjects.PublishSubject
9 |
10 | class ActivityLife: IActivityLife {
11 |
12 | private var mActivity: Activity? = null
13 | private val mLifecycleSubject = PublishSubject.create()
14 |
15 | override fun onCreate(activity: Activity, savedInstanceState: Bundle?) {
16 | mActivity = activity
17 |
18 | mLifecycleSubject.onNext(ActivityEvent.CREATE)
19 |
20 | var isNotAdd = false
21 | if (activity.intent != null) isNotAdd = activity.intent.getBooleanExtra(ActivityListManager.IS_NOT_ADD_ACTIVITY_LIST, false)
22 |
23 | if (!isNotAdd) BaseModuleKit.getInstance().activityListManager()!!.addActivity(activity)
24 |
25 | if ((mActivity as IBaseActivity).isUseEventBus()) {
26 | // DevRing.busManager().register(mActivity);
27 | }
28 | }
29 |
30 | override fun onStart() {
31 | mLifecycleSubject.onNext(ActivityEvent.START)
32 | }
33 |
34 | override fun onResume() {
35 | BaseModuleKit.getInstance().activityListManager()?.setCurrentActivity(mActivity)
36 | mLifecycleSubject.onNext(ActivityEvent.RESUME)
37 | }
38 |
39 | override fun onPause() {
40 | mLifecycleSubject.onNext(ActivityEvent.PAUSE)
41 | }
42 |
43 | override fun onStop() {
44 | if (BaseModuleKit.getInstance().activityListManager()?.getCurrentActivity() === mActivity) {
45 | BaseModuleKit.getInstance().activityListManager()?.setCurrentActivity(null)
46 | }
47 | mLifecycleSubject.onNext(ActivityEvent.STOP)
48 | }
49 |
50 | override fun onSaveInstanceState(outState: Bundle?) {
51 |
52 | }
53 |
54 | override fun onDestroy() {
55 | mLifecycleSubject.onNext(ActivityEvent.DESTROY)
56 |
57 | BaseModuleKit.getInstance().activityListManager()?.removeActivity(mActivity)
58 |
59 | if ((mActivity as IBaseActivity).isUseEventBus()) {
60 | // DevRing.busManager().unregister(mActivity)
61 | }
62 | mActivity = null
63 | }
64 |
65 | fun getLifecycleSubject(): PublishSubject {
66 | return mLifecycleSubject
67 | }
68 |
69 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/ui/activity/IActivityLife.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.ui.activity
2 |
3 | import android.app.Activity
4 | import android.os.Bundle
5 |
6 | interface IActivityLife {
7 |
8 | fun onCreate(activity: Activity, savedInstanceState: Bundle?)
9 |
10 | fun onStart()
11 |
12 | fun onResume()
13 |
14 | fun onPause()
15 |
16 | fun onStop()
17 |
18 | fun onSaveInstanceState(outState: Bundle?)
19 |
20 | fun onDestroy()
21 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/ui/activity/IBaseActivity.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.ui.activity
2 |
3 | interface IBaseActivity {
4 |
5 | fun isUseEventBus(): Boolean
6 |
7 | fun isUseFragment(): Boolean
8 |
9 | fun statusColor(): Int
10 |
11 | fun isFullScreen(): Boolean
12 |
13 | fun isImmersionBar(): Boolean
14 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/ui/fragment/IBaseFragment.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.ui.fragment
2 |
3 | import android.os.Bundle
4 |
5 | interface IBaseFragment {
6 |
7 | fun onSaveState(bundleToSave: Bundle)
8 |
9 | fun onRestoreState(bundleToRestore: Bundle)
10 |
11 | fun isUseEventBus(): Boolean
12 | }
--------------------------------------------------------------------------------
/basemodule/src/main/java/com/alien/base/ui/fragment/IFragmentLife.kt:
--------------------------------------------------------------------------------
1 | package com.alien.base.ui.fragment
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import android.support.v4.app.Fragment
6 | import android.view.View
7 |
8 | interface IFragmentLife {
9 |
10 | fun onAttach(fragment: Fragment, context: Context)
11 |
12 | fun onCreate(savedInstanceState: Bundle?)
13 |
14 | fun onCreateView(view: View, savedInstanceState: Bundle?)
15 |
16 | fun onActivityCreate(savedInstanceState: Bundle?)
17 |
18 | fun onStart()
19 |
20 | fun onResume()
21 |
22 | fun onPause()
23 |
24 | fun onStop()
25 |
26 | fun onSaveInstanceState(outState: Bundle?)
27 |
28 | fun onDestroyView()
29 |
30 | fun onDestroy()
31 |
32 | fun onDetach()
33 |
34 | fun isAdded(): Boolean
35 | }
--------------------------------------------------------------------------------
/basemodule/src/main/res/drawable/selector_action_bottom_sheet_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/basemodule/src/main/res/drawable/selector_action_bottom_sheet_middle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/basemodule/src/main/res/drawable/selector_action_bottom_sheet_single.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/basemodule/src/main/res/drawable/selector_action_bottom_sheet_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/basemodule/src/main/res/values/actionsheet_attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/basemodule/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BaseModule
3 |
4 |
--------------------------------------------------------------------------------
/basemodule/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
14 |
28 |
29 |
--------------------------------------------------------------------------------
/basemodule/src/test/java/com/alien/base/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.base;
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() {
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 |
3 | buildscript {
4 | ext.kotlin_version = '1.2.71'
5 | apply from: 'gradle/versions.gradle'
6 | addRepos(repositories)
7 | dependencies {
8 | classpath deps.android_gradle_plugin
9 | classpath deps.kotlin.extensions
10 | classpath deps.greendao.plugin
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | allprojects {
22 | addRepos(repositories)
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
29 | repositories {
30 | google()
31 | }
32 |
33 |
34 | ext{
35 | app_version_code = 100
36 | app_version_name = "1.0.0"
37 | }
38 |
--------------------------------------------------------------------------------
/componentlib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/componentlib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion 28
8 |
9 | defaultConfig {
10 | minSdkVersion 16
11 | targetSdkVersion 28
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | implementation deps.kotlin.stdlib
30 | api deps.arouter.api
31 | }
32 |
--------------------------------------------------------------------------------
/componentlib/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 |
--------------------------------------------------------------------------------
/componentlib/src/androidTest/java/com/android/componentlib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.android.componentlib;
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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.android.componentlib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/componentlib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/componentlib/src/main/java/com/android/componentlib/applicationlike/IApplicationLike.kt:
--------------------------------------------------------------------------------
1 | package com.android.componentlib.applicationlike
2 |
3 | interface IApplicationLike {
4 |
5 | fun onCreate()
6 |
7 | fun onStop()
8 | }
--------------------------------------------------------------------------------
/componentlib/src/main/java/com/android/componentlib/router/Jumper.kt:
--------------------------------------------------------------------------------
1 | package com.android.componentlib.router
2 |
3 | import android.app.Application
4 | import android.content.Context
5 | import com.alibaba.android.arouter.launcher.ARouter
6 |
7 | object Jumper {
8 |
9 | fun check(context: Context, uid: Long): Boolean{
10 | if (uid == 0L){
11 | login(context)
12 | return false
13 | }
14 | return true
15 | }
16 |
17 | fun init(debug: Boolean, application: Application){
18 | if (debug){
19 | ARouter.openLog()
20 | ARouter.openDebug()
21 | }
22 | ARouter.init(application)
23 | }
24 |
25 | fun main(){
26 | ARouter.getInstance().build(RouterPath.MAIN_PATH).navigation()
27 | }
28 |
29 | fun login(context: Context){
30 | ARouter.getInstance().build(RouterPath.PATH_LOGIN).navigation(context)
31 | }
32 |
33 |
34 | }
--------------------------------------------------------------------------------
/componentlib/src/main/java/com/android/componentlib/router/Router.kt:
--------------------------------------------------------------------------------
1 | package com.android.componentlib.router
2 |
3 | import android.text.TextUtils
4 | import com.android.componentlib.applicationlike.IApplicationLike
5 | import java.util.*
6 |
7 | class Router {
8 |
9 | private val services = HashMap()
10 |
11 | companion object {
12 | private val components = HashMap()
13 | private var instance: Router? = null
14 |
15 | fun getInstance(): Router {
16 | if (instance == null) {
17 | synchronized(Router::class.java) {
18 | if (instance == null) {
19 | instance = Router()
20 | }
21 | }
22 | }
23 | return instance!!
24 | }
25 |
26 | fun registerComponent(classname: String?) {
27 | if (TextUtils.isEmpty(classname)) {
28 | return
29 | }
30 | if (components.keys.contains(classname)) {
31 | return
32 | }
33 | try {
34 | val clazz = Class.forName(classname)
35 | val applicationLike = clazz.newInstance() as IApplicationLike
36 | applicationLike.onCreate()
37 | components[classname!!] = applicationLike
38 | } catch (e: Exception) {
39 | e.printStackTrace()
40 | }
41 |
42 | }
43 |
44 | fun unregisterComponent(classname: String?) {
45 | if (TextUtils.isEmpty(classname)) {
46 | return
47 | }
48 | if (components.keys.contains(classname)) {
49 | components[classname]?.onStop()
50 | components.remove(classname)
51 | return
52 | }
53 | try {
54 | val clazz = Class.forName(classname)
55 | val applicationLike = clazz.newInstance() as IApplicationLike
56 | applicationLike.onStop()
57 | components.remove(classname)
58 | } catch (e: Exception) {
59 | e.printStackTrace()
60 | }
61 |
62 | }
63 | }
64 |
65 | @Synchronized
66 | fun addService(tClass: Class?, t: T?) {
67 | if (tClass == null || t == null) {
68 | return
69 | }
70 | services.put(tClass.simpleName, t)
71 | }
72 |
73 | @Synchronized
74 | fun getService(tClass: Class?): T {
75 | return if (tClass == null || !services.containsKey(tClass.simpleName)) {
76 | null
77 | } else services[tClass.simpleName] as T?!!
78 | }
79 |
80 | @Synchronized
81 | fun removeService(tClass: Class?) {
82 | if (tClass == null || !services.containsKey(tClass.simpleName)) {
83 | return
84 | }
85 | services.remove(tClass.simpleName)
86 | }
87 | }
--------------------------------------------------------------------------------
/componentlib/src/main/java/com/android/componentlib/router/RouterPath.kt:
--------------------------------------------------------------------------------
1 | package com.android.componentlib.router
2 |
3 | object RouterPath {
4 |
5 | const val MAIN_PATH = "/app/MainActivity"
6 | const val PATH_LOGIN = "/user/LoginActivity"
7 | }
--------------------------------------------------------------------------------
/componentlib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ComponentLib
3 |
4 |
--------------------------------------------------------------------------------
/componentlib/src/test/java/com/android/componentlib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.android.componentlib;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/componentservice/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/componentservice/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion 28
8 |
9 |
10 |
11 | defaultConfig {
12 | minSdkVersion 16
13 | targetSdkVersion 28
14 | versionCode 1
15 | versionName "1.0"
16 |
17 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
18 |
19 | }
20 |
21 | buildTypes {
22 | release {
23 | minifyEnabled false
24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 |
28 | }
29 |
30 | dependencies {
31 | api project(':basemodule')
32 | }
33 |
--------------------------------------------------------------------------------
/componentservice/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 |
--------------------------------------------------------------------------------
/componentservice/src/androidTest/java/com/android/componentservice/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.android.componentservice;
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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.android.componentservice.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/componentservice/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/componentservice/src/main/java/com/android/componentservice/CoreService.kt:
--------------------------------------------------------------------------------
1 | package com.android.componentservice
2 |
3 | import android.support.v4.app.Fragment
4 |
5 | interface CoreService {
6 |
7 | fun getBusinessFlag(): String
8 |
9 | fun getFragment(): Fragment
10 | }
--------------------------------------------------------------------------------
/componentservice/src/main/java/com/android/componentservice/modulea/BusinessAService.kt:
--------------------------------------------------------------------------------
1 | package com.android.componentservice.modulea
2 |
3 | import android.support.v4.app.Fragment
4 | import com.android.componentservice.CoreService
5 |
6 | interface BusinessAService: CoreService {
7 |
8 | fun getFragmentE(): Fragment
9 |
10 | }
--------------------------------------------------------------------------------
/componentservice/src/main/java/com/android/componentservice/moduleb/BusinessBService.kt:
--------------------------------------------------------------------------------
1 | package com.android.componentservice.moduleb
2 |
3 | import com.android.componentservice.CoreService
4 |
5 | interface BusinessBService: CoreService {
6 |
7 | }
--------------------------------------------------------------------------------
/componentservice/src/main/java/com/android/componentservice/modulec/BusinessCService.kt:
--------------------------------------------------------------------------------
1 | package com.android.componentservice.modulec
2 |
3 | import com.android.componentservice.CoreService
4 |
5 | interface BusinessCService: CoreService {
6 |
7 | }
--------------------------------------------------------------------------------
/componentservice/src/main/java/com/android/componentservice/moduled/BusinessDService.kt:
--------------------------------------------------------------------------------
1 | package com.android.componentservice.moduled
2 |
3 | import com.android.componentservice.CoreService
4 |
5 | interface BusinessDService: CoreService {
6 |
7 | }
--------------------------------------------------------------------------------
/componentservice/src/main/java/com/android/componentservice/modulee/BusinessEService.kt:
--------------------------------------------------------------------------------
1 | package com.android.componentservice.modulee
2 |
3 | import com.android.componentservice.CoreService
4 |
5 | interface BusinessEService: CoreService {
6 |
7 | }
--------------------------------------------------------------------------------
/componentservice/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ComponentService
3 |
4 |
--------------------------------------------------------------------------------
/componentservice/src/test/java/com/android/componentservice/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.android.componentservice;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # Kotlin code style for this project: "official" or "obsolete":
15 | kotlin.code.style=official
16 | isBuildModule=false
17 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/viyski/Pluto/a57dbf961ee5ae4f0e33efa3a34cd8ce1932d214/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/modulea/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/modulea/build.gradle:
--------------------------------------------------------------------------------
1 | if (isBuildModule.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 | apply plugin: 'kotlin-android'
7 | apply plugin: 'kotlin-android-extensions'
8 | apply plugin: 'kotlin-kapt'
9 |
10 | android {
11 | compileSdkVersion build_version.target_sdk
12 |
13 | defaultConfig {
14 | minSdkVersion 16
15 | targetSdkVersion build_version.target_sdk
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20 |
21 | resourcePrefix "modulea_"
22 | if (isBuildModule.toBoolean()) {
23 | multiDexEnabled true
24 | }
25 | }
26 |
27 | buildTypes {
28 | release {
29 | minifyEnabled false
30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
31 | }
32 | debug {
33 | }
34 | }
35 |
36 | sourceSets {
37 | main {
38 | if (isBuildModule.toBoolean()) {
39 | manifest.srcFile 'src/main/debug/AndroidManifest.xml'
40 | } else {
41 | manifest.srcFile 'src/main/release/AndroidManifest.xml'
42 | }
43 | }
44 | }
45 |
46 | }
47 |
48 |
49 | kapt {
50 | generateStubs = true
51 | arguments {
52 | arg("AROUTER_MODULE_NAME", project.getName())
53 | }
54 | }
55 |
56 | dependencies {
57 | implementation fileTree(dir: 'libs', include: ['*.jar'])
58 | kapt deps.dagger.compiler
59 | kapt deps.dagger.android_support_compiler
60 | kapt deps.arouter.compiler
61 |
62 | implementation deps.banner
63 | api project(':componentservice')
64 | }
65 |
--------------------------------------------------------------------------------
/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/alien/modulea/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.alien.modulea.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/modulea/src/main/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/modulea/src/main/java/com/alien/modulea/AAppLike.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulea
2 |
3 | import com.alien.base.di.AppComponent
4 | import com.alien.base.modulekit.AModuleKit
5 | import com.alien.base.modulekit.AppModuleComponentDelegate
6 | import com.alien.base.modulekit.BaseModuleKit
7 | import com.alien.modulea.di.DaggerModuleAAppComponent
8 | import com.alien.modulea.serviceimpl.BusinessAServiceImpl
9 | import com.android.componentlib.applicationlike.IApplicationLike
10 | import com.android.componentlib.router.Router
11 | import com.android.componentservice.modulea.BusinessAService
12 |
13 | class AAppLike: IApplicationLike {
14 |
15 | override fun onCreate() {
16 | Router.getInstance().addService(BusinessAService::class.java, BusinessAServiceImpl())
17 | AModuleKit.getInstance().init(object : AppModuleComponentDelegate {
18 | override fun initAppComponent(): AppComponent {
19 | return DaggerModuleAAppComponent.builder()
20 | .baseAppComponent(BaseModuleKit.getInstance().getComponent())
21 | .build()
22 | }
23 | })
24 | }
25 |
26 | override fun onStop() {
27 |
28 | }
29 | }
--------------------------------------------------------------------------------
/modulea/src/main/java/com/alien/modulea/di/ActivityComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulea.di
2 |
3 | import com.alien.base.di.BaseViewModule
4 | import com.alien.base.di.scope.PerView
5 | import dagger.Component
6 |
7 | @PerView
8 | @Component(dependencies = [(ModuleAAppComponent::class)], modules = [(BaseViewModule::class)])
9 | interface ActivityComponent {
10 |
11 | }
--------------------------------------------------------------------------------
/modulea/src/main/java/com/alien/modulea/di/FragmentComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulea.di
2 |
3 | import com.alien.base.di.BaseViewModule
4 | import com.alien.base.di.scope.PerView
5 | import com.alien.modulea.ui.fragment.FragmentA
6 | import dagger.Component
7 |
8 | @PerView
9 | @Component(dependencies = [(ModuleAAppComponent::class)], modules = [(BaseViewModule::class)])
10 | interface FragmentComponent {
11 |
12 | fun inject(fragment: FragmentA)
13 | }
--------------------------------------------------------------------------------
/modulea/src/main/java/com/alien/modulea/di/ModuleAAppComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulea.di
2 |
3 | import com.alien.base.di.AppComponent
4 | import com.alien.base.di.BaseAppComponent
5 | import com.alien.base.di.scope.AppScope
6 | import com.alien.base.event.RxBus
7 | import dagger.Component
8 |
9 |
10 | @AppScope
11 | @Component(dependencies = [(BaseAppComponent::class)], modules = [(ModuleAAppModule::class)])
12 | interface ModuleAAppComponent : AppComponent{
13 |
14 | fun rxBus(): RxBus
15 |
16 | }
--------------------------------------------------------------------------------
/modulea/src/main/java/com/alien/modulea/di/ModuleAAppModule.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulea.di
2 |
3 | import dagger.Module
4 |
5 |
6 | @Module
7 | class ModuleAAppModule {
8 |
9 |
10 |
11 | }
--------------------------------------------------------------------------------
/modulea/src/main/java/com/alien/modulea/serviceimpl/BusinessAServiceImpl.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulea.serviceimpl
2 |
3 | import android.support.v4.app.Fragment
4 | import com.alien.modulea.ui.fragment.FragmentA
5 | import com.alien.modulea.ui.fragment.FragmentE
6 | import com.android.componentservice.modulea.BusinessAService
7 |
8 | class BusinessAServiceImpl: BusinessAService {
9 |
10 | override fun getBusinessFlag(): String = "com.alien.modulea.service.a"
11 |
12 | override fun getFragment(): Fragment = FragmentA.newInstance()
13 |
14 | override fun getFragmentE(): Fragment = FragmentE.newInstance()
15 | }
--------------------------------------------------------------------------------
/modulea/src/main/java/com/alien/modulea/ui/activity/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulea.ui.activity
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import com.alien.modulea.R
6 |
7 | class MainActivity : AppCompatActivity() {
8 |
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.modulea_activity_main)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/modulea/src/main/java/com/alien/modulea/ui/fragment/BaseInjectFragment.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulea.ui.fragment
2 |
3 | import com.alien.base.modulekit.AModuleKit
4 | import com.alien.base.ui.BaseFragment
5 | import com.alien.modulea.di.DaggerFragmentComponent
6 | import com.alien.modulea.di.FragmentComponent
7 | import com.alien.modulea.di.ModuleAAppComponent
8 |
9 | abstract class BaseInjectFragment: BaseFragment() {
10 |
11 | fun fragmentComponent(): FragmentComponent {
12 | return DaggerFragmentComponent.builder()
13 | .moduleAAppComponent(AModuleKit.getInstance().getComponent() as ModuleAAppComponent?)
14 | .build()
15 | }
16 | }
--------------------------------------------------------------------------------
/modulea/src/main/java/com/alien/modulea/ui/fragment/FragmentA.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulea.ui.fragment
2 |
3 | import com.alien.base.ui.BaseFragment
4 | import com.alien.modulea.R
5 |
6 | class FragmentA: BaseFragment() {
7 |
8 | override fun getLayoutRes(): Int = R.layout.modulea_fragment_a
9 |
10 | override fun setUp() {
11 | }
12 |
13 | companion object {
14 | fun newInstance(): FragmentA{
15 | return FragmentA()
16 | }
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/modulea/src/main/java/com/alien/modulea/ui/fragment/FragmentE.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulea.ui.fragment
2 |
3 | import com.alien.base.ui.BaseFragment
4 | import com.alien.modulea.R
5 |
6 | class FragmentE: BaseFragment() {
7 |
8 | override fun getLayoutRes(): Int = R.layout.modulea_fragment_e
9 |
10 | override fun setUp() {
11 | }
12 |
13 | companion object {
14 | fun newInstance(): FragmentE{
15 | return FragmentE()
16 | }
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/modulea/src/main/release/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/modulea/src/main/res/layout/modulea_activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
--------------------------------------------------------------------------------
/modulea/src/main/res/layout/modulea_fragment_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/modulea/src/main/res/layout/modulea_fragment_e.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/modulea/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ModuleA
3 |
4 |
--------------------------------------------------------------------------------
/modulea/src/test/java/com/alien/modulea/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.modulea;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/moduleb/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/moduleb/build.gradle:
--------------------------------------------------------------------------------
1 | if (isBuildModule.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 | apply plugin: 'kotlin-android'
7 | apply plugin: 'kotlin-android-extensions'
8 | apply plugin: 'kotlin-kapt'
9 |
10 | android {
11 | compileSdkVersion build_version.target_sdk
12 |
13 | defaultConfig {
14 | minSdkVersion 16
15 | targetSdkVersion build_version.target_sdk
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20 |
21 | resourcePrefix "moduleb_"
22 | if (isBuildModule.toBoolean()) {
23 | multiDexEnabled true
24 | }
25 | }
26 |
27 | buildTypes {
28 | release {
29 | minifyEnabled false
30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
31 | }
32 | debug {
33 | }
34 | }
35 |
36 | sourceSets {
37 | main {
38 | if (isBuildModule.toBoolean()) {
39 | manifest.srcFile 'src/main/debug/AndroidManifest.xml'
40 | } else {
41 | manifest.srcFile 'src/main/release/AndroidManifest.xml'
42 | }
43 | }
44 | }
45 |
46 | }
47 |
48 |
49 | kapt {
50 | generateStubs = true
51 | arguments {
52 | arg("AROUTER_MODULE_NAME", project.getName())
53 | }
54 | }
55 |
56 | dependencies {
57 | implementation fileTree(dir: 'libs', include: ['*.jar'])
58 | kapt deps.dagger.compiler
59 | kapt deps.dagger.android_support_compiler
60 | kapt deps.arouter.compiler
61 |
62 | implementation deps.banner
63 | api project(':componentservice')
64 | }
65 |
--------------------------------------------------------------------------------
/moduleb/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 |
--------------------------------------------------------------------------------
/moduleb/src/androidTest/java/com/alien/modulea/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.alien.modulea.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/moduleb/src/main/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/moduleb/src/main/java/com/alien/moduleb/BAppLike.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduleb
2 |
3 | import com.alien.base.di.AppComponent
4 | import com.alien.base.modulekit.AppModuleComponentDelegate
5 | import com.alien.base.modulekit.BModuleKit
6 | import com.alien.base.modulekit.BaseModuleKit
7 | import com.alien.moduleb.di.DaggerModuleBAppComponent
8 | import com.alien.moduleb.serviceimpl.BusinessBServiceImpl
9 | import com.android.componentlib.applicationlike.IApplicationLike
10 | import com.android.componentlib.router.Router
11 | import com.android.componentservice.moduleb.BusinessBService
12 |
13 | class BAppLike: IApplicationLike {
14 |
15 | override fun onCreate() {
16 | Router.getInstance().addService(BusinessBService::class.java, BusinessBServiceImpl())
17 | BModuleKit.getInstance().init(object : AppModuleComponentDelegate {
18 | override fun initAppComponent(): AppComponent {
19 | return DaggerModuleBAppComponent.builder()
20 | .baseAppComponent(BaseModuleKit.getInstance().getComponent())
21 | .build()
22 | }
23 | })
24 | }
25 |
26 | override fun onStop() {
27 |
28 | }
29 | }
--------------------------------------------------------------------------------
/moduleb/src/main/java/com/alien/moduleb/di/ActivityComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduleb.di
2 |
3 | import com.alien.base.di.BaseViewModule
4 | import com.alien.base.di.scope.PerView
5 | import dagger.Component
6 |
7 | @PerView
8 | @Component(dependencies = [(ModuleBAppComponent::class)], modules = [(BaseViewModule::class)])
9 | interface ActivityComponent {
10 |
11 | }
--------------------------------------------------------------------------------
/moduleb/src/main/java/com/alien/moduleb/di/FragmentComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduleb.di
2 |
3 | import com.alien.base.di.BaseViewModule
4 | import com.alien.base.di.scope.PerView
5 | import com.alien.moduleb.ui.fragment.FragmentB
6 | import dagger.Component
7 |
8 | @PerView
9 | @Component(dependencies = [(ModuleBAppComponent::class)], modules = [(BaseViewModule::class)])
10 | interface FragmentComponent {
11 |
12 | fun inject(fragment: FragmentB)
13 | }
--------------------------------------------------------------------------------
/moduleb/src/main/java/com/alien/moduleb/di/ModuleBAppComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduleb.di
2 |
3 | import com.alien.base.di.AppComponent
4 | import com.alien.base.di.BaseAppComponent
5 | import com.alien.base.di.scope.AppScope
6 | import com.alien.base.event.RxBus
7 | import dagger.Component
8 |
9 |
10 | @AppScope
11 | @Component(dependencies = [(BaseAppComponent::class)], modules = [(ModuleBAppModule::class)])
12 | interface ModuleBAppComponent : AppComponent{
13 |
14 | fun rxBus(): RxBus
15 |
16 | }
--------------------------------------------------------------------------------
/moduleb/src/main/java/com/alien/moduleb/di/ModuleBAppModule.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduleb.di
2 |
3 | import dagger.Module
4 |
5 |
6 | @Module
7 | class ModuleBAppModule {
8 |
9 |
10 |
11 | }
--------------------------------------------------------------------------------
/moduleb/src/main/java/com/alien/moduleb/serviceimpl/BusinessBServiceImpl.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduleb.serviceimpl
2 |
3 | import android.support.v4.app.Fragment
4 | import com.alien.moduleb.ui.fragment.FragmentB
5 | import com.android.componentservice.modulea.BusinessAService
6 | import com.android.componentservice.moduleb.BusinessBService
7 |
8 | class BusinessBServiceImpl: BusinessBService {
9 |
10 | override fun getBusinessFlag(): String = "com.alien.moduleb.service.a"
11 |
12 | override fun getFragment(): Fragment = FragmentB.newInstance()
13 | }
--------------------------------------------------------------------------------
/moduleb/src/main/java/com/alien/moduleb/ui/activity/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduleb.ui.activity
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import com.alien.moduleb.R
6 |
7 | class MainActivity : AppCompatActivity() {
8 |
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.moduleb_activity_main)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/moduleb/src/main/java/com/alien/moduleb/ui/fragment/FragmentB.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduleb.ui.fragment
2 |
3 | import com.alien.base.ui.BaseFragment
4 | import com.alien.moduleb.R
5 |
6 | class FragmentB: BaseFragment() {
7 |
8 | override fun getLayoutRes(): Int = R.layout.moduleb_fragment_b
9 |
10 | override fun setUp() {
11 | }
12 |
13 | companion object {
14 | fun newInstance(): FragmentB{
15 | return FragmentB()
16 | }
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/moduleb/src/main/release/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/moduleb/src/main/res/layout/moduleb_activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
--------------------------------------------------------------------------------
/moduleb/src/main/res/layout/moduleb_fragment_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/moduleb/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ModuleA
3 |
4 |
--------------------------------------------------------------------------------
/moduleb/src/test/java/com/alien/modulea/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.modulea;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/modulec/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/modulec/build.gradle:
--------------------------------------------------------------------------------
1 | if (isBuildModule.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 | apply plugin: 'kotlin-android'
7 | apply plugin: 'kotlin-android-extensions'
8 | apply plugin: 'kotlin-kapt'
9 |
10 | android {
11 | compileSdkVersion build_version.target_sdk
12 |
13 | defaultConfig {
14 | minSdkVersion 16
15 | targetSdkVersion build_version.target_sdk
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20 |
21 | resourcePrefix "modulec_"
22 | if (isBuildModule.toBoolean()) {
23 | multiDexEnabled true
24 | }
25 | }
26 |
27 | buildTypes {
28 | release {
29 | minifyEnabled false
30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
31 | }
32 | debug {
33 | }
34 | }
35 |
36 | sourceSets {
37 | main {
38 | if (isBuildModule.toBoolean()) {
39 | manifest.srcFile 'src/main/debug/AndroidManifest.xml'
40 | } else {
41 | manifest.srcFile 'src/main/release/AndroidManifest.xml'
42 | }
43 | }
44 | }
45 |
46 | }
47 |
48 |
49 | kapt {
50 | generateStubs = true
51 | arguments {
52 | arg("AROUTER_MODULE_NAME", project.getName())
53 | }
54 | }
55 |
56 | dependencies {
57 | implementation fileTree(dir: 'libs', include: ['*.jar'])
58 | kapt deps.dagger.compiler
59 | kapt deps.dagger.android_support_compiler
60 | kapt deps.arouter.compiler
61 |
62 | implementation deps.banner
63 | api project(':componentservice')
64 | }
65 |
--------------------------------------------------------------------------------
/modulec/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 |
--------------------------------------------------------------------------------
/modulec/src/androidTest/java/com/alien/modulea/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.alien.modulea.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/modulec/src/main/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/modulec/src/main/java/com/alien/modulec/CAppLike.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulec
2 |
3 | import com.alien.base.di.AppComponent
4 | import com.alien.base.modulekit.AppModuleComponentDelegate
5 | import com.alien.base.modulekit.BModuleKit
6 | import com.alien.base.modulekit.BaseModuleKit
7 | import com.alien.modulec.di.DaggerModuleCAppComponent
8 | import com.alien.modulec.serviceimpl.BusinessCServiceImpl
9 | import com.android.componentlib.applicationlike.IApplicationLike
10 | import com.android.componentlib.router.Router
11 | import com.android.componentservice.modulec.BusinessCService
12 |
13 | class CAppLike: IApplicationLike {
14 |
15 | override fun onCreate() {
16 | Router.getInstance().addService(BusinessCService::class.java, BusinessCServiceImpl())
17 | BModuleKit.getInstance().init(object : AppModuleComponentDelegate {
18 | override fun initAppComponent(): AppComponent {
19 | return DaggerModuleCAppComponent.builder()
20 | .baseAppComponent(BaseModuleKit.getInstance().getComponent())
21 | .build()
22 | }
23 | })
24 | }
25 |
26 | override fun onStop() {
27 |
28 | }
29 | }
--------------------------------------------------------------------------------
/modulec/src/main/java/com/alien/modulec/di/ActivityComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulec.di
2 |
3 | import com.alien.base.di.BaseViewModule
4 | import com.alien.base.di.scope.PerView
5 | import dagger.Component
6 |
7 | @PerView
8 | @Component(dependencies = [(ModuleCAppComponent::class)], modules = [(BaseViewModule::class)])
9 | interface ActivityComponent {
10 |
11 | }
--------------------------------------------------------------------------------
/modulec/src/main/java/com/alien/modulec/di/FragmentComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulec.di
2 |
3 | import com.alien.base.di.BaseViewModule
4 | import com.alien.base.di.scope.PerView
5 | import com.alien.modulec.ui.fragment.FragmentC
6 | import dagger.Component
7 |
8 | @PerView
9 | @Component(dependencies = [(ModuleCAppComponent::class)], modules = [(BaseViewModule::class)])
10 | interface FragmentComponent {
11 |
12 | fun inject(fragment: FragmentC)
13 | }
--------------------------------------------------------------------------------
/modulec/src/main/java/com/alien/modulec/di/ModuleCAppComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulec.di
2 |
3 | import com.alien.base.di.AppComponent
4 | import com.alien.base.di.BaseAppComponent
5 | import com.alien.base.di.scope.AppScope
6 | import com.alien.base.event.RxBus
7 | import dagger.Component
8 |
9 |
10 | @AppScope
11 | @Component(dependencies = [(BaseAppComponent::class)], modules = [(ModuleCAppModule::class)])
12 | interface ModuleCAppComponent : AppComponent{
13 |
14 | fun rxBus(): RxBus
15 |
16 | }
--------------------------------------------------------------------------------
/modulec/src/main/java/com/alien/modulec/di/ModuleCAppModule.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulec.di
2 |
3 | import dagger.Module
4 |
5 |
6 | @Module
7 | class ModuleCAppModule {
8 |
9 |
10 |
11 | }
--------------------------------------------------------------------------------
/modulec/src/main/java/com/alien/modulec/serviceimpl/BusinessCServiceImpl.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulec.serviceimpl
2 |
3 | import android.support.v4.app.Fragment
4 | import com.alien.modulec.ui.fragment.FragmentC
5 | import com.android.componentservice.moduleb.BusinessBService
6 | import com.android.componentservice.modulec.BusinessCService
7 |
8 | class BusinessCServiceImpl: BusinessCService {
9 |
10 | override fun getBusinessFlag(): String = "com.alien.modulec.service.c"
11 |
12 | override fun getFragment(): Fragment = FragmentC.newInstance()
13 | }
--------------------------------------------------------------------------------
/modulec/src/main/java/com/alien/modulec/ui/activity/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulec.ui.activity
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import com.alien.modulec.R
6 |
7 | class MainActivity : AppCompatActivity() {
8 |
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.modulec_activity_main)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/modulec/src/main/java/com/alien/modulec/ui/fragment/FragmentC.kt:
--------------------------------------------------------------------------------
1 | package com.alien.modulec.ui.fragment
2 |
3 | import com.alien.base.ui.BaseFragment
4 | import com.alien.modulec.R
5 |
6 | class FragmentC: BaseFragment() {
7 |
8 | override fun getLayoutRes(): Int = R.layout.modulec_fragment_c
9 |
10 | override fun setUp() {
11 | }
12 |
13 | companion object {
14 | fun newInstance(): FragmentC{
15 | return FragmentC()
16 | }
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/modulec/src/main/release/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/modulec/src/main/res/layout/modulec_activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
--------------------------------------------------------------------------------
/modulec/src/main/res/layout/modulec_fragment_c.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
--------------------------------------------------------------------------------
/modulec/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ModuleA
3 |
4 |
--------------------------------------------------------------------------------
/modulec/src/test/java/com/alien/modulea/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.modulea;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/moduled/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/moduled/build.gradle:
--------------------------------------------------------------------------------
1 | if (isBuildModule.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 | apply plugin: 'kotlin-android'
7 | apply plugin: 'kotlin-android-extensions'
8 | apply plugin: 'kotlin-kapt'
9 |
10 | android {
11 | compileSdkVersion build_version.target_sdk
12 |
13 | defaultConfig {
14 | minSdkVersion 16
15 | targetSdkVersion build_version.target_sdk
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20 |
21 | resourcePrefix "moduled_"
22 | if (isBuildModule.toBoolean()) {
23 | multiDexEnabled true
24 | }
25 | }
26 |
27 | buildTypes {
28 | release {
29 | minifyEnabled false
30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
31 | }
32 | debug {
33 | }
34 | }
35 |
36 | sourceSets {
37 | main {
38 | if (isBuildModule.toBoolean()) {
39 | manifest.srcFile 'src/main/debug/AndroidManifest.xml'
40 | } else {
41 | manifest.srcFile 'src/main/release/AndroidManifest.xml'
42 | }
43 | }
44 | }
45 |
46 | }
47 |
48 |
49 | kapt {
50 | generateStubs = true
51 | arguments {
52 | arg("AROUTER_MODULE_NAME", project.getName())
53 | }
54 | }
55 |
56 | dependencies {
57 | implementation fileTree(dir: 'libs', include: ['*.jar'])
58 | kapt deps.dagger.compiler
59 | kapt deps.dagger.android_support_compiler
60 | kapt deps.arouter.compiler
61 |
62 | implementation deps.banner
63 | api project(':componentservice')
64 | }
65 |
--------------------------------------------------------------------------------
/moduled/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 |
--------------------------------------------------------------------------------
/moduled/src/androidTest/java/com/alien/modulea/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.alien.modulea.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/moduled/src/main/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/moduled/src/main/java/com/alien/moduled/DAppLike.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduled
2 |
3 | import com.alien.base.di.AppComponent
4 | import com.alien.base.modulekit.AppModuleComponentDelegate
5 | import com.alien.base.modulekit.BModuleKit
6 | import com.alien.base.modulekit.BaseModuleKit
7 | import com.alien.moduled.di.DaggerModuleDAppComponent
8 | import com.alien.moduled.serviceimpl.BusinessDServiceImpl
9 | import com.android.componentlib.applicationlike.IApplicationLike
10 | import com.android.componentlib.router.Router
11 | import com.android.componentservice.moduled.BusinessDService
12 |
13 | class DAppLike: IApplicationLike {
14 |
15 | override fun onCreate() {
16 | Router.getInstance().addService(BusinessDService::class.java, BusinessDServiceImpl())
17 | BModuleKit.getInstance().init(object : AppModuleComponentDelegate {
18 | override fun initAppComponent(): AppComponent {
19 | return DaggerModuleDAppComponent.builder()
20 | .baseAppComponent(BaseModuleKit.getInstance().getComponent())
21 | .build()
22 | }
23 | })
24 | }
25 |
26 | override fun onStop() {
27 |
28 | }
29 | }
--------------------------------------------------------------------------------
/moduled/src/main/java/com/alien/moduled/di/ActivityComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduled.di
2 |
3 | import com.alien.base.di.BaseViewModule
4 | import com.alien.base.di.scope.PerView
5 | import dagger.Component
6 |
7 | @PerView
8 | @Component(dependencies = [(ModuleDAppComponent::class)], modules = [(BaseViewModule::class)])
9 | interface ActivityComponent {
10 |
11 | }
--------------------------------------------------------------------------------
/moduled/src/main/java/com/alien/moduled/di/FragmentComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduled.di
2 |
3 | import com.alien.base.di.BaseViewModule
4 | import com.alien.base.di.scope.PerView
5 | import com.alien.moduled.ui.fragment.FragmentD
6 | import dagger.Component
7 |
8 | @PerView
9 | @Component(dependencies = [(ModuleDAppComponent::class)], modules = [(BaseViewModule::class)])
10 | interface FragmentComponent {
11 |
12 | fun inject(fragment: FragmentD)
13 | }
--------------------------------------------------------------------------------
/moduled/src/main/java/com/alien/moduled/di/ModuleDAppComponent.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduled.di
2 |
3 | import com.alien.base.di.AppComponent
4 | import com.alien.base.di.BaseAppComponent
5 | import com.alien.base.di.scope.AppScope
6 | import com.alien.base.event.RxBus
7 | import dagger.Component
8 |
9 |
10 | @AppScope
11 | @Component(dependencies = [(BaseAppComponent::class)], modules = [(ModuleDAppModule::class)])
12 | interface ModuleDAppComponent : AppComponent{
13 |
14 | fun rxBus(): RxBus
15 |
16 | }
--------------------------------------------------------------------------------
/moduled/src/main/java/com/alien/moduled/di/ModuleDAppModule.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduled.di
2 |
3 | import dagger.Module
4 |
5 |
6 | @Module
7 | class ModuleDAppModule {
8 |
9 |
10 |
11 | }
--------------------------------------------------------------------------------
/moduled/src/main/java/com/alien/moduled/serviceimpl/BusinessDServiceImpl.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduled.serviceimpl
2 |
3 | import android.support.v4.app.Fragment
4 | import com.alien.moduled.ui.fragment.FragmentD
5 | import com.android.componentservice.moduled.BusinessDService
6 |
7 | class BusinessDServiceImpl: BusinessDService {
8 |
9 | override fun getBusinessFlag(): String = "com.alien.moduled.service.d"
10 |
11 | override fun getFragment(): Fragment = FragmentD.newInstance()
12 | }
--------------------------------------------------------------------------------
/moduled/src/main/java/com/alien/moduled/ui/activity/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduled.ui.activity
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import com.alien.moduled.R
6 |
7 | class MainActivity : AppCompatActivity() {
8 |
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.moduled_activity_main)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/moduled/src/main/java/com/alien/moduled/ui/fragment/FragmentD.kt:
--------------------------------------------------------------------------------
1 | package com.alien.moduled.ui.fragment
2 |
3 | import com.alien.base.ui.BaseFragment
4 | import com.alien.moduled.R
5 |
6 | class FragmentD: BaseFragment() {
7 |
8 | override fun getLayoutRes(): Int = R.layout.moduled_fragment_d
9 |
10 | override fun setUp() {
11 | }
12 |
13 | companion object {
14 | fun newInstance(): FragmentD{
15 | return FragmentD()
16 | }
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/moduled/src/main/release/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/moduled/src/main/res/layout/moduled_activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
--------------------------------------------------------------------------------
/moduled/src/main/res/layout/moduled_fragment_d.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
--------------------------------------------------------------------------------
/moduled/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ModuleA
3 |
4 |
--------------------------------------------------------------------------------
/moduled/src/test/java/com/alien/modulea/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.alien.modulea;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':modulea', ':moduleb',':modulec',':moduled', ':componentlib', ':baselib', ':basemodule', ':componentservice'
2 |
--------------------------------------------------------------------------------