├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── ThirdLibrarys └── README.md ├── app ├── .gitignore ├── AndroidManifest.xml ├── build.gradle └── proguard-rules.pro ├── art ├── build_1_min.png.jpg ├── model.png └── rule_aar_arouter.png.jpg ├── build.gradle ├── common_component_build.gradle ├── component ├── CommonRes │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── me │ │ │ └── jessyan │ │ │ └── armscomponent │ │ │ └── commonres │ │ │ ├── dialog │ │ │ └── ProgresDialog.java │ │ │ └── utils │ │ │ └── Anim.java │ │ └── res │ │ └── layout │ │ ├── public_dialog_porgress.xml │ │ └── public_include_title.xml ├── CommonResource │ ├── .gitignore │ ├── build.gradle │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── assets │ │ └── animation-lottie-splash.json │ │ └── res │ │ ├── anim │ │ ├── public_dialog_enter.xml │ │ ├── public_dialog_exit.xml │ │ ├── public_translate_center_to_left.xml │ │ ├── public_translate_center_to_right.xml │ │ ├── public_translate_left_to_center.xml │ │ └── public_translate_right_to_center.xml │ │ ├── drawable │ │ ├── layer_splash_bg.xml │ │ ├── public_ic_arrow_back_white_24dp.png │ │ ├── public_loading.png │ │ ├── public_loading_ani.xml │ │ ├── public_shape_gray_corner_4dp.xml │ │ └── splash_logo.png │ │ ├── mipmap │ │ ├── arms_component_logo.png │ │ ├── gank_ic_logo.webp │ │ ├── gold_ic_logo.webp │ │ └── zhihu_ic_logo.webp │ │ ├── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ └── public_network_security_config.xml ├── CommonSDK │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── me │ │ └── jessyan │ │ └── armscomponent │ │ └── commonsdk │ │ ├── core │ │ ├── ActivityLifecycleCallbacksImpl.java │ │ ├── Constants.java │ │ ├── EventBusHub.java │ │ ├── FragmentLifecycleCallbacksImpl.java │ │ ├── GlobalConfiguration.java │ │ ├── GlobalHttpHandlerImpl.java │ │ ├── ResponseErrorListenerImpl.java │ │ └── RouterHub.java │ │ ├── http │ │ ├── Api.java │ │ └── SSLSocketClient.java │ │ ├── imgaEngine │ │ ├── Strategy │ │ │ └── CommonGlideImageLoaderStrategy.java │ │ └── config │ │ │ └── CommonImageConfigImpl.java │ │ └── utils │ │ ├── HtmlUtil.java │ │ ├── RxUtil.java │ │ └── Utils.java └── CommonService │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── me │ └── jessyan │ └── armscomponent │ └── commonservice │ ├── gank │ ├── bean │ │ └── GankInfo.java │ └── service │ │ └── GankInfoService.java │ ├── gold │ ├── bean │ │ └── GoldInfo.java │ └── service │ │ └── GoldInfoService.java │ └── zhihu │ ├── bean │ └── ZhihuInfo.java │ └── service │ └── ZhihuInfoService.java ├── config.gradle ├── fake ├── fake-app │ ├── .gitignore │ ├── AndroidManifest.xml │ └── build.gradle ├── fake-template │ ├── .gitignore │ ├── AndroidManifest.xml │ └── build.gradle └── fake-zhihu │ ├── .gitignore │ ├── AndroidManifest.xml │ └── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── module ├── module_app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── me │ │ │ └── jessyan │ │ │ └── armscomponent │ │ │ └── app │ │ │ ├── app │ │ │ ├── AppLifecyclesImpl.java │ │ │ ├── GlobalConfiguration.java │ │ │ └── RouterInterceptor.java │ │ │ └── mvp │ │ │ └── ui │ │ │ └── activity │ │ │ ├── MainActivity.java │ │ │ └── SplashActivity.java │ │ └── res │ │ └── layout │ │ ├── app_activity_main.xml │ │ └── app_activity_splash.xml ├── module_gank │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── me │ │ │ └── jessyan │ │ │ └── armscomponent │ │ │ └── app │ │ │ └── ApplicationTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── me │ │ │ │ └── jessyan │ │ │ │ └── armscomponent │ │ │ │ └── gank │ │ │ │ ├── app │ │ │ │ ├── AppLifecyclesImpl.java │ │ │ │ ├── GankConstants.java │ │ │ │ └── GlobalConfiguration.java │ │ │ │ ├── component │ │ │ │ └── service │ │ │ │ │ └── GankInfoServiceImpl.java │ │ │ │ ├── di │ │ │ │ ├── component │ │ │ │ │ └── GankHomeComponent.java │ │ │ │ └── module │ │ │ │ │ └── GankHomeModule.java │ │ │ │ └── mvp │ │ │ │ ├── contract │ │ │ │ └── GankHomeContract.java │ │ │ │ ├── model │ │ │ │ ├── GankModel.java │ │ │ │ ├── api │ │ │ │ │ ├── Api.java │ │ │ │ │ └── service │ │ │ │ │ │ └── GankService.java │ │ │ │ └── entity │ │ │ │ │ ├── GankBaseResponse.java │ │ │ │ │ └── GankItemBean.java │ │ │ │ ├── presenter │ │ │ │ └── GankHomePresenter.java │ │ │ │ └── ui │ │ │ │ ├── activity │ │ │ │ └── GankHomeActivity.java │ │ │ │ ├── adapter │ │ │ │ └── GankHomeAdapter.java │ │ │ │ └── holder │ │ │ │ └── GankHomeItemHolder.java │ │ └── res │ │ │ └── layout │ │ │ ├── gank_activity_home.xml │ │ │ └── gank_recycle_list.xml │ │ └── test │ │ └── java │ │ └── me │ │ └── jessyan │ │ └── armscomponent │ │ └── app │ │ └── ExampleUnitTest.java ├── module_gold │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── me │ │ │ └── jessyan │ │ │ └── armscomponent │ │ │ └── app │ │ │ └── ApplicationTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── me │ │ │ │ └── jessyan │ │ │ │ └── armscomponent │ │ │ │ └── gold │ │ │ │ ├── app │ │ │ │ ├── AppLifecyclesImpl.java │ │ │ │ ├── GlobalConfiguration.java │ │ │ │ └── GoldConstants.java │ │ │ │ ├── component │ │ │ │ └── service │ │ │ │ │ └── GoldInfoServiceImpl.java │ │ │ │ ├── di │ │ │ │ ├── component │ │ │ │ │ └── GoldHomeComponent.java │ │ │ │ └── module │ │ │ │ │ └── GoldHomeModule.java │ │ │ │ └── mvp │ │ │ │ ├── contract │ │ │ │ └── GoldHomeContract.java │ │ │ │ ├── model │ │ │ │ ├── GoldModel.java │ │ │ │ ├── api │ │ │ │ │ ├── Api.java │ │ │ │ │ └── service │ │ │ │ │ │ └── GoldService.java │ │ │ │ └── entity │ │ │ │ │ ├── GoldBaseResponse.java │ │ │ │ │ └── GoldListBean.java │ │ │ │ ├── presenter │ │ │ │ └── GoldHomePresenter.java │ │ │ │ └── ui │ │ │ │ ├── activity │ │ │ │ ├── DetailActivity.java │ │ │ │ └── GoldHomeActivity.java │ │ │ │ ├── adapter │ │ │ │ └── GoldHomeAdapter.java │ │ │ │ └── holder │ │ │ │ └── GoldHomeItemHolder.java │ │ └── res │ │ │ └── layout │ │ │ ├── gold_activity_detail.xml │ │ │ ├── gold_activity_home.xml │ │ │ └── gold_recycle_list.xml │ │ └── test │ │ └── java │ │ └── me │ │ └── jessyan │ │ └── armscomponent │ │ └── app │ │ └── ExampleUnitTest.java └── module_zhihu │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ ├── androidTest │ └── java │ │ └── me │ │ └── jessyan │ │ └── armscomponent │ │ └── app │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── me │ │ │ └── jessyan │ │ │ └── armscomponent │ │ │ └── zhihu │ │ │ ├── app │ │ │ ├── AppLifecyclesImpl.java │ │ │ ├── GlobalConfiguration.java │ │ │ └── ZhihuConstants.java │ │ │ ├── component │ │ │ └── service │ │ │ │ └── ZhihuInfoServiceImpl.java │ │ │ ├── di │ │ │ ├── component │ │ │ │ ├── DetailComponent.java │ │ │ │ └── ZhihuHomeComponent.java │ │ │ └── module │ │ │ │ ├── DetailModule.java │ │ │ │ └── ZhihuHomeModule.java │ │ │ └── mvp │ │ │ ├── contract │ │ │ ├── DetailContract.java │ │ │ └── ZhihuHomeContract.java │ │ │ ├── model │ │ │ ├── ZhihuModel.java │ │ │ ├── api │ │ │ │ ├── Api.java │ │ │ │ └── service │ │ │ │ │ └── ZhihuService.java │ │ │ └── entity │ │ │ │ ├── DailyListBean.java │ │ │ │ └── ZhihuDetailBean.java │ │ │ ├── presenter │ │ │ ├── DetailPresenter.java │ │ │ └── ZhihuHomePresenter.java │ │ │ └── ui │ │ │ ├── activity │ │ │ ├── DetailActivity.java │ │ │ └── ZhihuHomeActivity.java │ │ │ ├── adapter │ │ │ └── ZhihuHomeAdapter.java │ │ │ └── holder │ │ │ └── ZhihuHomeItemHolder.java │ └── res │ │ └── layout │ │ ├── zhihu_activity_detail.xml │ │ ├── zhihu_activity_home.xml │ │ └── zhihu_recycle_list.xml │ └── test │ └── java │ └── me │ └── jessyan │ └── armscomponent │ └── app │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea 38 | 39 | # Keystore files 40 | *.jks 41 | 42 | # MacOS 43 | .DS_Store 44 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | before_install: 4 | - yes | sdkmanager "platforms;android-28" 5 | 6 | env: 7 | global: 8 | - ANDROID_API_LEVEL=28 9 | - ANDROID_BUILD_TOOLS_VERSION=28.0.3 10 | - TRAVIS_SECURE_ENV_VARS=true 11 | 12 | android: 13 | components: 14 | # The BuildTools version used by your project 15 | - tools 16 | - platform-tools 17 | - build-tools-$ANDROID_BUILD_TOOLS_VERSION 18 | - extra-android-m2repository 19 | - extra-google-android-support 20 | 21 | # The SDK version used to compile your project 22 | - android-$ANDROID_API_LEVEL 23 | licenses: 24 | - '.+' 25 | 26 | script: 27 | - ./gradlew clean 28 | - ./gradlew assembleDebug -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/CHANGELOG.md -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request targeting the branch `master`. 3 | 4 | When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. 5 | 6 | ## License 7 | 8 | By contributing your code, you agree to license your contribution under the terms of the APLv2: https://github.com/JessYanCoding/ArmsComponent/blob/master/LICENSE 9 | 10 | All files are released with the Apache 2.0 license. 11 | 12 | If you are adding a new file it should have a header like this: 13 | 14 | ``` 15 | /* 16 | * Copyright 2018 JessYan 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the "License"); 19 | * you may not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * http://www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an "AS IS" BASIS, 26 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | ``` -------------------------------------------------------------------------------- /ThirdLibrarys/README.md: -------------------------------------------------------------------------------- 1 | **ThirdLibrarys** 文件夹里用来放一些第三方库的 **Module** (某些三方库没有提供远程依赖,或者有些时候需要修改某些三方库源码,这时就需要直接依赖 **Module** 里的源码),然后在 **settings.gradle** 中加入 **':ThirdLibrarys:[三方库 Module 名]' (在实际项目中记得去除中括号 '[]')**, 即可在 **build.gradle** 中依赖 -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 37 | 40 | 43 | 44 | 48 | 51 | 54 | 57 | 60 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/jess/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # 混淆规则在 arms moudule下的proguard-rules.pro中,混淆前先参阅https://github.com/JessYanCoding/MVPArms/wiki#1.5 -------------------------------------------------------------------------------- /art/build_1_min.png.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/art/build_1_min.png.jpg -------------------------------------------------------------------------------- /art/model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/art/model.png -------------------------------------------------------------------------------- /art/rule_aar_arouter.png.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/art/rule_aar_arouter.png.jpg -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | apply from: "config.gradle" 3 | buildscript { 4 | repositories { 5 | google() 6 | jcenter() 7 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" } 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.2.1' 11 | classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT' 12 | //如果 ButterKnife 插件和其他插件发生冲突而报错请试试 v8.4.0 版本的 ButterKnife 插件, 注意 v8.4.0 最高只能支持 com.android.tools.build:gradle:3.0.1 13 | // classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0' 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | maven { url "https://jitpack.io" } 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /common_component_build.gradle: -------------------------------------------------------------------------------- 1 | //def componentName = project.getName().startsWith("module_") ? project.getName().substring(0, "module_".length()) : 2 | apply plugin: 'com.android.library' 3 | apply plugin: 'com.jakewharton.butterknife' 4 | 5 | android { 6 | compileSdkVersion rootProject.ext.android["compileSdkVersion"] 7 | buildToolsVersion rootProject.ext.android["buildToolsVersion"] 8 | useLibrary 'org.apache.http.legacy' 9 | 10 | compileOptions { 11 | targetCompatibility JavaVersion.VERSION_1_8 12 | sourceCompatibility JavaVersion.VERSION_1_8 13 | } 14 | 15 | defaultConfig { 16 | minSdkVersion rootProject.ext.android["minSdkVersion"] 17 | targetSdkVersion rootProject.ext.android["targetSdkVersion"] 18 | versionCode rootProject.ext.android["versionCode"] 19 | versionName rootProject.ext.android["versionName"] 20 | testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"] 21 | javaCompileOptions { 22 | annotationProcessorOptions { 23 | arguments = [AROUTER_MODULE_NAME: project.getName()] 24 | includeCompileClasspath true 25 | } 26 | } 27 | } 28 | buildTypes { 29 | debug { 30 | buildConfigField "boolean", "LOG_DEBUG", "true" 31 | buildConfigField "boolean", "USE_CANARY", "true" 32 | minifyEnabled false 33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 34 | } 35 | 36 | release { 37 | buildConfigField "boolean", "LOG_DEBUG", "false" 38 | buildConfigField "boolean", "USE_CANARY", "false" 39 | minifyEnabled true 40 | zipAlignEnabled true 41 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 42 | } 43 | } 44 | 45 | lintOptions { 46 | disable 'InvalidPackage' 47 | disable "ResourceType" 48 | abortOnError false 49 | } 50 | 51 | sourceSets { 52 | main { 53 | jniLibs.srcDirs = ['libs'] 54 | manifest.srcFile 'src/main/AndroidManifest.xml' 55 | } 56 | } 57 | } 58 | 59 | dependencies { 60 | compileOnly rootProject.ext.dependencies["butterknife-compiler"] 61 | compileOnly rootProject.ext.dependencies["dagger2-compiler"] 62 | compileOnly rootProject.ext.dependencies["arouter-compiler"] 63 | compileOnly rootProject.ext.dependencies["canary-debug"] 64 | compileOnly rootProject.ext.dependencies["canary-release"] 65 | } 66 | -------------------------------------------------------------------------------- /component/CommonRes/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /component/CommonRes/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android["compileSdkVersion"] 5 | buildToolsVersion rootProject.ext.android["buildToolsVersion"] 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.android["minSdkVersion"] 9 | targetSdkVersion rootProject.ext.android["targetSdkVersion"] 10 | versionCode rootProject.ext.android["versionCode"] 11 | versionName rootProject.ext.android["versionName"] 12 | 13 | testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"] 14 | } 15 | 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | 23 | resourcePrefix "public_" //给 Module 内的资源名增加前缀, 避免资源名冲突 24 | } 25 | 26 | dependencies { 27 | api fileTree(dir: 'libs', include: ['*.jar']) 28 | api project(":component:CommonSDK") //因为 CommonRes 依赖了 CommonSDK, 所以如果业务模块需要公共 UI 组件就依赖 CommonRes, 如果不需要就只依赖 CommonSDK 29 | api project(":component:CommonResource") 30 | 31 | api rootProject.ext.dependencies["autosize"] 32 | api(rootProject.ext.dependencies["cardview-v7"]) { 33 | exclude module: 'support-annotations' 34 | } 35 | api rootProject.ext.dependencies["paginate"] 36 | api rootProject.ext.dependencies["lottie"] 37 | } 38 | -------------------------------------------------------------------------------- /component/CommonRes/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 | -------------------------------------------------------------------------------- /component/CommonRes/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /component/CommonRes/src/main/java/me/jessyan/armscomponent/commonres/dialog/ProgresDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonres.dialog; 17 | 18 | import android.app.Dialog; 19 | import android.content.Context; 20 | import android.support.annotation.NonNull; 21 | 22 | import me.jessyan.armscomponent.commonres.R; 23 | 24 | /** 25 | * ================================================ 26 | * Created by JessYan on 16/04/2018 17:01 27 | * Contact me 28 | * Follow me 29 | * ================================================ 30 | */ 31 | public class ProgresDialog extends Dialog { 32 | public ProgresDialog(@NonNull Context context) { 33 | super(context, R.style.public_dialog_progress); 34 | setContentView(R.layout.public_dialog_porgress); 35 | setCanceledOnTouchOutside(false); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /component/CommonRes/src/main/java/me/jessyan/armscomponent/commonres/utils/Anim.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonres.utils; 17 | 18 | import android.app.Activity; 19 | import android.view.View; 20 | import android.widget.ImageView; 21 | 22 | import me.jessyan.armscomponent.commonres.R; 23 | 24 | 25 | /** 26 | * ================================================ 27 | * 动画工具类 28 | *

