Compare View
Commits (2)
Showing
6 changed files
Show diff stats
app/build.gradle
| 1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
| 2 | apply from: '../config.gradle' | ||
| 3 | 2 | ||
| 4 | 3 | ||
| 5 | def androidId = rootProject.ext.androidId | 4 | def androidId = rootProject.ext.androidId |
| 6 | def support = rootProject.ext.dependencies | 5 | def support = rootProject.ext.dependencies |
| 7 | def url = rootProject.ext.url | 6 | def url = rootProject.ext.url |
| 8 | 7 | ||
| 9 | 8 | ||
| 10 | android { | 9 | android { |
| 11 | signingConfigs { | 10 | signingConfigs { |
| 12 | 11 | ||
| 13 | config { | 12 | config { |
| 14 | keyAlias 'alias' | 13 | keyAlias 'alias' |
| 15 | keyPassword '123456' | 14 | keyPassword '123456' |
| 16 | storeFile file('key.jks') | 15 | storeFile file('key.jks') |
| 17 | storePassword '123456' | 16 | storePassword '123456' |
| 18 | } | 17 | } |
| 19 | debug { | 18 | debug { |
| 20 | } | 19 | } |
| 21 | } | 20 | } |
| 22 | compileSdk 32 | 21 | compileSdk 32 |
| 23 | 22 | ||
| 24 | defaultConfig { | 23 | defaultConfig { |
| 25 | applicationId "com.hjx.parent" | 24 | applicationId "com.hjx.parent" |
| 26 | minSdk 26 | 25 | minSdk 26 |
| 27 | targetSdk 32 | 26 | targetSdk 32 |
| 28 | versionCode 1006 | 27 | versionCode 1006 |
| 29 | versionName "1.0.0.6" | 28 | versionName "1.0.0.6" |
| 30 | 29 | ||
| 31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 30 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | android.applicationVariants.all { | 33 | android.applicationVariants.all { |
| 35 | variant -> | 34 | variant -> |
| 36 | variant.outputs.all { | 35 | variant.outputs.all { |
| 37 | //在这里修改apk文件名 | 36 | //在这里修改apk文件名 |
| 38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" | 37 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" |
| 39 | } | 38 | } |
| 40 | } | 39 | } |
| 41 | buildTypes { | 40 | buildTypes { |
| 42 | debug { | 41 | debug { |
| 43 | debuggable true | 42 | debuggable true |
| 44 | minifyEnabled false | 43 | minifyEnabled false |
| 45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 44 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 46 | signingConfig signingConfigs.config | 45 | signingConfig signingConfigs.config |
| 47 | } | 46 | } |
| 48 | release { | 47 | release { |
| 49 | debuggable true | 48 | debuggable true |
| 50 | minifyEnabled false | 49 | minifyEnabled false |
| 51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 50 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 52 | signingConfig signingConfigs.config | 51 | signingConfig signingConfigs.config |
| 53 | } | 52 | } |
| 54 | } | 53 | } |
| 55 | lintOptions { | 54 | lintOptions { |
| 56 | checkReleaseBuilds false | 55 | checkReleaseBuilds false |
| 57 | abortOnError false | 56 | abortOnError false |
| 58 | } | 57 | } |
| 59 | buildFeatures { | 58 | buildFeatures { |
| 60 | viewBinding true | 59 | viewBinding true |
| 61 | dataBinding true | 60 | dataBinding true |
| 62 | } | 61 | } |
| 63 | compileOptions { | 62 | compileOptions { |
| 64 | sourceCompatibility JavaVersion.VERSION_1_8 | 63 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 65 | targetCompatibility JavaVersion.VERSION_1_8 | 64 | targetCompatibility JavaVersion.VERSION_1_8 |
| 66 | } | 65 | } |
| 67 | } | 66 | } |
| 68 | 67 | ||
| 69 | dependencies { | 68 | dependencies { |
| 70 | support.each { k, v -> implementation v } | 69 | support.each { k, v -> implementation v } |
| 71 | api project(path: ':libs:common') | 70 | api project(path: ':libs:common') |
| 72 | implementation 'androidx.appcompat:appcompat:1.5.1' | 71 | implementation 'androidx.appcompat:appcompat:1.5.1' |
| 73 | implementation 'com.google.android.material:material:1.6.1' | 72 | implementation 'com.google.android.material:material:1.6.1' |
| 74 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | 73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' |
| 75 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' | 74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' |
| 76 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' | 75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' |
| 77 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' | 76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' |
| 78 | //使用的三方 | 77 | //使用的三方 |
| 79 | implementation 'com.yalantis:ucrop:2.2.0' | 78 | implementation 'com.yalantis:ucrop:2.2.0' |
| 80 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' | 79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' |
| 81 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' | 80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' |
| 82 | 81 | ||
| 83 | // rx | 82 | // rx |
| 84 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") | 83 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") |
| 85 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") | 84 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") |
| 86 | 85 | ||
| 87 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") | 86 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") |
| 88 | implementation("com.contrarywind:Android-PickerView:4.1.9") | 87 | implementation("com.contrarywind:Android-PickerView:4.1.9") |
| 89 | 88 | ||
| 90 | implementation 'com.google.android:flexbox:1.0.0' | 89 | implementation 'com.google.android:flexbox:1.0.0' |
| 91 | 90 | ||
| 92 | // 沉浸式状态栏和他的Kotlin拓展 | 91 | // 沉浸式状态栏和他的Kotlin拓展 |
| 93 | implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' | 92 | implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' |
| 94 | implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' | 93 | implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' |
| 95 | 94 | ||
| 96 | // 图片查看 | 95 | // 图片查看 |
| 97 | implementation 'com.github.chrisbanes:PhotoView:2.0.0' | 96 | implementation 'com.github.chrisbanes:PhotoView:2.0.0' |
| 97 | |||
| 98 | implementation 'com.jakewharton:butterknife:10.2.3' | ||
| 99 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' |
build.gradle
| 1 | buildscript { | 1 | buildscript { |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | ext { | 4 | ext { |
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | androidId = [ | 7 | androidId = [ |
| 8 | compileSdkVersion: 32, | 8 | compileSdkVersion: 32, |
| 9 | minSdkVersion : 26, | 9 | minSdkVersion : 26, |
| 10 | targetSdkVersion : 32, | 10 | targetSdkVersion : 32, |
| 11 | versionCode : 1, | 11 | versionCode : 1, |
| 12 | versionName : "0.0.1" | 12 | versionName : "0.0.1" |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | ] | 15 | ] |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | url = [ | 18 | url = [ |
| 19 | server_url : "http://192.168.3.144:8088", //http 请求指令 | 19 | server_url : "http://192.168.3.144:8088", //http 请求指令 |
| 20 | server_url_online: "https://mgr.hjx.com", //http 请求指令 | 20 | server_url_online: "https://mgr.hjx.com", //http 请求指令 |
| 21 | ] | 21 | ] |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | dependencies = [ | 24 | dependencies = [ |
| 25 | appcompat : 'androidx.appcompat:appcompat:1.0.0', | 25 | appcompat : 'androidx.appcompat:appcompat:1.0.0', |
| 26 | constraint : 'androidx.constraintlayout:constraintlayout:1.1.3', | 26 | constraint : 'androidx.constraintlayout:constraintlayout:1.1.3', |
| 27 | cardview : 'androidx.cardview:cardview:1.0.0', | 27 | cardview : 'androidx.cardview:cardview:1.0.0', |
| 28 | recyclerview : 'androidx.recyclerview:recyclerview:1.0.0', | 28 | recyclerview : 'androidx.recyclerview:recyclerview:1.0.0', |
| 29 | material : 'com.google.android.material:material:1.0.0', | 29 | material : 'com.google.android.material:material:1.0.0', |
| 30 | // 依赖RxAndroid 2X 的依赖库 | 30 | // 依赖RxAndroid 2X 的依赖库 |
| 31 | // 增加RxJava 2X 的依赖库 | 31 | // 增加RxJava 2X 的依赖库 |
| 32 | rxandroid : 'io.reactivex.rxjava2:rxandroid:2.0.1', | 32 | rxandroid : 'io.reactivex.rxjava2:rxandroid:2.0.1', |
| 33 | rxjava : 'io.reactivex.rxjava2:rxjava:2.0.7', | 33 | rxjava : 'io.reactivex.rxjava2:rxjava:2.0.7', |
| 34 | 34 | ||
| 35 | // 以下需要使用Retrofit | 35 | // 以下需要使用Retrofit |
| 36 | //retrofit | 36 | //retrofit |
| 37 | retrofit : 'com.squareup.retrofit2:retrofit:2.1.0', | 37 | retrofit : 'com.squareup.retrofit2:retrofit:2.1.0', |
| 38 | //Gson converter | 38 | //Gson converter |
| 39 | converter : 'com.squareup.retrofit2:converter-gson:2.1.0', | 39 | converter : 'com.squareup.retrofit2:converter-gson:2.1.0', |
| 40 | //RxJava2 Adapter | 40 | //RxJava2 Adapter |
| 41 | retrofit2 : 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0', | 41 | retrofit2 : 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0', |
| 42 | //okhttp | 42 | //okhttp |
| 43 | okhttp : 'com.squareup.okhttp3:okhttp:3.8.1', | 43 | okhttp : 'com.squareup.okhttp3:okhttp:3.8.1', |
| 44 | logging : 'com.squareup.okhttp3:logging-interceptor:3.4.1', | 44 | logging : 'com.squareup.okhttp3:logging-interceptor:3.4.1', |
| 45 | // utils : 'com.github.wang-developer:AndroidUtilsDemo:1.0.6', | 45 | // utils : 'com.github.wang-developer:AndroidUtilsDemo:1.0.6', |
| 46 | commons_lang : 'org.apache.commons:commons-lang3:3.7', | 46 | commons_lang : 'org.apache.commons:commons-lang3:3.7', |
| 47 | commons_compress: 'org.apache.commons:commons-compress:1.19', | 47 | commons_compress: 'org.apache.commons:commons-compress:1.19', |
| 48 | commons_c_lang : 'commons-lang:commons-lang:2.3', | 48 | commons_c_lang : 'commons-lang:commons-lang:2.3', |
| 49 | commons_codec : 'commons-codec:commons-codec:1.7', | 49 | commons_codec : 'commons-codec:commons-codec:1.7', |
| 50 | eventbus : 'org.greenrobot:eventbus:3.2.0', | 50 | eventbus : 'org.greenrobot:eventbus:3.2.0', |
| 51 | eventbus2 : 'org.simple:androideventbus:1.0.5.1', | 51 | eventbus2 : 'org.simple:androideventbus:1.0.5.1', |
| 52 | glide : 'com.github.bumptech.glide:glide:4.6.1', | 52 | glide : 'com.github.bumptech.glide:glide:4.6.1', |
| 53 | permissions : 'com.github.getActivity:XXPermissions:18.5', | 53 | permissions : 'com.github.getActivity:XXPermissions:18.5', |
| 54 | orcode : 'cn.yipianfengye.android:zxing-library:2.2' | 54 | orcode : 'cn.yipianfengye.android:zxing-library:2.2' |
| 55 | // push : 'com.umeng.sdk:push:4.1.0', | 55 | // push : 'com.umeng.sdk:push:4.1.0', |
| 56 | // litepal : 'org.litepal.android:java:3.0.0', | 56 | // litepal : 'org.litepal.android:java:3.0.0', |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | // AlivcFFmpeg : 'com.aliyun.video.android:AlivcFFmpeg:2.0.0', | 59 | // AlivcFFmpeg : 'com.aliyun.video.android:AlivcFFmpeg:2.0.0', |
| 60 | 60 | ||
| 61 | // | 61 | // |
| 62 | // basequickadapter : 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34', | 62 | // basequickadapter : 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34', |
| 63 | // SwipeDelMenuLayout: 'com.github.mcxtzhang:SwipeDelMenuLayout:V1.3.0', | 63 | // SwipeDelMenuLayout: 'com.github.mcxtzhang:SwipeDelMenuLayout:V1.3.0', |
| 64 | // flycoTabLayout : 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' | 64 | // flycoTabLayout : 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' |
| 65 | 65 | ||
| 66 | 66 | ||
| 67 | ] | 67 | ] |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | repositories { | 71 | repositories { |
| 72 | maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } | 72 | maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } |
| 73 | maven { url 'https://maven.aliyun.com/repository/public' } | 73 | maven { url 'https://maven.aliyun.com/repository/public' } |
| 74 | maven { url 'https://maven.aliyun.com/repository/google' } | 74 | maven { url 'https://maven.aliyun.com/repository/google' } |
| 75 | maven { url 'https://repo.huaweicloud.com/repository/maven-public/' } | 75 | maven { url 'https://repo.huaweicloud.com/repository/maven-public/' } |
| 76 | //maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven-public/' } | 76 | //maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven-public/' } |
| 77 | 77 | ||
| 78 | google() | 78 | google() |
| 79 | mavenCentral() | 79 | mavenCentral() |
| 80 | gradlePluginPortal() | 80 | gradlePluginPortal() |
| 81 | maven { url "https://jitpack.io" } | 81 | maven { url "https://jitpack.io" } |
| 82 | } | 82 | } |
| 83 | dependencies { | 83 | dependencies { |
| 84 | classpath 'com.android.tools.build:gradle:4.2.2' | 84 | classpath 'com.android.tools.build:gradle:4.2.2' |
| 85 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' | 85 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' |
| 86 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' | 86 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' |
| 87 | classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3' | 87 | classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3' |
| 88 | classpath "com.alibaba:arouter-register:1.0.2" | 88 | //classpath "com.alibaba:arouter-register:1.0.2" |
| 89 | // NOTE: Do not place your application dependencies here; they belong | 89 | // NOTE: Do not place your application dependencies here; they belong |
| 90 | // in the individual module build.gradle files | 90 | // in the individual module build.gradle files |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | 93 | ||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | allprojects { | 97 | allprojects { |
| 98 | repositories { | 98 | repositories { |
| 99 | maven { url 'https://maven.aliyun.com/repository/public' } | 99 | maven { url 'https://maven.aliyun.com/repository/public' } |
| 100 | maven { url 'https://maven.aliyun.com/repository/google' } | 100 | maven { url 'https://maven.aliyun.com/repository/google' } |
| 101 | maven { url 'https://repo.huaweicloud.com/repository/maven-public/' } | 101 | maven { url 'https://repo.huaweicloud.com/repository/maven-public/' } |
| 102 | //maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven-public/' } | 102 | //maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven-public/' } |
| 103 | 103 | ||
| 104 | google() | 104 | google() |
| 105 | mavenCentral() | 105 | mavenCentral() |
| 106 | maven { url "https://jitpack.io" } | 106 | maven { url "https://jitpack.io" } |
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | task clean(type: Delete) { | 109 | task clean(type: Delete) { |
| 110 | delete rootProject.buildDir | 110 | delete rootProject.buildDir |
| 111 | } | 111 | } |
| 112 | 112 |
libs/common/build.gradle
| 1 | apply plugin: 'com.android.library' | 1 | apply plugin: 'com.android.library' |
| 2 | apply from: '../../config.gradle' | ||
| 3 | 2 | ||
| 4 | 3 | ||
| 5 | def androidId = rootProject.ext.androidId | 4 | def androidId = rootProject.ext.androidId |
| 6 | def support = rootProject.ext.dependencies | 5 | def support = rootProject.ext.dependencies |
| 7 | def url = rootProject.ext.url | 6 | def url = rootProject.ext.url |
| 8 | 7 | ||
| 9 | 8 | ||
| 10 | android { | 9 | android { |
| 11 | compileSdkVersion androidId.compileSdkVersion | 10 | compileSdkVersion androidId.compileSdkVersion |
| 12 | 11 | ||
| 13 | 12 | ||
| 14 | defaultConfig { | 13 | defaultConfig { |
| 15 | minSdkVersion androidId.minSdkVersion | 14 | minSdkVersion androidId.minSdkVersion |
| 16 | targetSdkVersion androidId.targetSdkVersion | 15 | targetSdkVersion androidId.targetSdkVersion |
| 17 | versionCode androidId.versionCode | 16 | versionCode androidId.versionCode |
| 18 | versionName androidId.versionName | 17 | versionName androidId.versionName |
| 19 | 18 | ||
| 20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 21 | 20 | ||
| 22 | buildConfigField("String", "APIKey1", "\"eCa3YzEjTBBiNjlXcNnjnldP\"") | 21 | buildConfigField("String", "APIKey1", "\"eCa3YzEjTBBiNjlXcNnjnldP\"") |
| 23 | buildConfigField("String", "SecretKey1", "\"KnZPmjF0ZzmxWV964mzmm6yuDljnETLt\"") | 22 | buildConfigField("String", "SecretKey1", "\"KnZPmjF0ZzmxWV964mzmm6yuDljnETLt\"") |
| 24 | } | 23 | } |
| 25 | 24 | ||
| 26 | buildTypes { | 25 | buildTypes { |
| 27 | debug { | 26 | debug { |
| 28 | minifyEnabled false | 27 | minifyEnabled false |
| 29 | buildConfigField("String", "SERVER_URL", "\"${url.server_url}\"") | 28 | buildConfigField("String", "SERVER_URL", "\"${url.server_url}\"") |
| 30 | buildConfigField("String", "APIKey", "\"OmmSqorNFXjVHXlZWhHAyGyQ\"") | 29 | buildConfigField("String", "APIKey", "\"OmmSqorNFXjVHXlZWhHAyGyQ\"") |
| 31 | buildConfigField("String", "SecretKey", "\"Uwjz4XGi89RN4Mvl5mievKpjqpGgUy6D\"") | 30 | buildConfigField("String", "SecretKey", "\"Uwjz4XGi89RN4Mvl5mievKpjqpGgUy6D\"") |
| 32 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 31 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 33 | } | 32 | } |
| 34 | release { | 33 | release { |
| 35 | minifyEnabled false | 34 | minifyEnabled false |
| 36 | buildConfigField("String", "SERVER_URL", "\"${url.server_url_online}\"") | 35 | buildConfigField("String", "SERVER_URL", "\"${url.server_url_online}\"") |
| 37 | buildConfigField("String", "APIKey", "\"OmmSqorNFXjVHXlZWhHAyGyQ\"") | 36 | buildConfigField("String", "APIKey", "\"OmmSqorNFXjVHXlZWhHAyGyQ\"") |
| 38 | buildConfigField("String", "SecretKey", "\"Uwjz4XGi89RN4Mvl5mievKpjqpGgUy6D\"") | 37 | buildConfigField("String", "SecretKey", "\"Uwjz4XGi89RN4Mvl5mievKpjqpGgUy6D\"") |
| 39 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 38 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 40 | } | 39 | } |
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | compileOptions { | 42 | compileOptions { |
| 44 | sourceCompatibility JavaVersion.VERSION_1_8 | 43 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 45 | targetCompatibility JavaVersion.VERSION_1_8 | 44 | targetCompatibility JavaVersion.VERSION_1_8 |
| 46 | } | 45 | } |
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | dependencies { | 48 | dependencies { |
| 50 | implementation fileTree(include: ['*.jar'], dir: 'libs') | 49 | implementation fileTree(include: ['*.jar'], dir: 'libs') |
| 51 | 50 | ||
| 52 | 51 | ||
| 53 | support.each { k, v -> implementation v } | 52 | support.each { k, v -> implementation v } |
| 54 | 53 | ||
| 55 | // 抓包, OkHttp拦截 | 54 | // 抓包, OkHttp拦截 |
| 56 | def chuckerVersion = "3.5.2" | 55 | def chuckerVersion = "3.5.2" |
| 57 | debugImplementation("com.github.chuckerteam.chucker:library:$chuckerVersion") { | 56 | debugImplementation("com.github.chuckerteam.chucker:library:$chuckerVersion") { |
| 58 | exclude module: 'lifecycle-viewmodel-ktx' | 57 | exclude module: 'lifecycle-viewmodel-ktx' |
| 59 | } | 58 | } |
| 60 | releaseImplementation("com.github.chuckerteam.chucker:library-no-op:$chuckerVersion") { | 59 | releaseImplementation("com.github.chuckerteam.chucker:library-no-op:$chuckerVersion") { |
| 61 | exclude module: 'lifecycle-viewmodel-ktx' | 60 | exclude module: 'lifecycle-viewmodel-ktx' |
| 62 | } | 61 | } |
| 63 | 62 | ||
| 63 | implementation 'com.jakewharton:butterknife:10.2.3' | ||
| 64 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' |
libs/common/src/main/java/com/prws/common/base/BaseActivity.java
| 1 | package com.prws.common.base; | 1 | package com.prws.common.base; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | import android.app.Activity; | 4 | import android.app.Activity; |
| 5 | import android.app.AlertDialog; | 5 | import android.app.AlertDialog; |
| 6 | import android.content.Context; | 6 | import android.content.Context; |
| 7 | import android.content.DialogInterface; | 7 | import android.content.DialogInterface; |
| 8 | import android.content.Intent; | 8 | import android.content.Intent; |
| 9 | import android.graphics.Color; | 9 | import android.graphics.Color; |
| 10 | import android.os.Bundle; | 10 | import android.os.Bundle; |
| 11 | import android.os.IBinder; | 11 | import android.os.IBinder; |
| 12 | import android.text.TextUtils; | 12 | import android.text.TextUtils; |
| 13 | import android.util.Log; | 13 | import android.util.Log; |
| 14 | import android.view.MotionEvent; | 14 | import android.view.MotionEvent; |
| 15 | import android.view.View; | 15 | import android.view.View; |
| 16 | import android.view.Window; | 16 | import android.view.Window; |
| 17 | import android.view.WindowManager; | 17 | import android.view.WindowManager; |
| 18 | import android.view.inputmethod.InputMethodManager; | 18 | import android.view.inputmethod.InputMethodManager; |
| 19 | import android.widget.EditText; | 19 | import android.widget.EditText; |
| 20 | import android.widget.Toast; | 20 | import android.widget.Toast; |
| 21 | 21 | ||
| 22 | import androidx.annotation.IdRes; | 22 | import androidx.annotation.IdRes; |
| 23 | import androidx.annotation.Nullable; | 23 | import androidx.annotation.Nullable; |
| 24 | import androidx.appcompat.app.AppCompatActivity; | 24 | import androidx.appcompat.app.AppCompatActivity; |
| 25 | import androidx.fragment.app.Fragment; | 25 | import androidx.fragment.app.Fragment; |
| 26 | import androidx.fragment.app.FragmentTransaction; | 26 | import androidx.fragment.app.FragmentTransaction; |
| 27 | import androidx.lifecycle.Lifecycle; | 27 | import androidx.lifecycle.Lifecycle; |
| 28 | 28 | ||
| 29 | import com.prws.common.R; | 29 | import com.prws.common.R; |
| 30 | import com.prws.common.net.INetEvent; | 30 | import com.prws.common.net.INetEvent; |
| 31 | import com.prws.common.utils.LogUtil; | 31 | import com.prws.common.utils.LogUtil; |
| 32 | import com.prws.common.utils.ScreenUtils; | 32 | import com.prws.common.utils.ScreenUtils; |
| 33 | import com.prws.common.view.LoadingView; | 33 | import com.prws.common.view.LoadingView; |
| 34 | 34 | ||
| 35 | import org.simple.eventbus.EventBus; | 35 | import org.simple.eventbus.EventBus; |
| 36 | 36 | ||
| 37 | import java.util.ArrayList; | 37 | import java.util.ArrayList; |
| 38 | import java.util.List; | 38 | import java.util.List; |
| 39 | 39 | ||
| 40 | import butterknife.ButterKnife; | 40 | import butterknife.ButterKnife; |
| 41 | import io.reactivex.disposables.CompositeDisposable; | 41 | import io.reactivex.disposables.CompositeDisposable; |
| 42 | import io.reactivex.disposables.Disposable; | 42 | import io.reactivex.disposables.Disposable; |
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | * @author 描述:BaseActivity | 46 | * @author 描述:BaseActivity |
| 47 | */ | 47 | */ |
| 48 | public abstract class BaseActivity<P extends BasePresenter, CONTRACT> extends AppCompatActivity implements INetEvent, BaseView { | 48 | public abstract class BaseActivity<P extends BasePresenter, CONTRACT> extends AppCompatActivity implements INetEvent, BaseView { |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | private LoadingView loading; | 51 | private LoadingView loading; |
| 52 | 52 | ||
| 53 | public static INetEvent mINetEvent; | 53 | public static INetEvent mINetEvent; |
| 54 | protected final String TAG = getClass().getSimpleName(); | 54 | protected final String TAG = getClass().getSimpleName(); |
| 55 | private CompositeDisposable mCompositeDisposable; | 55 | private CompositeDisposable mCompositeDisposable; |
| 56 | protected P p; | 56 | protected P p; |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| 59 | * 获取布局文件 | 59 | * 获取布局文件 |
| 60 | * | 60 | * |
| 61 | * @return | 61 | * @return |
| 62 | */ | 62 | */ |
| 63 | protected abstract int layoutResId(); | 63 | protected abstract int layoutResId(); |
| 64 | 64 | ||
| 65 | /** | 65 | /** |
| 66 | * 让P层做相应需求 | 66 | * 让P层做相应需求 |
| 67 | */ | 67 | */ |
| 68 | public abstract CONTRACT getContract(); | 68 | public abstract CONTRACT getContract(); |
| 69 | 69 | ||
| 70 | /** | 70 | /** |
| 71 | * 子类获取具体契约 | 71 | * 子类获取具体契约 |
| 72 | */ | 72 | */ |
| 73 | public abstract P getPresenter(); | 73 | public abstract P getPresenter(); |
| 74 | 74 | ||
| 75 | @Override | 75 | @Override |
| 76 | protected void onCreate(@Nullable Bundle savedInstanceState) { | 76 | protected void onCreate(@Nullable Bundle savedInstanceState) { |
| 77 | super.onCreate(savedInstanceState); | 77 | super.onCreate(savedInstanceState); |
| 78 | setNetEvent(); | 78 | setNetEvent(); |
| 79 | initPresenter(); | 79 | initPresenter(); |
| 80 | showWhiteStatus(); | 80 | showWhiteStatus(); |
| 81 | setContentView(layoutResId()); | 81 | setContentView(layoutResId()); |
| 82 | ButterKnife.bind(this); | 82 | ButterKnife.bind(this); |
| 83 | registerEventBus(); | 83 | registerEventBus(); |
| 84 | initView(); | 84 | initView(); |
| 85 | initListener(); | 85 | initListener(); |
| 86 | initData(); | 86 | initData(); |
| 87 | 87 | ||
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | 90 | ||
| 91 | public void showWhiteStatus() { | 91 | public void showWhiteStatus() { |
| 92 | Window window = getWindow(); | 92 | Window window = getWindow(); |
| 93 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); | 93 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| 94 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); | 94 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
| 95 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | 95 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
| 96 | window.setStatusBarColor(Color.TRANSPARENT); | 96 | window.setStatusBarColor(Color.TRANSPARENT); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | 99 | ||
| 100 | public void fullScreen(){ | 100 | public void fullScreen(){ |
| 101 | Window window = getWindow(); | 101 | Window window = getWindow(); |
| 102 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); | 102 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| 103 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | 103 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 104 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); | 104 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); |
| 105 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | 105 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
| 106 | window.setStatusBarColor(Color.TRANSPARENT); | 106 | window.setStatusBarColor(Color.TRANSPARENT); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | protected void blackBar() { | 109 | protected void blackBar() { |
| 110 | Window window = getWindow(); | 110 | Window window = getWindow(); |
| 111 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); | 111 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| 112 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | 112 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 113 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); | 113 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
| 114 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | 114 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
| 115 | window.setStatusBarColor(Color.TRANSPARENT); | 115 | window.setStatusBarColor(Color.TRANSPARENT); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | @Override | 118 | @Override |
| 119 | protected void onResume() { | 119 | protected void onResume() { |
| 120 | super.onResume(); | 120 | super.onResume(); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | protected abstract void initView(); | 123 | protected abstract void initView(); |
| 124 | 124 | ||
| 125 | protected abstract void initListener(); | 125 | protected abstract void initListener(); |
| 126 | 126 | ||
| 127 | protected abstract void initData(); | 127 | protected abstract void initData(); |
| 128 | 128 | ||
| 129 | 129 | ||
| 130 | private void setNetEvent() { | 130 | private void setNetEvent() { |
| 131 | mINetEvent = this; | 131 | mINetEvent = this; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | private void initPresenter() { | 134 | private void initPresenter() { |
| 135 | p = getPresenter(); | 135 | p = getPresenter(); |
| 136 | if (p != null) | 136 | if (p != null) |
| 137 | p.bindView(this); | 137 | p.bindView(this); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | 140 | ||
| 141 | public void showDialog(String title, String message, String confirm, String cancel, DialogInterface.OnClickListener cancelListener, DialogInterface.OnClickListener listener) { | 141 | public void showDialog(String title, String message, String confirm, String cancel, DialogInterface.OnClickListener cancelListener, DialogInterface.OnClickListener listener) { |
| 142 | AlertDialog.Builder builder = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); | 142 | AlertDialog.Builder builder = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); |
| 143 | builder.setTitle(title); | 143 | builder.setTitle(title); |
| 144 | builder.setMessage(message); | 144 | builder.setMessage(message); |
| 145 | builder.setCancelable(false); | 145 | builder.setCancelable(false); |
| 146 | if (!TextUtils.isEmpty(cancel)) { | 146 | if (!TextUtils.isEmpty(cancel)) { |
| 147 | builder.setNegativeButton(cancel, cancelListener); | 147 | builder.setNegativeButton(cancel, cancelListener); |
| 148 | } | 148 | } |
| 149 | builder.setPositiveButton(confirm, listener); | 149 | builder.setPositiveButton(confirm, listener); |
| 150 | builder.show(); | 150 | builder.show(); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | private void setWindow() { | 153 | private void setWindow() { |
| 154 | Window window = getWindow(); | 154 | Window window = getWindow(); |
| 155 | WindowManager.LayoutParams params = window.getAttributes(); | 155 | WindowManager.LayoutParams params = window.getAttributes(); |
| 156 | params.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN | 156 | params.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN |
| 157 | ; | 157 | ; |
| 158 | window.setAttributes(params); | 158 | window.setAttributes(params); |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | 161 | ||
| 162 | // public void openFloatWindow() { | 162 | // public void openFloatWindow() { |
| 163 | // if (FloatWindow.get("navigation") == null) { | 163 | // if (FloatWindow.get("navigation") == null) { |
| 164 | // NavigationBarView navigationBarView = new NavigationBarView(this); | 164 | // NavigationBarView navigationBarView = new NavigationBarView(this); |
| 165 | // FloatWindow.with(CommonApplication.getAppContext()) | 165 | // FloatWindow.with(CommonApplication.getAppContext()) |
| 166 | // .setView(navigationBarView) | 166 | // .setView(navigationBarView) |
| 167 | // .setWidth(Screen.width, 1) | 167 | // .setWidth(Screen.width, 1) |
| 168 | // .setHeight(WindowManager.LayoutParams.WRAP_CONTENT) | 168 | // .setHeight(WindowManager.LayoutParams.WRAP_CONTENT) |
| 169 | // .setX(0) | 169 | // .setX(0) |
| 170 | // .setY(0) | 170 | // .setY(0) |
| 171 | // .setMoveType(MoveType.inactive) | 171 | // .setMoveType(MoveType.inactive) |
| 172 | // .setDesktopShow(false) | 172 | // .setDesktopShow(false) |
| 173 | // .setTag("navigation") | 173 | // .setTag("navigation") |
| 174 | // .build(); | 174 | // .build(); |
| 175 | // } | 175 | // } |
| 176 | // if (!FloatWindow.get("navigation").isShowing()) | 176 | // if (!FloatWindow.get("navigation").isShowing()) |
| 177 | // FloatWindow.get("navigation").show(); | 177 | // FloatWindow.get("navigation").show(); |
| 178 | // | 178 | // |
| 179 | // } | 179 | // } |
| 180 | 180 | ||
| 181 | 181 | ||
| 182 | public void showAlertDialogOfFloatWindow() { | 182 | public void showAlertDialogOfFloatWindow() { |
| 183 | //弹窗提示用户开启权限 | 183 | //弹窗提示用户开启权限 |
| 184 | // new AlertDialog(this).builder().setTitle(getString(R.string.need_permission)) | 184 | // new AlertDialog(this).builder().setTitle(getString(R.string.need_permission)) |
| 185 | // .setMsg(getString(R.string.need_permission_window)) | 185 | // .setMsg(getString(R.string.need_permission_window)) |
| 186 | // .setPositiveButton(getString(R.string.open), new View.OnClickListener() { | 186 | // .setPositiveButton(getString(R.string.open), new View.OnClickListener() { |
| 187 | // @Override | 187 | // @Override |
| 188 | // public void onClick(View v) { | 188 | // public void onClick(View v) { |
| 189 | // Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); | 189 | // Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); |
| 190 | // intent.setData(Uri.parse("package:" + getPackageName())); | 190 | // intent.setData(Uri.parse("package:" + getPackageName())); |
| 191 | // startActivity(intent); | 191 | // startActivity(intent); |
| 192 | // } | 192 | // } |
| 193 | // }).setNegativeButton(getString(R.string.cancel), new View.OnClickListener() { | 193 | // }).setNegativeButton(getString(R.string.cancel), new View.OnClickListener() { |
| 194 | // @Override | 194 | // @Override |
| 195 | // public void onClick(View v) { | 195 | // public void onClick(View v) { |
| 196 | // } | 196 | // } |
| 197 | // }).show(); | 197 | // }).show(); |
| 198 | LogUtil.toast("请开启浮窗权限"); | 198 | LogUtil.toast("请开启浮窗权限"); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | 201 | ||
| 202 | public void showLoading(String title) { | 202 | public void showLoading(String title) { |
| 203 | synchronized (this) { | 203 | synchronized (this) { |
| 204 | if (loading != null || !isLiving(this)) return; | 204 | if (loading != null || !isLiving(this)) return; |
| 205 | runOnUiThread(() -> { | 205 | runOnUiThread(() -> { |
| 206 | loading = new LoadingView(this, R.style.CustomDialog, title); | 206 | loading = new LoadingView(this, R.style.CustomDialog, title); |
| 207 | loading.show(); | 207 | loading.show(); |
| 208 | ScreenUtils.hideBottomUIMenu(this); | 208 | ScreenUtils.hideBottomUIMenu(this); |
| 209 | ScreenUtils.hideDialogBottomUIMenu(loading); | 209 | ScreenUtils.hideDialogBottomUIMenu(loading); |
| 210 | }); | 210 | }); |
| 211 | } | 211 | } |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | 214 | ||
| 215 | public void setCanAble(boolean canAble) { | 215 | public void setCanAble(boolean canAble) { |
| 216 | if (loading != null) | 216 | if (loading != null) |
| 217 | loading.setCancelable(canAble); | 217 | loading.setCancelable(canAble); |
| 218 | 218 | ||
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | public boolean isShowLoading() { | 221 | public boolean isShowLoading() { |
| 222 | if (loading == null) return false; | 222 | if (loading == null) return false; |
| 223 | return loading.isShowing(); | 223 | return loading.isShowing(); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | public void dismissLoading() { | 226 | public void dismissLoading() { |
| 227 | runOnUiThread(() -> { | 227 | runOnUiThread(() -> { |
| 228 | if (loading == null || loading.isShowing() == false || !isLiving(this)) { | 228 | if (loading == null || loading.isShowing() == false || !isLiving(this)) { |
| 229 | Log.w(TAG, "loading == null" + | 229 | Log.w(TAG, "loading == null" + |
| 230 | " || loading.isShowing() == false >> return;"); | 230 | " || loading.isShowing() == false >> return;"); |
| 231 | return; | 231 | return; |
| 232 | } | 232 | } |
| 233 | loading.dismiss(); | 233 | loading.dismiss(); |
| 234 | loading = null; | 234 | loading = null; |
| 235 | 235 | ||
| 236 | }); | 236 | }); |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | 239 | ||
| 240 | private static boolean isLiving(Activity activity) { | 240 | private static boolean isLiving(Activity activity) { |
| 241 | 241 | ||
| 242 | if (activity == null) { | 242 | if (activity == null) { |
| 243 | Log.d("wisely", "activity == null"); | 243 | Log.d("wisely", "activity == null"); |
| 244 | return false; | 244 | return false; |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | if (activity.isFinishing()) { | 247 | if (activity.isFinishing()) { |
| 248 | Log.d("wisely", "activity is finishing"); | 248 | Log.d("wisely", "activity is finishing"); |
| 249 | return false; | 249 | return false; |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | return true; | 252 | return true; |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | 255 | ||
| 256 | /** | 256 | /** |
| 257 | * 是否需要弹窗提示更新 | 257 | * 是否需要弹窗提示更新 |
| 258 | */ | 258 | */ |
| 259 | protected void isNeedGetVersionUpdate() { | 259 | protected void isNeedGetVersionUpdate() { |
| 260 | // View view = findViewById(R.id.view_loading); | 260 | // View view = findViewById(R.id.view_loading); |
| 261 | //如果显示正在下载的页面,则不弹出更新弹窗 | 261 | //如果显示正在下载的页面,则不弹出更新弹窗 |
| 262 | // if (null == view || view.getVisibility() == View.VISIBLE) return; | 262 | // if (null == view || view.getVisibility() == View.VISIBLE) return; |
| 263 | // UpdateUtils.getVersion(this); | 263 | // UpdateUtils.getVersion(this); |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | 266 | ||
| 267 | /** | 267 | /** |
| 268 | * 全局检测网络广播的回调 处理网络变化 | 268 | * 全局检测网络广播的回调 处理网络变化 |
| 269 | * 注:在程序第一次启动的时候,没网并不会回调,需要自己在启动页面,或者主页自己再判断一次 | 269 | * 注:在程序第一次启动的时候,没网并不会回调,需要自己在启动页面,或者主页自己再判断一次 |
| 270 | * | 270 | * |
| 271 | * @param netWorkState 网络状态 -1:没网络 0:移动网络 1:WiFi网络 | 271 | * @param netWorkState 网络状态 -1:没网络 0:移动网络 1:WiFi网络 |
| 272 | */ | 272 | */ |
| 273 | public abstract void onNetChanged(int netWorkState); | 273 | public abstract void onNetChanged(int netWorkState); |
| 274 | 274 | ||
| 275 | @Override | 275 | @Override |
| 276 | public void onNetChange(int netWorkState) { | 276 | public void onNetChange(int netWorkState) { |
| 277 | onNetChanged(netWorkState); | 277 | onNetChanged(netWorkState); |
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | @Override | 280 | @Override |
| 281 | protected void onDestroy() { | 281 | protected void onDestroy() { |
| 282 | super.onDestroy(); | 282 | super.onDestroy(); |
| 283 | unSubscribe(); | 283 | unSubscribe(); |
| 284 | cleanFragment(); | 284 | cleanFragment(); |
| 285 | unregisterEventBus(); | 285 | unregisterEventBus(); |
| 286 | if (p != null) { | 286 | if (p != null) { |
| 287 | p.onBindView(); | 287 | p.onBindView(); |
| 288 | p.cancelAllRequest(); | 288 | p.cancelAllRequest(); |
| 289 | } | 289 | } |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | @Override | 292 | @Override |
| 293 | protected void onPause() { | 293 | protected void onPause() { |
| 294 | super.onPause(); | 294 | super.onPause(); |
| 295 | 295 | ||
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | private void registerEventBus() { | 298 | private void registerEventBus() { |
| 299 | EventBus.getDefault().register(this); | 299 | EventBus.getDefault().register(this); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | private void unregisterEventBus() { | 302 | private void unregisterEventBus() { |
| 303 | EventBus.getDefault().unregister(this); | 303 | EventBus.getDefault().unregister(this); |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | public void showErrorToast() { | 306 | public void showErrorToast() { |
| 307 | // LogUtil.toast(MainApplication.getAppContext(), getString(R.string.service_error)); | 307 | // LogUtil.toast(MainApplication.getAppContext(), getString(R.string.service_error)); |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | public void showToast(String s) { | 310 | public void showToast(String s) { |
| 311 | Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show(); | 311 | Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show(); |
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | private void unSubscribe() { | 314 | private void unSubscribe() { |
| 315 | if (mCompositeDisposable != null) { | 315 | if (mCompositeDisposable != null) { |
| 316 | mCompositeDisposable.clear(); | 316 | mCompositeDisposable.clear(); |
| 317 | } | 317 | } |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | protected void addSubscribe(Disposable disposable) { | 320 | protected void addSubscribe(Disposable disposable) { |
| 321 | if (mCompositeDisposable == null) { | 321 | if (mCompositeDisposable == null) { |
| 322 | mCompositeDisposable = new CompositeDisposable(); | 322 | mCompositeDisposable = new CompositeDisposable(); |
| 323 | } | 323 | } |
| 324 | mCompositeDisposable.add(disposable); | 324 | mCompositeDisposable.add(disposable); |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | protected void startActivity(Class clazz) { | 327 | protected void startActivity(Class clazz) { |
| 328 | startActivity(new Intent(this, clazz)); | 328 | startActivity(new Intent(this, clazz)); |
| 329 | } | 329 | } |
| 330 | 330 | ||
| 331 | /******************** 处理fragment *******************************/ | 331 | /******************** 处理fragment *******************************/ |
| 332 | List<Fragment> fragmentList = new ArrayList<>(); | 332 | List<Fragment> fragmentList = new ArrayList<>(); |
| 333 | 333 | ||
| 334 | protected void showFragment(Fragment fragment, @IdRes int id) { | 334 | protected void showFragment(Fragment fragment, @IdRes int id) { |
| 335 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); | 335 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); |
| 336 | 336 | ||
| 337 | if (!fragmentList.contains(fragment)) { | 337 | if (!fragmentList.contains(fragment)) { |
| 338 | fragmentList.add(fragment); | 338 | fragmentList.add(fragment); |
| 339 | fragmentTransaction.add(id, fragment, fragment.getClass().getSimpleName()); | 339 | fragmentTransaction.add(id, fragment, fragment.getClass().getSimpleName()); |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | fragmentTransaction.show(fragment); | 342 | fragmentTransaction.show(fragment); |
| 343 | 343 | ||
| 344 | for (Fragment fragment1 : fragmentList) { | 344 | for (Fragment fragment1 : fragmentList) { |
| 345 | if (fragment1 != fragment) { | 345 | if (fragment1 != fragment) { |
| 346 | fragmentTransaction.hide(fragment1); | 346 | fragmentTransaction.hide(fragment1); |
| 347 | } | 347 | } |
| 348 | } | 348 | } |
| 349 | 349 | ||
| 350 | fragmentTransaction.commitAllowingStateLoss(); | 350 | fragmentTransaction.commitAllowingStateLoss(); |
| 351 | 351 | ||
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | protected void cleanFragment() { | 354 | protected void cleanFragment() { |
| 355 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); | 355 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); |
| 356 | if (fragmentList.size() > 0) { | 356 | if (fragmentList.size() > 0) { |
| 357 | for (Fragment fragment : fragmentList) { | 357 | for (Fragment fragment : fragmentList) { |
| 358 | fragmentTransaction.remove(fragment); | 358 | fragmentTransaction.remove(fragment); |
| 359 | } | 359 | } |
| 360 | try { | 360 | try { |
| 361 | fragmentTransaction.commitNowAllowingStateLoss(); | 361 | fragmentTransaction.commitNowAllowingStateLoss(); |
| 362 | } catch (Exception e) { | 362 | } catch (Exception e) { |
| 363 | e.printStackTrace(); | 363 | e.printStackTrace(); |
| 364 | } | 364 | } |
| 365 | } | 365 | } |
| 366 | fragmentList.clear(); | 366 | fragmentList.clear(); |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | //************************* 用于隐藏键盘 ***************************************// | 369 | //************************* 用于隐藏键盘 ***************************************// |
| 370 | @Override | 370 | @Override |
| 371 | public boolean dispatchTouchEvent(MotionEvent ev) { | 371 | public boolean dispatchTouchEvent(MotionEvent ev) { |
| 372 | if (ev.getAction() == MotionEvent.ACTION_DOWN) { | 372 | if (ev.getAction() == MotionEvent.ACTION_DOWN) { |
| 373 | 373 | ||
| 374 | View v = getCurrentFocus(); | 374 | View v = getCurrentFocus(); |
| 375 | if (isShouldHideInput(v, ev)) { | 375 | if (isShouldHideInput(v, ev)) { |
| 376 | hideSoftInput(v.getWindowToken()); | 376 | hideSoftInput(v.getWindowToken()); |
| 377 | } | 377 | } |
| 378 | } | 378 | } |
| 379 | return super.dispatchTouchEvent(ev); | 379 | return super.dispatchTouchEvent(ev); |
| 380 | } | 380 | } |
| 381 | 381 | ||
| 382 | private boolean isShouldHideInput(View v, MotionEvent event) { | 382 | private boolean isShouldHideInput(View v, MotionEvent event) { |
| 383 | if (v != null && (v instanceof EditText)) { | 383 | if (v != null && (v instanceof EditText)) { |
| 384 | int[] l = {0, 0}; | 384 | int[] l = {0, 0}; |
| 385 | v.getLocationInWindow(l); | 385 | v.getLocationInWindow(l); |
| 386 | int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left | 386 | int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left |
| 387 | + v.getWidth(); | 387 | + v.getWidth(); |
| 388 | if (event.getX() > left && event.getX() < right | 388 | if (event.getX() > left && event.getX() < right |
| 389 | && event.getY() > top && event.getY() < bottom) { | 389 | && event.getY() > top && event.getY() < bottom) { |
| 390 | // 点击EditText的事件,忽略它。 | 390 | // 点击EditText的事件,忽略它。 |
| 391 | return false; | 391 | return false; |
| 392 | } else { | 392 | } else { |
| 393 | return true; | 393 | return true; |
| 394 | } | 394 | } |
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | return false; | 397 | return false; |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | /** | 400 | /** |
| 401 | * 多种隐藏软件盘方法的其中一种 | 401 | * 多种隐藏软件盘方法的其中一种 |
| 402 | * | 402 | * |
| 403 | * @param token | 403 | * @param token |
| 404 | */ | 404 | */ |
| 405 | private void hideSoftInput(IBinder token) { | 405 | private void hideSoftInput(IBinder token) { |
| 406 | LogUtil.i(TAG, "隐藏键盘"); | 406 | LogUtil.i(TAG, "隐藏键盘"); |
| 407 | if (token != null) { | 407 | if (token != null) { |
| 408 | InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); | 408 | InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
| 409 | im.hideSoftInputFromWindow(token, | 409 | im.hideSoftInputFromWindow(token, |
| 410 | InputMethodManager.HIDE_NOT_ALWAYS); | 410 | InputMethodManager.HIDE_NOT_ALWAYS); |
| 411 | } | 411 | } |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | //************************* 用于隐藏键盘 end***************************************// | 414 | //************************* 用于隐藏键盘 end***************************************// |
| 415 | 415 | ||
| 416 | 416 | ||
| 417 | } | 417 | } |
| 418 | 418 |
libs/common/src/main/java/com/prws/common/router/RouterFragmentUtils.java
| 1 | package com.prws.common.router; | File was deleted | |
| 2 | |||
| 3 | import androidx.fragment.app.Fragment; | ||
| 4 | |||
| 5 | import com.alibaba.android.arouter.launcher.ARouter; | ||
| 6 | |||
| 7 | public class RouterFragmentUtils { | ||
| 8 | /****************************** SettingActivity *********************/ | ||
| 9 | public static Fragment getSpeekFragment() { | ||
| 10 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_SPEEK).navigation(); | ||
| 11 | } | ||
| 12 | |||
| 13 | public static Fragment getWorkFragment() { | ||
| 14 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_WORK).navigation(); | ||
| 15 | } | ||
| 16 | |||
| 17 | public static Fragment getWifiFragment() { | ||
| 18 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_WIFI).navigation(); | ||
| 19 | } | ||
| 20 | |||
| 21 | public static Fragment getAccountFragment() { | ||
| 22 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_ACCOUNT).navigation(); | ||
| 23 | } | ||
| 24 | |||
| 25 | public static Fragment getAlarmFragment() { | ||
| 26 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_ALARM).navigation(); | ||
| 27 | } | ||
| 28 | |||
| 29 | public static Fragment getVoiceFragment() { | ||
| 30 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_VOICE).navigation(); | ||
| 31 | } | ||
| 32 | |||
| 33 | public static Fragment getPwdFragment() { | ||
| 34 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_PWD).navigation(); | ||
| 35 | } | ||
| 36 | |||
| 37 | public static Fragment getRunFragment() { | ||
| 38 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_RUN).navigation(); | ||
| 39 | } | ||
| 40 | |||
| 41 | public static Fragment getLanguageFragment() { | ||
| 42 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_LANGUAGE).navigation(); | ||
| 43 | } | ||
| 44 | public static Fragment getWashSweepSettingFragment(){ | ||
| 45 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_WASH_SWEEP_SETTING).navigation(); | ||
| 46 | } | ||
| 47 | |||
| 48 | public static Fragment getMachineFragment() { | ||
| 49 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_MACHINE).navigation(); | ||
| 50 | } | ||
| 51 | |||
| 52 | public static Fragment getTaskFragment() { | ||
| 53 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_TASK).navigation(); | ||
| 54 | } | ||
| 55 | public static Fragment getCaiFragment() { | ||
| 56 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_CAI).navigation(); | ||
| 57 | } | ||
| 58 | public static Fragment getShuiFragment() { | ||
| 59 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_SHUI).navigation(); | ||
| 60 | } | ||
| 61 | public static Fragment getxdFragment() { | ||
| 62 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_XDS).navigation(); | ||
| 63 | } | ||
| 64 | public static Fragment getxdaFragment() { | ||
| 65 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_XDSA).navigation(); | ||
| 66 | } | ||
| 67 | |||
| 68 | |||
| 69 | /******************************** RemoteActivity *************************/ | ||
| 70 | public static Fragment getWashSweepFragment(){ | ||
| 71 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_WASH_SWEEP).navigation(); | ||
| 72 | } | ||
| 73 | public static Fragment getDustFragment() { | ||
| 74 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_DUST).navigation(); | ||
| 75 | } | ||
| 76 | |||
| 77 | public static Fragment getDisinfectFragment() { | ||
| 78 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_DISINFECT).navigation(); | ||
| 79 | } | ||
| 80 | |||
| 81 | public static Fragment getSidePushFragment() { | ||
| 82 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_SIDE_PUSH).navigation(); | ||
| 83 | } | ||
| 84 | |||
| 85 | public static Fragment getChargeFragment() { | ||
| 86 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_CHARGE).navigation(); | ||
| 87 | } | ||
| 88 | |||
| 89 | public static Fragment getPenLinFragment() { | ||
| 90 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_PENLIN).navigation(); | ||
| 91 | } | ||
| 92 | public static Fragment getGSFragment() { | ||
| 93 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_GS).navigation(); | ||
| 94 | } | ||
| 95 | public static Fragment getXCFragment() { | ||
| 96 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_XC).navigation(); | ||
| 97 | } | ||
| 98 | public static Fragment getCJFragment() { | ||
| 99 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_CJ).navigation(); | ||
| 100 | } | ||
| 101 | public static Fragment getJHFragment() { | ||
| 102 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_JH).navigation(); | ||
| 103 | } | ||
| 104 | public static Fragment getWSJFragment() { | ||
| 105 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_WSJ).navigation(); | ||
| 106 | } | ||
| 107 | public static Fragment getPDFragment() { | ||
| 108 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_PD).navigation(); | ||
| 109 | } | ||
| 110 | public static Fragment getXDABFragment() { | ||
| 111 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_XDAB).navigation(); | ||
| 112 | } | ||
| 113 | |||
| 114 | } | ||
| 115 | 1 | package com.prws.common.router; |
libs/common/src/main/java/com/prws/common/router/RouterUtils.java
| 1 | package com.prws.common.router; | File was deleted | |
| 2 | |||
| 3 | import android.content.pm.ApplicationInfo; | ||
| 4 | import android.content.pm.PackageManager; | ||
| 5 | import com.prws.common.CommonApplication; | ||
| 6 | |||
| 7 | import com.alibaba.android.arouter.launcher.ARouter; | ||
| 8 | |||
| 9 | import java.util.ArrayList; | ||
| 10 | |||
| 11 | |||
| 12 | public class RouterUtils { | ||
| 13 | |||
| 14 | public static void goTestActivity(){ | ||
| 15 | if (isPaimo()) | ||
| 16 | ARouter.getInstance().build(RouterConfig.PAIMO_TEST).navigation(); | ||
| 17 | else | ||
| 18 | ARouter.getInstance().build(RouterConfig.TEST).navigation(); | ||
| 19 | } | ||
| 20 | |||
| 21 | public static void getMapTestActivity(){ | ||
| 22 | ARouter.getInstance().build(RouterConfig.MAP_ACTY_TEST).navigation(); | ||
| 23 | } | ||
| 24 | |||
| 25 | public static void goMapListActivity(){ | ||
| 26 | ARouter.getInstance().build(RouterConfig.MAP_LIST).navigation(); | ||
| 27 | } | ||
| 28 | public static void goMapCreateActivity(ArrayList<String> mapNameList){ | ||
| 29 | ARouter.getInstance().build(RouterConfig.MAP_CREATE) | ||
| 30 | .withStringArrayList("mapNameList",mapNameList) | ||
| 31 | .navigation(); | ||
| 32 | } | ||
| 33 | |||
| 34 | public static void goEditMapActivity(String projectId,String mapMd5){ | ||
| 35 | ARouter.getInstance().build(RouterConfig.MAP_EDIT) | ||
| 36 | .withString("projectId",projectId) | ||
| 37 | .withString("mapMd5",mapMd5) | ||
| 38 | .navigation(); | ||
| 39 | } | ||
| 40 | |||
| 41 | public static void goMenuActivity(){ | ||
| 42 | |||
| 43 | if (isPaiwee()) | ||
| 44 | ARouter.getInstance().build(RouterConfig.PAIWEE_MENU).navigation(); | ||
| 45 | else if (isPaipo()) | ||
| 46 | ARouter.getInstance().build(RouterConfig.PAIPO_MENU).navigation(); | ||
| 47 | else | ||
| 48 | ARouter.getInstance().build(RouterConfig.PAIMO_MENU).navigation(); | ||
| 49 | |||
| 50 | } | ||
| 51 | public static void goTaskActivity(){ | ||
| 52 | ARouter.getInstance().build(RouterConfig.TASK).navigation(); | ||
| 53 | } | ||
| 54 | public static void goRemoteActivity(){ | ||
| 55 | if (isPaiwee()) | ||
| 56 | ARouter.getInstance().build(RouterConfig.PAIWEE_REMOTE).navigation(); | ||
| 57 | else | ||
| 58 | ARouter.getInstance().build(RouterConfig.REMOTE).navigation(); | ||
| 59 | } | ||
| 60 | |||
| 61 | public static void goSettingActivity(){ | ||
| 62 | |||
| 63 | if (isPaiwee()) | ||
| 64 | ARouter.getInstance().build(RouterConfig.PAIWEE_SETTING).navigation(); | ||
| 65 | else | ||
| 66 | ARouter.getInstance().build(RouterConfig.SETTING).navigation(); | ||
| 67 | |||
| 68 | } | ||
| 69 | |||
| 70 | public static void goMainActivity(){ | ||
| 71 | if (isPaimo()){ | ||
| 72 | |||
| 73 | }else if (isPaipo()){ | ||
| 74 | |||
| 75 | }else if (isPaisam()){ | ||
| 76 | |||
| 77 | } | ||
| 78 | |||
| 79 | // if (BuildConfig.PROJECT_NAME.equals("paimo")) | ||
| 80 | // ARouter.getInstance().build(RouterConfig.PAIMO_MAIN).navigation(); | ||
| 81 | // else if (BuildConfig.PROJECT_NAME.equals("paipo")) | ||
| 82 | // ARouter.getInstance().build(RouterConfig.PAIPO_MAIN).navigation(); | ||
| 83 | // else if (BuildConfig.PROJECT_NAME.equals("paisam")) | ||
| 84 | // ARouter.getInstance().build(RouterConfig.PAISAM_MAIN).navigation(); | ||
| 85 | } | ||
| 86 | |||
| 87 | |||
| 88 | |||
| 89 | /************************* 判断项目类型 **********************************/ | ||
| 90 | |||
| 91 | public static boolean isPaimo(){ return getProjectName().equals("paimo"); } | ||
| 92 | private static boolean isPaipo(){ | ||
| 93 | return getProjectName().equals("paipo"); | ||
| 94 | } | ||
| 95 | private static boolean isPaisam(){ | ||
| 96 | return getProjectName().equals("paisam"); | ||
| 97 | } | ||
| 98 | public static boolean isPaiwee(){ | ||
| 99 | return getProjectName().equals("paiwee"); | ||
| 100 | } | ||
| 101 | |||
| 102 | |||
| 103 | public static String getProjectName(){ | ||
| 104 | // ApplicationInfo applicationInfo = null; | ||
| 105 | // try { | ||
| 106 | // applicationInfo = CommonApplication.getAppContext().getPackageManager().getApplicationInfo(CommonApplication.getAppContext().getPackageName(), PackageManager.GET_META_DATA); | ||
| 107 | // } catch (PackageManager.NameNotFoundException e) { | ||
| 108 | // e.printStackTrace(); | ||
| 109 | // } | ||
| 110 | // if (applicationInfo == null)return ""; | ||
| 111 | // return applicationInfo.metaData.getString("PROJECT_NAME"); | ||
| 112 | return "paicu"; | ||
| 113 | } | ||
| 114 | |||
| 115 | |||
| 116 | } | ||
| 117 | 1 | package com.prws.common.router; |