29 | * Created by JessYan on 27/04/2017 21:40 30 | * Contact me 31 | * Follow me 32 | * ================================================ 33 | */ 34 | public class Anim { 35 | public static void exit(Activity obj) { 36 | obj.overridePendingTransition(R.anim.public_translate_left_to_center, R.anim.public_translate_center_to_right); 37 | } 38 | 39 | public static void in(Activity obj) { 40 | obj.overridePendingTransition(R.anim.public_translate_right_to_center, R.anim.public_translate_center_to_left); 41 | } 42 | 43 | public static void cleanAnim(ImageView animView) { 44 | if (animView == null) 45 | return; 46 | animView.setImageResource(0); 47 | animView.clearAnimation(); 48 | animView.setVisibility(View.GONE); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /component/CommonRes/src/main/res/layout/public_dialog_porgress.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | 21 | 22 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /component/CommonRes/src/main/res/layout/public_include_title.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 19 | 20 | 27 | 28 | 29 | 30 | 38 | 39 | -------------------------------------------------------------------------------- /component/CommonResource/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /component/CommonResource/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android["compileSdkVersion"] 5 | buildToolsVersion rootProject.ext.android["buildToolsVersion"] 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.android["minSdkVersion"] 9 | targetSdkVersion rootProject.ext.android["targetSdkVersion"] 10 | versionCode rootProject.ext.android["versionCode"] 11 | versionName rootProject.ext.android["versionName"] 12 | 13 | testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"] 14 | } 15 | } -------------------------------------------------------------------------------- /component/CommonResource/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/anim/public_dialog_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/anim/public_dialog_exit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/anim/public_translate_center_to_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/anim/public_translate_center_to_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/anim/public_translate_left_to_center.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/anim/public_translate_right_to_center.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/drawable/layer_splash_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/drawable/public_ic_arrow_back_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/component/CommonResource/src/main/res/drawable/public_ic_arrow_back_white_24dp.png -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/drawable/public_loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/component/CommonResource/src/main/res/drawable/public_loading.png -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/drawable/public_loading_ani.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/drawable/public_shape_gray_corner_4dp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/drawable/splash_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/component/CommonResource/src/main/res/drawable/splash_logo.png -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/mipmap/arms_component_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/component/CommonResource/src/main/res/mipmap/arms_component_logo.png -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/mipmap/gank_ic_logo.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/component/CommonResource/src/main/res/mipmap/gank_ic_logo.webp -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/mipmap/gold_ic_logo.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/component/CommonResource/src/main/res/mipmap/gold_ic_logo.webp -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/mipmap/zhihu_ic_logo.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/component/CommonResource/src/main/res/mipmap/zhihu_ic_logo.webp -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #241e20 4 | #f8f8e9 5 | 6 | #37889F 7 | #37889F 8 | #FF4081 9 | #FFFFFF 10 | #000000 11 | #00000000 12 | #4A4A4A 13 | #443636 14 | #53A8F4 15 | #53A7F3 16 | #E5E5E5 17 | #F6F6F6 18 | #FFFFFF 19 | #959292 20 | #CDD3D7 21 | #B8B6B6 22 | #E7E7E7 23 | #D8D8D8 24 | #06CB7E 25 | #6C6C6C 26 | #666F80 27 | #0F79FD 28 | #FFB8B6B6 29 | #F55122 30 | #F55123 31 | #FFF55122 32 | #FF6C6C6C 33 | #FF959292 34 | #FF9C15 35 | #FF4A4A4A 36 | #FFF59C22 37 | #F59C22 38 | #F59C23 39 | #FFFFFFFF 40 | #FF53A8F4 41 | #E9EDEE 42 | #FFE9EDEE 43 | #FF06CB7E 44 | #FFF6F6F6 45 | #979797 46 | #FED652 47 | #148CF9 48 | 49 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 64dp 6 | 7 | 8 | 9 | 11sp 10 | 12sp 11 | 13sp 12 | 14sp 13 | 16sp 14 | 18sp 15 | 20sp 16 | 24sp 17 | 30sp 18 | 32sp 19 | 36sp 20 | 48sp 21 | 22 | 23 | 24 | 24dp 25 | 50dp 26 | 54dp 27 | 67dp 28 | 80dp 29 | 174dp 30 | 280dp 31 | 32 | 33 | 34 | 24dp 35 | 67dp 36 | 80dp 37 | 38 | 39 | 40 | 20dp 41 | 4dp 42 | 28dp 43 | 4dp 44 | 20dp 45 | 46 | 47 | 48 | 3dp 49 | 8dp 50 | 4dp 51 | 5dp 52 | 6dp 53 | 10dp 54 | 4dp 55 | 5dp 56 | 10dp 57 | 4dp 58 | 5dp 59 | 60 | 61 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ArmsComponent 3 | app 4 | 加载中 5 | 知乎日报 6 | 干货集中营 7 | 稀土掘金 8 | 9 | app 10 | ModuleGold 11 | ModuleZhihu 12 | ModuleGank 13 | 14 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 16 | 17 | 23 | 24 | 30 | 31 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /component/CommonResource/src/main/res/xml/public_network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /component/CommonSDK/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /component/CommonSDK/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android["compileSdkVersion"] 5 | buildToolsVersion rootProject.ext.android["buildToolsVersion"] 6 | 7 | compileOptions { 8 | targetCompatibility JavaVersion.VERSION_1_8 9 | sourceCompatibility JavaVersion.VERSION_1_8 10 | } 11 | 12 | defaultConfig { 13 | minSdkVersion rootProject.ext.android["minSdkVersion"] 14 | targetSdkVersion rootProject.ext.android["targetSdkVersion"] 15 | versionCode rootProject.ext.android["versionCode"] 16 | versionName rootProject.ext.android["versionName"] 17 | 18 | testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"] 19 | } 20 | 21 | buildTypes { 22 | debug { 23 | buildConfigField "boolean", "LOG_DEBUG", "true" 24 | buildConfigField "boolean", "USE_CANARY", "true" 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 27 | } 28 | release { 29 | buildConfigField "boolean", "LOG_DEBUG", "false" 30 | buildConfigField "boolean", "USE_CANARY", "false" 31 | minifyEnabled false 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 33 | } 34 | } 35 | } 36 | 37 | dependencies { 38 | api fileTree(dir: 'libs', include: ['*.jar']) 39 | api 'me.jessyan:arms:2.5.0' 40 | api 'me.jessyan:arms-imageloader-glide:2.5.0' 41 | 42 | //tools 43 | api rootProject.ext.dependencies["androideventbus"] 44 | api(rootProject.ext.dependencies["arouter"]) { 45 | exclude module: 'support-v4' 46 | exclude module: 'support-annotations' 47 | } 48 | api rootProject.ext.dependencies["retrofit-url-manager"] 49 | } 50 | -------------------------------------------------------------------------------- /component/CommonSDK/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 | -------------------------------------------------------------------------------- /component/CommonSDK/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /component/CommonSDK/src/main/java/me/jessyan/armscomponent/commonsdk/core/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonsdk.core; 17 | 18 | /** 19 | * ================================================ 20 | * CommonSDK 的 Constants 可以定义公用的常量, 比如关于业务的常量或者正则表达式, 每个组件的 Constants 可以定义组件自己的私有常量 21 | *

22 | * Created by JessYan on 30/03/2018 17:32 23 | * Contact me 24 | * Follow me 25 | * ================================================ 26 | */ 27 | public interface Constants { 28 | //电话号码正则 29 | String PHONE_REGULAR = "^1[3-9]\\d{9}$"; 30 | } 31 | -------------------------------------------------------------------------------- /component/CommonSDK/src/main/java/me/jessyan/armscomponent/commonsdk/core/EventBusHub.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonsdk.core; 17 | 18 | /** 19 | * ================================================ 20 | * AndroidEventBus 作为本方案提供的另一种跨组件通信方式 (第一种是接口下沉, 在 app 的 MainActivity 中已展示, 通过 ARouter 实现) 21 | * AndroidEventBus 比 greenrobot 的 EventBus 多了一个 Tag, 在组件化中更容定位和管理事件 22 | *

23 | * EventBusHub 用来定义 AndroidEventBus 的 Tag 字符串, 以组件名作为 Tag 前缀, 对每个组件的事件进行分组 24 | * Tag 的命名规则为 组件名 + 页面名 + 动作 25 | * 比如需要使用 AndroidEventBus 通知订单组件的订单详情页进行刷新, 可以将这个刷新方法的 Tag 命名为 "order/OrderDetailActivity/refresh" 26 | *

27 | * Tips: 基础库中的 EventBusHub 仅用来存放需要跨组件通信的事件的 Tag, 如果某个事件只想在组件内使用 AndroidEventBus 进行通信 28 | * 那就让组件自行管理这个事件的 Tag 29 | * 30 | * @see EventBusHub wiki 官方文档 31 | * Created by JessYan on 30/03/2018 17:46 32 | * Contact me 33 | * Follow me 34 | * ================================================ 35 | */ 36 | public interface EventBusHub { 37 | /** 38 | * 组名 39 | */ 40 | String APP = "app";//宿主 App 组件 41 | String ZHIHU = "zhihu";//知乎组件 42 | String GANK = "gank";//干货集中营组件 43 | String GOLD = "gold";//稀土掘金组件 44 | } 45 | -------------------------------------------------------------------------------- /component/CommonSDK/src/main/java/me/jessyan/armscomponent/commonsdk/core/GlobalHttpHandlerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonsdk.core; 17 | 18 | import android.content.Context; 19 | 20 | import com.jess.arms.http.GlobalHttpHandler; 21 | 22 | import okhttp3.Interceptor; 23 | import okhttp3.Request; 24 | import okhttp3.Response; 25 | 26 | /** 27 | * ================================================ 28 | * 展示 {@link GlobalHttpHandler} 的用法 29 | *

30 | * Created by JessYan on 04/09/2017 17:06 31 | * Contact me 32 | * Follow me 33 | * ================================================ 34 | */ 35 | public class GlobalHttpHandlerImpl implements GlobalHttpHandler { 36 | private Context context; 37 | 38 | public GlobalHttpHandlerImpl(Context context) { 39 | this.context = context; 40 | } 41 | 42 | /** 43 | * 这里可以先客户端一步拿到每一次 Http 请求的结果, 可以先解析成 Json, 再做一些操作, 如检测到 token 过期后 44 | * 重新请求 token, 并重新执行请求 45 | * 46 | * @param httpResult 服务器返回的结果 (已被框架自动转换为字符串) 47 | * @param chain {@link okhttp3.Interceptor.Chain} 48 | * @param response {@link Response} 49 | * @return 50 | */ 51 | @Override 52 | public Response onHttpResultResponse(String httpResult, Interceptor.Chain chain, Response response) { 53 | /* 这里如果发现 token 过期, 可以先请求最新的 token, 然后在拿新的 token 放入 Request 里去重新请求 54 | 注意在这个回调之前已经调用过 proceed(), 所以这里必须自己去建立网络请求, 如使用 Okhttp 使用新的 Request 去请求 55 | create a new request and modify it accordingly using the new token 56 | Request newRequest = chain.request().newBuilder().header("token", newToken) 57 | .build(); 58 | 59 | retry the request 60 | 61 | response.body().close(); 62 | 如果使用 Okhttp 将新的请求, 请求成功后, 再将 Okhttp 返回的 Response return 出去即可 63 | 如果不需要返回新的结果, 则直接把参数 response 返回出去即可 */ 64 | return response; 65 | } 66 | 67 | /** 68 | * 这里可以在请求服务器之前拿到 {@link Request}, 做一些操作比如给 {@link Request} 统一添加 token 或者 header 以及参数加密等操作 69 | * 70 | * @param chain {@link okhttp3.Interceptor.Chain} 71 | * @param request {@link Request} 72 | * @return 73 | */ 74 | @Override 75 | public Request onHttpRequestBefore(Interceptor.Chain chain, Request request) { 76 | /* 如果需要再请求服务器之前做一些操作, 则重新返回一个做过操作的的 Request 如增加 Header, 不做操作则直接返回参数 request 77 | return chain.request().newBuilder().header("token", tokenId) 78 | .build(); */ 79 | return request; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /component/CommonSDK/src/main/java/me/jessyan/armscomponent/commonsdk/core/ResponseErrorListenerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonsdk.core; 17 | 18 | import android.content.Context; 19 | import android.net.ParseException; 20 | 21 | import com.google.gson.JsonIOException; 22 | import com.google.gson.JsonParseException; 23 | import com.jess.arms.utils.ArmsUtils; 24 | 25 | import org.json.JSONException; 26 | 27 | import java.net.SocketTimeoutException; 28 | import java.net.UnknownHostException; 29 | 30 | import me.jessyan.rxerrorhandler.handler.listener.ResponseErrorListener; 31 | import retrofit2.HttpException; 32 | import timber.log.Timber; 33 | 34 | /** 35 | * ================================================ 36 | * 展示 {@link ResponseErrorListener} 的用法 37 | *

38 | * Created by JessYan on 04/09/2017 17:18 39 | * Contact me 40 | * Follow me 41 | * ================================================ 42 | */ 43 | public class ResponseErrorListenerImpl implements ResponseErrorListener { 44 | 45 | @Override 46 | public void handleResponseError(Context context, Throwable t) { 47 | Timber.tag("Catch-Error").w(t.getMessage()); 48 | //这里不光只能打印错误, 还可以根据不同的错误做出不同的逻辑处理 49 | //这里只是对几个常用错误进行简单的处理, 展示这个类的用法, 在实际开发中请您自行对更多错误进行更严谨的处理 50 | String msg = "未知错误"; 51 | if (t instanceof UnknownHostException) { 52 | msg = "网络不可用"; 53 | } else if (t instanceof SocketTimeoutException) { 54 | msg = "请求网络超时"; 55 | } else if (t instanceof HttpException) { 56 | HttpException httpException = (HttpException) t; 57 | msg = convertStatusCode(httpException); 58 | } else if (t instanceof JsonParseException || t instanceof ParseException || t instanceof JSONException || t instanceof JsonIOException) { 59 | msg = "数据解析错误"; 60 | } 61 | ArmsUtils.snackbarText(msg); 62 | } 63 | 64 | private String convertStatusCode(HttpException httpException) { 65 | String msg; 66 | if (httpException.code() == 500) { 67 | msg = "服务器发生错误"; 68 | } else if (httpException.code() == 404) { 69 | msg = "请求地址不存在"; 70 | } else if (httpException.code() == 403) { 71 | msg = "请求被服务器拒绝"; 72 | } else if (httpException.code() == 401) { 73 | msg = "未授权"; 74 | } else if (httpException.code() == 307) { 75 | msg = "请求被重定向到其他页面"; 76 | } else { 77 | msg = httpException.message(); 78 | } 79 | return msg; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /component/CommonSDK/src/main/java/me/jessyan/armscomponent/commonsdk/core/RouterHub.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonsdk.core; 17 | 18 | /** 19 | * ================================================ 20 | * RouterHub 用来定义路由器的路由地址, 以组件名作为前缀, 对每个组件的路由地址进行分组, 可以统一查看和管理所有分组的路由地址 21 | *

22 | * RouterHub 存在于基础库, 可以被看作是所有组件都需要遵守的通讯协议, 里面不仅可以放路由地址常量, 还可以放跨组件传递数据时命名的各种 Key 值 23 | * 再配以适当注释, 任何组件开发人员不需要事先沟通只要依赖了这个协议, 就知道了各自该怎样协同工作, 既提高了效率又降低了出错风险, 约定的东西自然要比口头上说强 24 | *

25 | * 如果您觉得把每个路由地址都写在基础库的 RouterHub 中, 太麻烦了, 也可以在每个组件内部建立一个私有 RouterHub, 将不需要跨组件的 26 | * 路由地址放入私有 RouterHub 中管理, 只将需要跨组件的路由地址放入基础库的公有 RouterHub 中管理, 如果您不需要集中管理所有路由地址的话 27 | * 这也是比较推荐的一种方式 28 | *

29 | * 路由地址的命名规则为 组件名 + 页面名, 如订单组件的订单详情页的路由地址可以命名为 "/order/OrderDetailActivity" 30 | *

31 | * ARouter 将路由地址中第一个 '/' 后面的字符称为 Group, 比如上面的示例路由地址中 order 就是 Group, 以 order 开头的地址都被分配该 Group 下 32 | * 切记不同的组件中不能出现名称一样的 Group, 否则会发生该 Group 下的部分路由地址找不到的情况!!! 33 | * 所以每个组件使用自己的组件名作为 Group 是比较好的选择, 毕竟组件不会重名 34 | * 35 | * @see RouterHub wiki 官方文档 36 | * Created by JessYan on 30/03/2018 18:07 37 | * Contact me 38 | * Follow me 39 | * ================================================ 40 | */ 41 | public interface RouterHub { 42 | /** 43 | * 组名 44 | */ 45 | String APP = "/app";//宿主 App 组件 46 | String ZHIHU = "/zhihu";//知乎组件 47 | String GANK = "/gank";//干货集中营组件 48 | String GOLD = "/gold";//稀土掘金组件 49 | 50 | /** 51 | * 服务组件, 用于给每个组件暴露特有的服务 52 | */ 53 | String SERVICE = "/service"; 54 | 55 | 56 | /** 57 | * 宿主 App 分组 58 | */ 59 | String APP_SPLASHACTIVITY = APP + "/SplashActivity"; 60 | String APP_MAINACTIVITY = APP + "/MainActivity"; 61 | 62 | 63 | /** 64 | * 知乎分组 65 | */ 66 | String ZHIHU_SERVICE_ZHIHUINFOSERVICE = ZHIHU + SERVICE + "/ZhihuInfoService"; 67 | 68 | String ZHIHU_HOMEACTIVITY = ZHIHU + "/HomeActivity"; 69 | String ZHIHU_DETAILACTIVITY = ZHIHU + "/DetailActivity"; 70 | 71 | /** 72 | * 干货集中营分组 73 | */ 74 | String GANK_SERVICE_GANKINFOSERVICE = GANK + SERVICE + "/GankInfoService"; 75 | 76 | String GANK_HOMEACTIVITY = GANK + "/HomeActivity"; 77 | 78 | /** 79 | * 稀土掘金分组 80 | */ 81 | String GOLD_SERVICE_GOLDINFOSERVICE = GOLD + SERVICE + "/GoldInfoService"; 82 | 83 | String GOLD_HOMEACTIVITY = GOLD + "/HomeActivity"; 84 | String GOLD_DETAILACTIVITY = GOLD + "/DetailActivity"; 85 | } 86 | -------------------------------------------------------------------------------- /component/CommonSDK/src/main/java/me/jessyan/armscomponent/commonsdk/http/Api.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonsdk.http; 17 | 18 | /** 19 | * ================================================ 20 | * CommonSDK 的 Api 可以定义公用的关于 API 的相关常量, 比如说请求地址, 错误码等, 每个组件的 Api 可以定义组件自己的私有常量 21 | * 22 | * Created by JessYan on 30/03/2018 17:16 23 | * Contact me 24 | * Follow me 25 | * ================================================ 26 | */ 27 | public interface Api { 28 | String APP_DOMAIN = "https://api.github.com"; 29 | 30 | String REQUEST_SUCCESS = "200"; 31 | 32 | // 错误码 33 | String ERROR_USER_INCORRECT = "1001"; 34 | String ERROR_PHONE_EXIST = "1019"; 35 | String VALIDATION_OVERTIME = "1020"; 36 | String NOT_PERMISSIONS = "403"; 37 | String API_EXCPTION = "500"; 38 | String REQUEST_PARAM_INCORRECT = "1000"; 39 | String VADATION_INCORRECT = "1002"; 40 | String FIRST_STOP_AFTER_DELETE = "1003"; 41 | String UPLOADING_FILE_OVERSIZE = "1004"; 42 | String EDIT_COMMO_LEVEL = "1005"; 43 | String COMMO_CLASS_RE = "1006"; 44 | String COMMO_TRADEMARK_RE = "1007"; 45 | String LOGISTICS_TEMPLATE_RE = "1008"; 46 | String COMMO_ATTRIBUTE_RE = "1009"; 47 | String USER_NOT_REGISTER = "1010"; 48 | String USER_ALREADY_ADD = "1011"; 49 | String COMMO_CLASS_DELETE = "1012"; 50 | String COMMO_TRANDMARK_DELETE = "1013"; 51 | String COMMO_STORE_OFF = "1014"; 52 | String USER_FORBIDDEN = "1015"; 53 | String ONLY_FIVE_OPERATION = "1024"; 54 | String NAME_ONE_MODIFICATION = "1017"; 55 | String NAME_EXIST = "1018"; 56 | String FIVE_ERR_PWDD = "1016"; 57 | String PWD_NOT_LIKE = "1053"; 58 | String BINDPHONELIKE = "1025"; 59 | String MODIFICOUNTTHREE = "1026"; 60 | String MODIFIPHONEOVERTHREE = "1027"; 61 | String NOTLOGININ = "1052"; 62 | String PASSOWRDINCOREECT = "1055"; 63 | String NOTMATCHIMGBANKCARD = "1041"; 64 | String IDCARDEXIT = "1038"; 65 | String STORENAMEEXIT = "1028"; 66 | String COMPANYNAMEEXIT = "1030"; 67 | String CODEEXIT = "1029"; 68 | String BANKREPETION = "1074"; 69 | String REPETITION = "1032"; 70 | String SERIVENULL ="1044"; 71 | String LIMITMESSAGE = "1082"; 72 | String NO_DEAL = "1081"; 73 | } 74 | -------------------------------------------------------------------------------- /component/CommonSDK/src/main/java/me/jessyan/armscomponent/commonsdk/http/SSLSocketClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonsdk.http; 17 | 18 | import java.security.SecureRandom; 19 | import java.security.cert.CertificateException; 20 | import java.security.cert.X509Certificate; 21 | 22 | import javax.net.ssl.HostnameVerifier; 23 | import javax.net.ssl.SSLContext; 24 | import javax.net.ssl.SSLSession; 25 | import javax.net.ssl.TrustManager; 26 | import javax.net.ssl.X509TrustManager; 27 | 28 | /** 29 | * ================================================ 30 | * Created by JessYan on 30/03/2018 17:16 31 | * Contact me 32 | * Follow me 33 | * ================================================ 34 | */ 35 | public class SSLSocketClient { 36 | 37 | //获取这个SSLSocketFactory 38 | public static javax.net.ssl.SSLSocketFactory getSSLSocketFactory() { 39 | try { 40 | SSLContext sslContext = SSLContext.getInstance("SSL"); 41 | sslContext.init(null, getTrustManagers(), new SecureRandom()); 42 | return sslContext.getSocketFactory(); 43 | } catch (Exception e) { 44 | throw new RuntimeException(e); 45 | } 46 | } 47 | 48 | //获取TrustManager 49 | private static TrustManager[] getTrustManagers() { 50 | TrustManager[] trustAllCerts = new TrustManager[]{getTrustManager()}; 51 | return trustAllCerts; 52 | } 53 | 54 | //获取HostnameVerifier 55 | public static HostnameVerifier getHostnameVerifier() { 56 | HostnameVerifier hostnameVerifier = new HostnameVerifier() { 57 | @Override 58 | public boolean verify(String s, SSLSession sslSession) { 59 | return true; 60 | } 61 | }; 62 | return hostnameVerifier; 63 | } 64 | 65 | public static X509TrustManager getTrustManager(){ 66 | return new MyTrustManager(); 67 | } 68 | 69 | private static final class MyTrustManager implements X509TrustManager { 70 | 71 | @Override 72 | public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { 73 | 74 | } 75 | 76 | @Override 77 | public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { 78 | 79 | } 80 | 81 | @Override 82 | public X509Certificate[] getAcceptedIssuers() { 83 | return new X509Certificate[0]; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /component/CommonSDK/src/main/java/me/jessyan/armscomponent/commonsdk/utils/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonsdk.utils; 17 | 18 | import android.app.Activity; 19 | import android.content.Context; 20 | 21 | import com.alibaba.android.arouter.launcher.ARouter; 22 | 23 | /** 24 | * ================================================ 25 | * Created by JessYan on 30/03/2018 17:16 26 | * Contact me 27 | * Follow me 28 | * ================================================ 29 | */ 30 | public class Utils { 31 | private Utils() { 32 | throw new IllegalStateException("you can't instantiate me!"); 33 | } 34 | 35 | /** 36 | * 使用 {@link ARouter} 根据 {@code path} 跳转到对应的页面, 这个方法因为没有使用 {@link Activity}跳转 37 | * 所以 {@link ARouter} 会自动给 {@link android.content.Intent} 加上 Intent.FLAG_ACTIVITY_NEW_TASK 38 | * 如果不想自动加上这个 Flag 请使用 {@link ARouter#getInstance()#navigation(Context, String)} 并传入 {@link Activity} 39 | * 40 | * @param path {@code path} 41 | */ 42 | public static void navigation(String path) { 43 | ARouter.getInstance().build(path).navigation(); 44 | } 45 | 46 | /** 47 | * 使用 {@link ARouter} 根据 {@code path} 跳转到对应的页面, 如果参数 {@code context} 传入的不是 {@link Activity} 48 | * {@link ARouter} 就会自动给 {@link android.content.Intent} 加上 Intent.FLAG_ACTIVITY_NEW_TASK 49 | * 如果不想自动加上这个 Flag 请使用 {@link Activity} 作为 {@code context} 传入 50 | * 51 | * @param context 52 | * @param path 53 | */ 54 | public static void navigation(Context context, String path) { 55 | ARouter.getInstance().build(path).navigation(context); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /component/CommonService/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /component/CommonService/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android["compileSdkVersion"] 5 | buildToolsVersion rootProject.ext.android["buildToolsVersion"] 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.android["minSdkVersion"] 9 | targetSdkVersion rootProject.ext.android["targetSdkVersion"] 10 | versionCode rootProject.ext.android["versionCode"] 11 | versionName rootProject.ext.android["versionName"] 12 | 13 | testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"] 14 | } 15 | 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | 23 | } 24 | 25 | dependencies { 26 | compileOnly rootProject.ext.dependencies["arouter"] 27 | compileOnly rootProject.ext.dependencies["appcompat-v7"] 28 | } 29 | -------------------------------------------------------------------------------- /component/CommonService/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 | -------------------------------------------------------------------------------- /component/CommonService/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /component/CommonService/src/main/java/me/jessyan/armscomponent/commonservice/gank/bean/GankInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonservice.gank.bean; 17 | 18 | /** 19 | * ================================================ 20 | * Created by JessYan on 2018/4/27 14:11 21 | * Contact me 22 | * Follow me 23 | * ================================================ 24 | */ 25 | public class GankInfo { 26 | private String name; 27 | 28 | public GankInfo(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /component/CommonService/src/main/java/me/jessyan/armscomponent/commonservice/gank/service/GankInfoService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonservice.gank.service; 17 | 18 | import com.alibaba.android.arouter.facade.template.IProvider; 19 | 20 | import me.jessyan.armscomponent.commonservice.gank.bean.GankInfo; 21 | 22 | /** 23 | * ================================================ 24 | * 向外提供服务的接口, 在此接口中声明一些具有特定功能的方法提供给外部, 即可让一个组件与其他组件或宿主进行交互 25 | * 26 | * @see CommonService wiki 官方文档 27 | * Created by JessYan on 2018/4/27 14:16 28 | * Contact me 29 | * Follow me 30 | * ================================================ 31 | */ 32 | public interface GankInfoService extends IProvider { 33 | GankInfo getInfo(); 34 | } 35 | -------------------------------------------------------------------------------- /component/CommonService/src/main/java/me/jessyan/armscomponent/commonservice/gold/bean/GoldInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonservice.gold.bean; 17 | 18 | /** 19 | * ================================================ 20 | * Created by JessYan on 2018/4/27 14:11 21 | * Contact me 22 | * Follow me 23 | * ================================================ 24 | */ 25 | public class GoldInfo { 26 | private String name; 27 | 28 | public GoldInfo(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /component/CommonService/src/main/java/me/jessyan/armscomponent/commonservice/gold/service/GoldInfoService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonservice.gold.service; 17 | 18 | import com.alibaba.android.arouter.facade.template.IProvider; 19 | 20 | import me.jessyan.armscomponent.commonservice.gold.bean.GoldInfo; 21 | 22 | /** 23 | * ================================================ 24 | * 向外提供服务的接口, 在此接口中声明一些具有特定功能的方法提供给外部, 即可让一个组件与其他组件或宿主进行交互 25 | * 26 | * @see CommonService wiki 官方文档 27 | * Created by JessYan on 2018/4/27 14:16 28 | * Contact me 29 | * Follow me 30 | * ================================================ 31 | */ 32 | public interface GoldInfoService extends IProvider { 33 | GoldInfo getInfo(); 34 | } 35 | -------------------------------------------------------------------------------- /component/CommonService/src/main/java/me/jessyan/armscomponent/commonservice/zhihu/bean/ZhihuInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonservice.zhihu.bean; 17 | 18 | /** 19 | * ================================================ 20 | * Created by JessYan on 2018/4/27 14:11 21 | * Contact me 22 | * Follow me 23 | * ================================================ 24 | */ 25 | public class ZhihuInfo { 26 | private String name; 27 | 28 | public ZhihuInfo(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /component/CommonService/src/main/java/me/jessyan/armscomponent/commonservice/zhihu/service/ZhihuInfoService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.commonservice.zhihu.service; 17 | 18 | import com.alibaba.android.arouter.facade.template.IProvider; 19 | 20 | import me.jessyan.armscomponent.commonservice.zhihu.bean.ZhihuInfo; 21 | 22 | /** 23 | * ================================================ 24 | * 向外提供服务的接口, 在此接口中声明一些具有特定功能的方法提供给外部, 即可让一个组件与其他组件或宿主进行交互 25 | * 26 | * @see CommonService wiki 官方文档 27 | * Created by JessYan on 2018/4/27 14:16 28 | * Contact me 29 | * Follow me 30 | * ================================================ 31 | */ 32 | public interface ZhihuInfoService extends IProvider { 33 | ZhihuInfo getInfo(); 34 | } 35 | -------------------------------------------------------------------------------- /fake/fake-app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /fake/fake-app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 41 | 42 | 45 | 48 | 49 | 50 | 51 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /fake/fake-app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android["compileSdkVersion"] 5 | buildToolsVersion rootProject.ext.android["buildToolsVersion"] 6 | defaultConfig { 7 | minSdkVersion rootProject.ext.android["minSdkVersion"] 8 | targetSdkVersion rootProject.ext.android["targetSdkVersion"] 9 | versionCode rootProject.ext.android["versionCode"] 10 | versionName rootProject.ext.android["versionName"] 11 | testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"] 12 | javaCompileOptions { 13 | annotationProcessorOptions { 14 | arguments = [AROUTER_MODULE_NAME: project.getName()] 15 | } 16 | } 17 | } 18 | buildTypes { 19 | debug { 20 | buildConfigField "boolean", "LOG_DEBUG", "true" 21 | buildConfigField "boolean", "USE_CANARY", "true" 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | 26 | release { 27 | buildConfigField "boolean", "LOG_DEBUG", "false" 28 | buildConfigField "boolean", "USE_CANARY", "false" 29 | minifyEnabled true 30 | shrinkResources true 31 | zipAlignEnabled true 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 33 | } 34 | } 35 | useLibrary 'org.apache.http.legacy' 36 | compileOptions { 37 | targetCompatibility JavaVersion.VERSION_1_8 38 | sourceCompatibility JavaVersion.VERSION_1_8 39 | } 40 | dexOptions { 41 | //预编译 42 | preDexLibraries true 43 | //支持大工程 44 | jumboMode = true 45 | //线程数 46 | threadCount = 16 47 | //dex内存,公式:dex内存 + 1G < Gradle内存 48 | javaMaxHeapSize "4g" 49 | additionalParameters = [ 50 | '--multi-dex',//多分包 51 | '--set-max-idx-number=60000'//每个包内方法数上限 52 | ] 53 | } 54 | lintOptions { 55 | checkReleaseBuilds false 56 | disable 'InvalidPackage' 57 | disable "ResourceType" 58 | // Or, if you prefer, you can continue to check for errors in release builds, 59 | // but continue the build even when errors are found: 60 | abortOnError false 61 | } 62 | sourceSets { 63 | main { 64 | manifest.srcFile './AndroidManifest.xml' 65 | } 66 | } 67 | } 68 | 69 | dependencies { 70 | //TODO 4. 修改要调试的组件 71 | runtimeOnly project(':module:module_app') 72 | runtimeOnly project(':module:module_zhihu') 73 | 74 | implementation project(":component:CommonRes")//因为 CommonRes 依赖了 CommonSDK, 所以如果业务模块需要公共 UI 组件就依赖 CommonRes, 如果不需要就只依赖 CommonSDK 75 | implementation project(":component:CommonService") 76 | 77 | //test 78 | testImplementation rootProject.ext.dependencies["junit"] 79 | debugImplementation rootProject.ext.dependencies["canary-debug"] 80 | releaseImplementation rootProject.ext.dependencies["canary-release"] 81 | testImplementation rootProject.ext.dependencies["canary-release"] 82 | } 83 | -------------------------------------------------------------------------------- /fake/fake-template/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /fake/fake-template/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 41 | 42 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /fake/fake-template/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android["compileSdkVersion"] 5 | buildToolsVersion rootProject.ext.android["buildToolsVersion"] 6 | defaultConfig { 7 | minSdkVersion rootProject.ext.android["minSdkVersion"] 8 | targetSdkVersion rootProject.ext.android["targetSdkVersion"] 9 | versionCode rootProject.ext.android["versionCode"] 10 | versionName rootProject.ext.android["versionName"] 11 | testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"] 12 | javaCompileOptions { 13 | annotationProcessorOptions { 14 | arguments = [AROUTER_MODULE_NAME: project.getName()] 15 | } 16 | } 17 | } 18 | buildTypes { 19 | debug { 20 | buildConfigField "boolean", "LOG_DEBUG", "true" 21 | buildConfigField "boolean", "USE_CANARY", "true" 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | 26 | release { 27 | buildConfigField "boolean", "LOG_DEBUG", "false" 28 | buildConfigField "boolean", "USE_CANARY", "false" 29 | minifyEnabled true 30 | shrinkResources true 31 | zipAlignEnabled true 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 33 | } 34 | } 35 | useLibrary 'org.apache.http.legacy' 36 | compileOptions { 37 | targetCompatibility JavaVersion.VERSION_1_8 38 | sourceCompatibility JavaVersion.VERSION_1_8 39 | } 40 | dexOptions { 41 | //预编译 42 | preDexLibraries true 43 | //支持大工程 44 | jumboMode = true 45 | //线程数 46 | threadCount = 16 47 | //dex内存,公式:dex内存 + 1G < Gradle内存 48 | javaMaxHeapSize "4g" 49 | additionalParameters = [ 50 | '--multi-dex',//多分包 51 | '--set-max-idx-number=60000'//每个包内方法数上限 52 | ] 53 | } 54 | lintOptions { 55 | checkReleaseBuilds false 56 | disable 'InvalidPackage' 57 | disable "ResourceType" 58 | // Or, if you prefer, you can continue to check for errors in release builds, 59 | // but continue the build even when errors are found: 60 | abortOnError false 61 | } 62 | sourceSets { 63 | main { 64 | manifest.srcFile './AndroidManifest.xml' 65 | } 66 | } 67 | } 68 | 69 | dependencies { 70 | //TODO 4. 修改要调试的组件 71 | runtimeOnly project(':module:module_zhihu') 72 | 73 | implementation project(":component:CommonRes")//因为 CommonRes 依赖了 CommonSDK, 所以如果业务模块需要公共 UI 组件就依赖 CommonRes, 如果不需要就只依赖 CommonSDK 74 | implementation project(":component:CommonService") 75 | 76 | //test 77 | testImplementation rootProject.ext.dependencies["junit"] 78 | debugImplementation rootProject.ext.dependencies["canary-debug"] 79 | releaseImplementation rootProject.ext.dependencies["canary-release"] 80 | testImplementation rootProject.ext.dependencies["canary-release"] 81 | } 82 | -------------------------------------------------------------------------------- /fake/fake-zhihu/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /fake/fake-zhihu/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 38 | 41 | 42 | 46 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /fake/fake-zhihu/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android["compileSdkVersion"] 5 | buildToolsVersion rootProject.ext.android["buildToolsVersion"] 6 | defaultConfig { 7 | minSdkVersion rootProject.ext.android["minSdkVersion"] 8 | targetSdkVersion rootProject.ext.android["targetSdkVersion"] 9 | versionCode rootProject.ext.android["versionCode"] 10 | versionName rootProject.ext.android["versionName"] 11 | testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"] 12 | javaCompileOptions { 13 | annotationProcessorOptions { 14 | arguments = [AROUTER_MODULE_NAME: project.getName()] 15 | } 16 | } 17 | } 18 | buildTypes { 19 | debug { 20 | buildConfigField "boolean", "LOG_DEBUG", "true" 21 | buildConfigField "boolean", "USE_CANARY", "true" 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | 26 | release { 27 | buildConfigField "boolean", "LOG_DEBUG", "false" 28 | buildConfigField "boolean", "USE_CANARY", "false" 29 | minifyEnabled true 30 | shrinkResources true 31 | zipAlignEnabled true 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 33 | } 34 | } 35 | useLibrary 'org.apache.http.legacy' 36 | compileOptions { 37 | targetCompatibility JavaVersion.VERSION_1_8 38 | sourceCompatibility JavaVersion.VERSION_1_8 39 | } 40 | dexOptions { 41 | //预编译 42 | preDexLibraries true 43 | //支持大工程 44 | jumboMode = true 45 | //线程数 46 | threadCount = 16 47 | //dex内存,公式:dex内存 + 1G < Gradle内存 48 | javaMaxHeapSize "4g" 49 | additionalParameters = [ 50 | '--multi-dex',//多分包 51 | '--set-max-idx-number=60000'//每个包内方法数上限 52 | ] 53 | } 54 | lintOptions { 55 | checkReleaseBuilds false 56 | disable 'InvalidPackage' 57 | disable "ResourceType" 58 | // Or, if you prefer, you can continue to check for errors in release builds, 59 | // but continue the build even when errors are found: 60 | abortOnError false 61 | } 62 | sourceSets { 63 | main { 64 | manifest.srcFile './AndroidManifest.xml' 65 | } 66 | } 67 | } 68 | 69 | dependencies { 70 | runtimeOnly project(':module:module_zhihu') 71 | 72 | implementation project(":component:CommonRes")//因为 CommonRes 依赖了 CommonSDK, 所以如果业务模块需要公共 UI 组件就依赖 CommonRes, 如果不需要就只依赖 CommonSDK 73 | implementation project(":component:CommonService") 74 | implementation project(":component:CommonResource") 75 | 76 | //test 77 | testImplementation rootProject.ext.dependencies["junit"] 78 | debugImplementation rootProject.ext.dependencies["canary-debug"] 79 | releaseImplementation rootProject.ext.dependencies["canary-release"] 80 | testImplementation rootProject.ext.dependencies["canary-release"] 81 | } 82 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Thu May 25 20:59:18 CST 2017 16 | org.gradle.jvmargs=-Xmx2048m 17 | android.enableBuildCache=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXueyuanStdio/lifecycle-component/b6233fc38af61370d67273be1b165a5c84cb9c5f/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Sep 26 10:55:24 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /module/module_app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /module/module_app/build.gradle: -------------------------------------------------------------------------------- 1 | apply from:"../../common_component_build.gradle" 2 | 3 | android { 4 | resourcePrefix "app_" //给 Module 内的资源名增加前缀, 避免资源名冲突 5 | } 6 | 7 | dependencies { 8 | implementation fileTree(include: ['*.jar'], dir: 'libs') 9 | implementation project(":component:CommonRes")//因为 CommonRes 依赖了 CommonSDK, 所以如果业务模块需要公共 UI 组件就依赖 CommonRes, 如果不需要就只依赖 CommonSDK 10 | implementation project(":component:CommonService") 11 | implementation project(":component:CommonResource") 12 | } 13 | -------------------------------------------------------------------------------- /module/module_app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/jess/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # 混淆规则在 arms moudule下的proguard-rules.pro中,混淆前先参阅https://github.com/JessYanCoding/MVPArms/wiki#1.5 -------------------------------------------------------------------------------- /module/module_app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 26 | 27 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /module/module_app/src/main/java/me/jessyan/armscomponent/app/app/AppLifecyclesImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.app.app; 17 | 18 | import android.app.Application; 19 | import android.content.Context; 20 | import android.support.annotation.NonNull; 21 | 22 | import com.jess.arms.base.delegate.AppLifecycles; 23 | import com.jess.arms.utils.ArmsUtils; 24 | import com.squareup.leakcanary.LeakCanary; 25 | import com.squareup.leakcanary.RefWatcher; 26 | 27 | import me.jessyan.armscomponent.app.BuildConfig; 28 | 29 | /** 30 | * ================================================ 31 | * 展示 {@link AppLifecycles} 的用法 32 | *

33 | * Created by JessYan on 04/09/2017 17:12 34 | * Contact me 35 | * Follow me 36 | * ================================================ 37 | */ 38 | public class AppLifecyclesImpl implements AppLifecycles { 39 | 40 | @Override 41 | public void attachBaseContext(@NonNull Context base) { 42 | // MultiDex.install(base); //这里比 onCreate 先执行,常用于 MultiDex 初始化,插件化框架的初始化 43 | } 44 | 45 | @Override 46 | public void onCreate(@NonNull Application application) { 47 | if (LeakCanary.isInAnalyzerProcess(application)) { 48 | // This process is dedicated to LeakCanary for heap analysis. 49 | // You should not init your app in this process. 50 | return; 51 | } 52 | //leakCanary内存泄露检查 53 | ArmsUtils.obtainAppComponentFromContext(application).extras().put(RefWatcher.class.getName(), BuildConfig.USE_CANARY ? LeakCanary.install(application) : RefWatcher.DISABLED); 54 | } 55 | 56 | @Override 57 | public void onTerminate(@NonNull Application application) { 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /module/module_app/src/main/java/me/jessyan/armscomponent/app/app/GlobalConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.app.app; 17 | 18 | import android.app.Application; 19 | import android.content.Context; 20 | import android.support.v4.app.Fragment; 21 | import android.support.v4.app.FragmentManager; 22 | 23 | import com.jess.arms.base.delegate.AppLifecycles; 24 | import com.jess.arms.di.module.GlobalConfigModule; 25 | import com.jess.arms.integration.ConfigModule; 26 | import com.jess.arms.utils.ArmsUtils; 27 | import com.squareup.leakcanary.RefWatcher; 28 | 29 | import java.util.List; 30 | 31 | /** 32 | * ================================================ 33 | * 组件的全局配置信息在此配置, 需要将此实现类声明到 AndroidManifest 中 34 | * CommonSDK 中已有 {@link me.jessyan.armscomponent.commonsdk.core.GlobalConfiguration} 配置有组件可公用的配置信息 35 | * 这里用来配置一些组件自身私有的配置信息 36 | * 37 | * @see com.jess.arms.base.delegate.AppDelegate 38 | * @see com.jess.arms.integration.ManifestParser 39 | * Created by JessYan on 12/04/2017 17:25 40 | * Contact me 41 | * Follow me 42 | * ================================================ 43 | */ 44 | public final class GlobalConfiguration implements ConfigModule { 45 | 46 | @Override 47 | public void applyOptions(Context context, GlobalConfigModule.Builder builder) { 48 | 49 | } 50 | 51 | @Override 52 | public void injectAppLifecycle(Context context, List lifecycles) { 53 | // AppLifecycles 的所有方法都会在基类 Application 的对应的生命周期中被调用,所以在对应的方法中可以扩展一些自己需要的逻辑 54 | // 可以根据不同的逻辑添加多个实现类 55 | lifecycles.add(new AppLifecyclesImpl()); 56 | } 57 | 58 | @Override 59 | public void injectActivityLifecycle(Context context, List lifecycles) { 60 | 61 | } 62 | 63 | @Override 64 | public void injectFragmentLifecycle(Context context, List lifecycles) { 65 | lifecycles.add(new FragmentManager.FragmentLifecycleCallbacks() { 66 | @Override 67 | public void onFragmentDestroyed(FragmentManager fm, Fragment f) { 68 | ((RefWatcher) ArmsUtils 69 | .obtainAppComponentFromContext(f.getActivity()) 70 | .extras() 71 | .get(RefWatcher.class.getName())) 72 | .watch(f); 73 | } 74 | }); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /module/module_app/src/main/java/me/jessyan/armscomponent/app/app/RouterInterceptor.java: -------------------------------------------------------------------------------- 1 | package me.jessyan.armscomponent.app.app; 2 | 3 | import android.content.Context; 4 | 5 | import com.alibaba.android.arouter.facade.Postcard; 6 | import com.alibaba.android.arouter.facade.annotation.Interceptor; 7 | import com.alibaba.android.arouter.facade.callback.InterceptorCallback; 8 | import com.alibaba.android.arouter.facade.template.IInterceptor; 9 | import com.alibaba.android.arouter.launcher.ARouter; 10 | 11 | /** 12 | * ================================================ 13 | * 声明 {@link ARouter} 拦截器, 可以根据需求自定义拦截逻辑, 比如用户没有登录就拦截其他页面 14 | *

15 | * Created by JessYan on 08/08/2017 15:54 16 | * Contact with jess.yan.effort@gmail.com 17 | * Follow me on https://github.com/JessYanCoding 18 | * ================================================ 19 | */ 20 | @Interceptor(priority = 8, name = "RouterInterceptor") 21 | public class RouterInterceptor implements IInterceptor { 22 | private Context mContext; 23 | 24 | @Override 25 | public void process(Postcard postcard, InterceptorCallback callback) { 26 | callback.onContinue(postcard); 27 | //这里示例的意思是, 如果用户没有登录就只能进入登录注册等划分到 ACCOUNT 分组的页面, 用户进入其他页面将全部被拦截 28 | // if (postcard.getGroup().equals(RouterHub.ACCOUNT.split("/")[1]) 29 | // callback.onContinue(postcard); 30 | // } else { 31 | // callback.onInterrupt(new Exception("用户没有登陆")); 32 | // } 33 | } 34 | 35 | @Override 36 | public void init(Context context) { 37 | mContext = context; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /module/module_app/src/main/java/me/jessyan/armscomponent/app/mvp/ui/activity/SplashActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 JessYan 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.jessyan.armscomponent.app.mvp.ui.activity; 17 | 18 | import android.os.Bundle; 19 | import android.support.annotation.NonNull; 20 | import android.support.annotation.Nullable; 21 | 22 | import com.alibaba.android.arouter.facade.annotation.Route; 23 | import com.jess.arms.base.BaseActivity; 24 | import com.jess.arms.di.component.AppComponent; 25 | 26 | import java.util.concurrent.TimeUnit; 27 | 28 | import io.reactivex.Observable; 29 | import io.reactivex.android.schedulers.AndroidSchedulers; 30 | import io.reactivex.functions.Consumer; 31 | import me.jessyan.armscomponent.app.R; 32 | import me.jessyan.armscomponent.commonsdk.core.RouterHub; 33 | import me.jessyan.armscomponent.commonsdk.utils.Utils; 34 | 35 | /** 36 | * ================================================ 37 | * Created by JessYan on 18/04/2018 17:03 38 | * Contact me 39 | * Follow me 40 | * ================================================ 41 | */ 42 | @Route(path = RouterHub.APP_SPLASHACTIVITY) 43 | public class SplashActivity extends BaseActivity { 44 | @Override 45 | public void setupActivityComponent(@NonNull AppComponent appComponent) { 46 | 47 | } 48 | 49 | @Override 50 | public int initView(@Nullable Bundle savedInstanceState) { 51 | return R.layout.app_activity_splash; 52 | } 53 | 54 | @Override 55 | public void initData(@Nullable Bundle savedInstanceState) { 56 | Observable.timer(2, TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer() { 57 | @Override 58 | public void accept(Long aLong) throws Exception { 59 | Utils.navigation(SplashActivity.this, RouterHub.APP_MAINACTIVITY); 60 | finish(); 61 | overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); 62 | } 63 | }); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /module/module_app/src/main/res/layout/app_activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 18 | 19 | 24 | 25 |