├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── maindex-keep.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── res │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── common ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── objectbox-models │ ├── default.json │ └── default.json.bak ├── proguard-rules.pro ├── publish.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── vc │ │ └── wd │ │ └── common │ │ ├── bean │ │ ├── BDResult.java │ │ ├── Banner.java │ │ ├── Circle.java │ │ ├── Result.java │ │ ├── UserInfo.java │ │ └── shop │ │ │ ├── Commodity.java │ │ │ ├── CommodityList.java │ │ │ └── HomeList.java │ │ ├── core │ │ ├── DataCall.java │ │ ├── IWDApplication.java │ │ ├── WDActivity.java │ │ ├── WDApplication.java │ │ ├── WDFragViewModel.java │ │ ├── WDFragment.java │ │ ├── WDListAdpater.java │ │ ├── WDRecyclerAdapter.java │ │ ├── WDViewModel.java │ │ ├── exception │ │ │ └── ApiException.java │ │ └── http │ │ │ ├── IBaiduRequest.java │ │ │ └── NetworkManager.java │ │ └── util │ │ ├── Constant.java │ │ ├── DateUtils.java │ │ ├── FileUtils.java │ │ ├── IOUtils.java │ │ ├── MD5Utils.java │ │ ├── StringUtils.java │ │ ├── UIUtils.java │ │ ├── logger │ │ ├── Logger.java │ │ ├── conf │ │ │ ├── LogConfiger.java │ │ │ └── LogProxyPrinter.java │ │ └── printer │ │ │ ├── ConsolePrinter.java │ │ │ ├── EmptyPrinter.java │ │ │ ├── FileLogPrinter.java │ │ │ ├── FileLogger.java │ │ │ └── LogPrinter.java │ │ ├── recycleview │ │ └── SpacingItemDecoration.java │ │ └── shared │ │ ├── Pair.java │ │ └── SharedUtils.java │ └── res │ ├── layout │ └── base.xml │ └── xml │ └── network_security_config.xml ├── config.gradle ├── debug_mode ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── vc │ │ └── wd │ │ └── debug │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── vc │ │ │ └── wd │ │ │ └── debug │ │ │ ├── activity │ │ │ └── DebugActivity.java │ │ │ ├── core │ │ │ └── DebugApplication.java │ │ │ ├── util │ │ │ └── ClassScannerUtil.java │ │ │ └── vm │ │ │ └── DebugViewModel.java │ └── res │ │ └── layout │ │ └── activity_debug.xml │ └── test │ └── java │ └── com │ └── vc │ └── wd │ └── debug │ └── ExampleUnitTest.java ├── gct ├── commit-template-idea-plugin.jar └── scope.json ├── gradle.properties ├── module.gradle ├── open_im ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── vc │ │ └── wd │ │ └── im │ │ ├── activity │ │ └── ChatActivity.java │ │ └── core │ │ └── IMApplication.java │ └── test │ └── java │ └── com │ └── vc │ └── wd │ └── im │ └── ExampleUnitTest.java ├── open_login ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── vc │ │ │ └── wd │ │ │ └── login │ │ │ ├── activity │ │ │ ├── LoginActivity.java │ │ │ ├── RegisterActivity.java │ │ │ └── WelcomeActivity.java │ │ │ ├── request │ │ │ └── ILoginRequest.java │ │ │ └── vm │ │ │ ├── LoginViewModel.java │ │ │ ├── RegisterViewModel.java │ │ │ └── WelcomeViewModel.java │ └── res │ │ ├── drawable-xhdpi │ │ ├── check_f.png │ │ ├── check_t.png │ │ ├── login_bg.png │ │ ├── login_icon_eye_n.png │ │ ├── login_icon_lock_n.png │ │ ├── login_icon_phone_n.png │ │ └── login_icon_verify_n.png │ │ ├── drawable │ │ ├── login_btn_bg.xml │ │ └── seek_text_bg.xml │ │ ├── layout │ │ ├── activity_login.xml │ │ ├── activity_register.xml │ │ └── activity_welcome.xml │ │ └── values │ │ ├── colors.xml │ │ └── styles.xml │ └── test │ └── AndroidManifest.xml ├── open_main ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── vc │ │ │ └── wd │ │ │ └── main │ │ │ ├── activity │ │ │ ├── AddCircleActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── MainFromViewPagerActivity.java │ │ │ └── SetActivity.java │ │ │ ├── adapter │ │ │ ├── CircleAdpater.java │ │ │ ├── CommodityAdpater.java │ │ │ ├── HomeBannerAdapter.java │ │ │ └── ImageAdapter.java │ │ │ ├── fragment │ │ │ ├── CircleFragment.java │ │ │ ├── HomeFragment.java │ │ │ └── TestFragment.java │ │ │ ├── request │ │ │ └── IMainRequest.java │ │ │ └── vm │ │ │ ├── AddCircleViewModel.java │ │ │ ├── CircleViewModel.java │ │ │ ├── HomeViewModel.java │ │ │ ├── MainFromViewPagerViewModel.java │ │ │ ├── MainViewModel.java │ │ │ ├── SetViewModel.java │ │ │ └── TestViewModel.java │ └── res │ │ ├── drawable-xhdpi │ │ ├── btn_close.png │ │ ├── btn_send.png │ │ ├── common_btn_more_n.png │ │ ├── common_btn_prise_n.png │ │ ├── common_btn_prise_s.png │ │ ├── common_nav_btn_back_n.png │ │ ├── common_nav_btn_menu_n.png │ │ ├── common_nav_btn_search_n.png │ │ ├── common_tab_btn_circle_n.png │ │ ├── common_tab_btn_circle_s.png │ │ ├── common_tab_btn_home_n.png │ │ ├── common_tab_btn_home_s.png │ │ ├── common_tab_btn_list_n.png │ │ ├── common_tab_btn_list_s.png │ │ ├── common_tab_btn_my_n.png │ │ ├── common_tab_btn_my_s.png │ │ ├── common_tab_btn_shop_cart_n.png │ │ ├── main_frag_fashion_bg.png │ │ ├── main_frag_hot_bg.png │ │ ├── main_frag_life_bg.png │ │ └── mask_01.png │ │ ├── drawable │ │ ├── common_tab_btn_circle.xml │ │ ├── common_tab_btn_home.xml │ │ ├── common_tab_btn_list.xml │ │ ├── common_tab_btn_my.xml │ │ ├── ic_launcher_background.xml │ │ ├── item_layer_shadow.xml │ │ └── rectangle.9.png │ │ ├── layout │ │ ├── activity_add_circle.xml │ │ ├── activity_main.xml │ │ ├── activity_main_view_pager.xml │ │ ├── activity_set.xml │ │ ├── banner_item.xml │ │ ├── circle_image_item.xml │ │ ├── circle_item.xml │ │ ├── fashion_item.xml │ │ ├── frag_circle.xml │ │ ├── frag_main.xml │ │ ├── frag_test.xml │ │ └── hot_item.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── AndroidManifest.xml ├── open_push ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── vc │ └── wd │ └── push │ ├── core │ └── PushApplication.java │ └── receiver │ └── MyReceiver.java ├── open_user ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── vc │ │ └── wd │ │ └── user │ │ ├── fragment │ │ └── MeFragment.java │ │ └── vm │ │ └── UserViewModel.java │ └── res │ ├── drawable-xhdpi │ ├── btn_close.png │ ├── btn_send.png │ ├── main_frag_fashion_bg.png │ ├── main_frag_hot_bg.png │ ├── main_frag_life_bg.png │ ├── mask_01.png │ ├── my_icon_address_n.png │ ├── my_icon_circle_n.png │ ├── my_icon_foot_n.png │ ├── my_icon_information_n.png │ └── my_icon_wallet_n.png │ ├── drawable │ └── my_card_bg.xml │ ├── layout │ └── frag_me.xml │ └── values │ ├── colors.xml │ └── dimens.xml ├── repo └── com │ └── github │ └── VcStrong │ └── ConstantPlugin │ ├── 0.0.1 │ ├── ConstantPlugin-0.0.1.jar │ ├── ConstantPlugin-0.0.1.jar.md5 │ ├── ConstantPlugin-0.0.1.jar.sha1 │ ├── ConstantPlugin-0.0.1.pom │ ├── ConstantPlugin-0.0.1.pom.md5 │ └── ConstantPlugin-0.0.1.pom.sha1 │ ├── maven-metadata.xml │ ├── maven-metadata.xml.md5 │ └── maven-metadata.xml.sha1 └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | /app/objectbox-models/default.json 16 | /app/objectbox-models/default.json.bak 17 | /.idea/gradle.xml 18 | /gradle/wrapper/gradle-wrapper.jar 19 | /gradle/wrapper/gradle-wrapper.properties 20 | /gradlew 21 | /gradlew.bat 22 | /.idea/misc.xml 23 | /.idea/codeStyles/Project.xml 24 | /.idea/runConfigurations.xml 25 | /.idea/vcs.xml 26 | /.idea/jarRepositories.xml 27 | /.idea/ 28 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | signingConfigs { 5 | } 6 | compileSdkVersion SDK_VERSION.compileSdkVersion 7 | defaultConfig { 8 | applicationId active.applicationId 9 | minSdkVersion SDK_VERSION.minSdkVersion 10 | targetSdkVersion SDK_VERSION.targetSdkVersion 11 | versionCode active.versionCode 12 | versionName active.versionName 13 | 14 | //上面注释 15 | manifestPlaceholders = [ 16 | appName : active.appName 17 | ] 18 | 19 | javaCompileOptions { 20 | annotationProcessorOptions { 21 | arguments = [AROUTER_MODULE_NAME: project.getName()] 22 | } 23 | } 24 | 25 | // Enabling multidex support. 26 | multiDexEnabled true 27 | multiDexKeepProguard file('maindex-keep.pro') 28 | } 29 | buildTypes { 30 | release { 31 | minifyEnabled false 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 33 | } 34 | } 35 | buildFeatures{ 36 | dataBinding = true 37 | } 38 | compileOptions { 39 | sourceCompatibility = 1.8 40 | targetCompatibility = 1.8 41 | } 42 | lintOptions { 43 | abortOnError false 44 | } 45 | } 46 | 47 | dependencies { 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/maindex-keep.pro: -------------------------------------------------------------------------------- 1 | -keep class com.vc.wd.common.core.WDApplication -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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 | 4 | buildscript { 5 | repositories { 6 | google() 7 | jcenter() 8 | maven{ url 'https://maven.aliyun.com/repository/jcenter'} 9 | maven{ url 'https://maven.aliyun.com/repository/google'} 10 | maven { url 'https://jitpack.io' } 11 | maven { 12 | url uri('repo') 13 | } 14 | } 15 | dependencies { 16 | classpath 'com.android.tools.build:gradle:4.0.0' 17 | classpath "io.objectbox:objectbox-gradle-plugin:2.9.1" 18 | classpath 'com.github.VcStrong:ConstantPlugin:0.0.1' 19 | // NOTE: Do not place your application dependencies here; they belong 20 | // in the individual module build.gradle files 21 | } 22 | } 23 | 24 | allprojects { 25 | repositories { 26 | google() 27 | jcenter() 28 | maven{ url 'https://maven.aliyun.com/repository/jcenter'} 29 | maven{ url 'https://maven.aliyun.com/repository/google'} 30 | maven { url 'https://jitpack.io' } 31 | maven { 32 | url uri('repo') 33 | } 34 | } 35 | } 36 | 37 | task clean(type: Delete) { 38 | delete rootProject.buildDir 39 | } 40 | def modules = getSubprojects() 41 | //def modules = getAllprojects() 42 | // app 是主工程模块名,组件化打包,如果后续使用了拆分aar后,可视情况删除,参考README.md中的日志说明 43 | project('app') { p -> 44 | p.afterEvaluate { 45 | println "===============================================================" 46 | println "打包分支:"+active.branch + " 包名:" +active.applicationId + " 版本:" + active.versionName 47 | println "===============================================================" 48 | modules.each() { module -> 49 | if (!ignorePackage.contains(module.name)) { 50 | if (allPackage) {//所有模块都打包 51 | if (module != p) { 52 | println p.name + "全功能打包,已添加模块:" + module.name 53 | p.dependencies.add("implementation", project(':' + module.name)) 54 | 55 | } else { 56 | println p.name + "全模块打包,重复或者不添加的模块:" + module.name 57 | } 58 | } else { 59 | if (needPackage.contains(module.name)) { 60 | if (module != p) { 61 | println p.name + "组件化打包,清单文件默认采用src/test/AndroidManifest.xml...加载模块:" + module.name 62 | p.dependencies.add("implementation", project(':' + module.name)) 63 | } 64 | } 65 | } 66 | } 67 | } 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /common/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /common/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | // 发布到本地测试用 3 | apply from: 'publish.gradle' 4 | 5 | android { 6 | compileSdkVersion SDK_VERSION.compileSdkVersion 7 | defaultConfig { 8 | minSdkVersion SDK_VERSION.minSdkVersion 9 | targetSdkVersion SDK_VERSION.targetSdkVersion 10 | versionCode active.versionCode 11 | versionName active.versionName 12 | 13 | buildConfigField('String',"SERVER_URL","\"${active.serverUrl}\"") 14 | buildConfigField('String',"BAIDU_URL","\"${active.baiduUrl}\"") 15 | 16 | javaCompileOptions { 17 | annotationProcessorOptions { 18 | arguments = [AROUTER_MODULE_NAME: project.getName()] 19 | } 20 | } 21 | ndk { 22 | abiFilters 'armeabi', 'armeabi-v7a' 23 | } 24 | } 25 | buildFeatures{ 26 | dataBinding = true 27 | } 28 | 29 | buildTypes { 30 | release { 31 | minifyEnabled false 32 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 33 | } 34 | } 35 | compileOptions { 36 | sourceCompatibility = 1.8 37 | targetCompatibility = 1.8 38 | } 39 | 40 | } 41 | 42 | dependencies { 43 | api fileTree(dir: 'libs', include: ['*.jar']) 44 | testImplementation 'junit:junit:4.13.2' 45 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 46 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 47 | 48 | api 'androidx.appcompat:appcompat:1.1.0' 49 | api 'com.google.android.material:material:1.1.0' 50 | api 'androidx.recyclerview:recyclerview:1.0.0' 51 | api 'androidx.constraintlayout:constraintlayout:1.1.3' 52 | 53 | //今日头条-抖音团队multidex打包 54 | api 'com.bytedance.boost_multidex:boost_multidex:1.0.0' 55 | 56 | def lifecycle_version = "2.2.0" 57 | // ViewModel 58 | api "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version" 59 | // LiveData 60 | api "androidx.lifecycle:lifecycle-livedata:$lifecycle_version" 61 | // Lifecycles only (without ViewModel or LiveData) 62 | api "androidx.lifecycle:lifecycle-runtime:$lifecycle_version" 63 | 64 | //OKhttp+Retrofit+rxjava 65 | api 'com.squareup.retrofit2:converter-gson:2.5.0' 66 | api 'com.squareup.retrofit2:retrofit:2.5.0' 67 | api 'com.squareup.okhttp3:okhttp:3.12.1' 68 | api 'com.squareup.retrofit2:adapter-rxjava2:2.5.0' 69 | api 'com.squareup.okhttp3:logging-interceptor:3.12.1' 70 | api 'io.reactivex.rxjava2:rxjava:2.2.4' 71 | api 'io.reactivex.rxjava2:rxandroid:2.1.0' 72 | 73 | //arouter 74 | api 'com.alibaba:arouter-api:1.5.2' 75 | annotationProcessor 'com.alibaba:arouter-compiler:1.5.2' 76 | 77 | api 'com.youth.banner:banner:2.0.10' 78 | api 'com.facebook.fresco:fresco:1.11.0' 79 | api 'com.jcodecraeer:xrecyclerview:1.5.9' 80 | //objectbox数据库 81 | debugApi "io.objectbox:objectbox-android-objectbrowser:2.9.1" 82 | releaseApi "io.objectbox:objectbox-android:2.9.1" 83 | 84 | api 'com.github.tbruyelle:rxpermissions:0.10.2' 85 | //工具类 86 | api 'com.blankj:utilcodex:1.30.5' 87 | } 88 | 89 | apply plugin: 'io.objectbox' 90 | -------------------------------------------------------------------------------- /common/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/common/consumer-rules.pro -------------------------------------------------------------------------------- /common/objectbox-models/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.", 3 | "_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.", 4 | "_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.", 5 | "entities": [ 6 | { 7 | "id": "1:1918397186535782234", 8 | "lastPropertyId": "7:6650086664334351878", 9 | "name": "UserInfo", 10 | "properties": [ 11 | { 12 | "id": "1:7783833741321903654", 13 | "name": "userId", 14 | "type": 6, 15 | "flags": 129 16 | }, 17 | { 18 | "id": "2:8550969369029858886", 19 | "name": "headPic", 20 | "type": 9 21 | }, 22 | { 23 | "id": "3:4036532479939442171", 24 | "name": "nickName", 25 | "type": 9 26 | }, 27 | { 28 | "id": "4:5803427497069305798", 29 | "name": "phone", 30 | "type": 9 31 | }, 32 | { 33 | "id": "5:6729286553698975268", 34 | "name": "sessionId", 35 | "type": 9 36 | }, 37 | { 38 | "id": "6:4995037162595156469", 39 | "name": "sex", 40 | "type": 5, 41 | "flags": 4 42 | }, 43 | { 44 | "id": "7:6650086664334351878", 45 | "name": "status", 46 | "type": 5, 47 | "flags": 4 48 | } 49 | ], 50 | "relations": [] 51 | }, 52 | { 53 | "id": "3:2555095662947319643", 54 | "lastPropertyId": "3:6553837661032666887", 55 | "name": "Pair", 56 | "properties": [ 57 | { 58 | "id": "1:7104475480958847922", 59 | "name": "id", 60 | "type": 6, 61 | "flags": 1 62 | }, 63 | { 64 | "id": "2:3939458337398694284", 65 | "name": "key", 66 | "indexId": "2:6891132687101871970", 67 | "type": 9, 68 | "flags": 2080 69 | }, 70 | { 71 | "id": "3:6553837661032666887", 72 | "name": "value", 73 | "type": 9 74 | } 75 | ], 76 | "relations": [] 77 | } 78 | ], 79 | "lastEntityId": "3:2555095662947319643", 80 | "lastIndexId": "2:6891132687101871970", 81 | "lastRelationId": "0:0", 82 | "lastSequenceId": "0:0", 83 | "modelVersion": 5, 84 | "modelVersionParserMinimum": 5, 85 | "retiredEntityUids": [ 86 | 4287601921541255177 87 | ], 88 | "retiredIndexUids": [ 89 | 2461321783639467485 90 | ], 91 | "retiredPropertyUids": [ 92 | 4980491960036424469, 93 | 3910612852395587482, 94 | 5412320459890006894 95 | ], 96 | "retiredRelationUids": [], 97 | "version": 1 98 | } -------------------------------------------------------------------------------- /common/objectbox-models/default.json.bak: -------------------------------------------------------------------------------- 1 | { 2 | "_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.", 3 | "_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.", 4 | "_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.", 5 | "entities": [ 6 | { 7 | "id": "1:1918397186535782234", 8 | "lastPropertyId": "7:6650086664334351878", 9 | "name": "UserInfo", 10 | "properties": [ 11 | { 12 | "id": "1:7783833741321903654", 13 | "name": "userId", 14 | "type": 6, 15 | "flags": 129 16 | }, 17 | { 18 | "id": "2:8550969369029858886", 19 | "name": "headPic", 20 | "type": 9 21 | }, 22 | { 23 | "id": "3:4036532479939442171", 24 | "name": "nickName", 25 | "type": 9 26 | }, 27 | { 28 | "id": "4:5803427497069305798", 29 | "name": "phone", 30 | "type": 9 31 | }, 32 | { 33 | "id": "5:6729286553698975268", 34 | "name": "sessionId", 35 | "type": 9 36 | }, 37 | { 38 | "id": "6:4995037162595156469", 39 | "name": "sex", 40 | "type": 5, 41 | "flags": 4 42 | }, 43 | { 44 | "id": "7:6650086664334351878", 45 | "name": "status", 46 | "type": 5, 47 | "flags": 4 48 | } 49 | ], 50 | "relations": [] 51 | }, 52 | { 53 | "id": "3:2555095662947319643", 54 | "lastPropertyId": "3:6553837661032666887", 55 | "name": "Pair", 56 | "properties": [ 57 | { 58 | "id": "1:7104475480958847922", 59 | "name": "id", 60 | "type": 6, 61 | "flags": 1 62 | }, 63 | { 64 | "id": "2:3939458337398694284", 65 | "name": "key", 66 | "type": 9 67 | }, 68 | { 69 | "id": "3:6553837661032666887", 70 | "name": "value", 71 | "type": 9 72 | } 73 | ], 74 | "relations": [] 75 | } 76 | ], 77 | "lastEntityId": "3:2555095662947319643", 78 | "lastIndexId": "1:2461321783639467485", 79 | "lastRelationId": "0:0", 80 | "lastSequenceId": "0:0", 81 | "modelVersion": 5, 82 | "modelVersionParserMinimum": 5, 83 | "retiredEntityUids": [ 84 | 4287601921541255177 85 | ], 86 | "retiredIndexUids": [ 87 | 2461321783639467485 88 | ], 89 | "retiredPropertyUids": [ 90 | 4980491960036424469, 91 | 3910612852395587482, 92 | 5412320459890006894 93 | ], 94 | "retiredRelationUids": [], 95 | "version": 1 96 | } -------------------------------------------------------------------------------- /common/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 | -------------------------------------------------------------------------------- /common/publish.gradle: -------------------------------------------------------------------------------- 1 | //发布本地或者远程服务器等脚本都放在此类中 2 | apply plugin: 'maven' 3 | 4 | uploadArchives { 5 | repositories { 6 | mavenDeployer { 7 | // 发布到本地路径进行测试 8 | repository(url:uri('../repo')) 9 | pom.groupId = active.applicationId //groupId ,自行定义,一般是包名 10 | pom.artifactId = 'common' //artifactId ,自行定义 11 | pom.version = 'latest' //version 版本号 12 | } 13 | } 14 | doLast { 15 | // 删除生成的build/lib文件夹 16 | delete libsDirName 17 | } 18 | } -------------------------------------------------------------------------------- /common/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/bean/BDResult.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.bean; 2 | 3 | /** 4 | * desc 5 | * author VcStrong 6 | * github VcStrong 7 | * date 2020/5/28 1:42 PM 8 | */ 9 | public class BDResult { 10 | int code; 11 | String msg; 12 | T data; 13 | 14 | public int getCode() { 15 | return code; 16 | } 17 | 18 | public void setCode(int code) { 19 | this.code = code; 20 | } 21 | 22 | public String getMsg() { 23 | return msg; 24 | } 25 | 26 | public void setMsg(String msg) { 27 | this.msg = msg; 28 | } 29 | 30 | public T getData() { 31 | return data; 32 | } 33 | 34 | public void setData(T data) { 35 | this.data = data; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/bean/Banner.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.bean; 2 | 3 | /** 4 | * desc 5 | * author VcStrong 6 | * github VcStrong 7 | * date 2020/5/28 1:42 PM 8 | */ 9 | public class Banner { 10 | String imageUrl; 11 | String jumpUrl; 12 | int rank; 13 | String title; 14 | 15 | public String getImageUrl() { 16 | return imageUrl; 17 | } 18 | 19 | public void setImageUrl(String imageUrl) { 20 | this.imageUrl = imageUrl; 21 | } 22 | 23 | public String getJumpUrl() { 24 | return jumpUrl; 25 | } 26 | 27 | public void setJumpUrl(String jumpUrl) { 28 | this.jumpUrl = jumpUrl; 29 | } 30 | 31 | public int getRank() { 32 | return rank; 33 | } 34 | 35 | public void setRank(int rank) { 36 | this.rank = rank; 37 | } 38 | 39 | public String getTitle() { 40 | return title; 41 | } 42 | 43 | public void setTitle(String title) { 44 | this.title = title; } 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/bean/Circle.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.bean; 2 | 3 | /** 4 | * desc 5 | * author VcStrong 6 | * github VcStrong 7 | * date 2020/5/28 1:42 PM 8 | */ 9 | public class Circle { 10 | long id; 11 | long userId; 12 | String nickName; 13 | String headPic; 14 | long commodityId; 15 | String content; 16 | String image; 17 | int whetherGreat;//当前登录用户是否点赞(2为否,1为是) 18 | int greatNum; 19 | long createTime; 20 | 21 | public long getId() { 22 | return id; 23 | } 24 | 25 | public void setId(long id) { 26 | this.id = id; 27 | } 28 | 29 | public long getUserId() { 30 | return userId; 31 | } 32 | 33 | public void setUserId(long userId) { 34 | this.userId = userId; 35 | } 36 | 37 | public String getNickName() { 38 | return nickName; 39 | } 40 | 41 | public void setNickName(String nickName) { 42 | this.nickName = nickName; 43 | } 44 | 45 | public String getHeadPic() { 46 | return headPic; 47 | } 48 | 49 | public void setHeadPic(String headPic) { 50 | this.headPic = headPic; 51 | } 52 | 53 | public long getCommodityId() { 54 | return commodityId; 55 | } 56 | 57 | public void setCommodityId(long commodityId) { 58 | this.commodityId = commodityId; 59 | } 60 | 61 | public String getContent() { 62 | return content; 63 | } 64 | 65 | public void setContent(String content) { 66 | this.content = content; 67 | } 68 | 69 | public String getImage() { 70 | return image; 71 | } 72 | 73 | public void setImage(String image) { 74 | this.image = image; 75 | } 76 | 77 | public int getWhetherGreat() { 78 | return whetherGreat; 79 | } 80 | 81 | public void setWhetherGreat(int whetherGreat) { 82 | this.whetherGreat = whetherGreat; 83 | } 84 | 85 | public int getGreatNum() { 86 | return greatNum; 87 | } 88 | 89 | public void setGreatNum(int greatNum) { 90 | this.greatNum = greatNum; 91 | } 92 | 93 | public long getCreateTime() { 94 | return createTime; 95 | } 96 | 97 | public void setCreateTime(long createTime) { 98 | this.createTime = createTime; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/bean/Result.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.bean; 2 | 3 | /** 4 | * desc 5 | * author VcStrong 6 | * github VcStrong 7 | * date 2020/5/28 1:42 PM 8 | */ 9 | public class Result { 10 | String status; 11 | String message; 12 | T result; 13 | String headPath; 14 | 15 | public Result(String status, String message) { 16 | this.status = status; 17 | this.message = message; 18 | } 19 | 20 | public String getStatus() { 21 | return status; 22 | } 23 | 24 | public void setStatus(String status) { 25 | this.status = status; 26 | } 27 | 28 | public String getMessage() { 29 | return message; 30 | } 31 | 32 | public void setMessage(String message) { 33 | this.message = message; 34 | } 35 | 36 | public T getResult() { 37 | return result; 38 | } 39 | 40 | public void setResult(T result) { 41 | this.result = result; 42 | } 43 | 44 | public String getHeadPath() { 45 | return headPath; 46 | } 47 | 48 | public void setHeadPath(String headPath) { 49 | this.headPath = headPath; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/bean/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.bean; 2 | 3 | import io.objectbox.annotation.Entity; 4 | import io.objectbox.annotation.Id; 5 | 6 | /** 7 | * desc 8 | * author VcStrong 9 | * github VcStrong 10 | * date 2020/5/28 1:42 PM 11 | */ 12 | @Entity 13 | public class UserInfo { 14 | //as-signable:允许使用其他地方分配的ID,默认false代表objectbox自动生成 15 | @Id(assignable = true) 16 | long userId; 17 | String headPic; 18 | String nickName; 19 | String phone; 20 | String sessionId; 21 | int sex; 22 | 23 | int status;//记录本地用户登录状态,用于直接登录和退出,1:登录,0:未登录或退出 24 | 25 | public UserInfo(long userId, String headPic, String nickName, String phone, 26 | String sessionId, int sex, int status) { 27 | this.userId = userId; 28 | this.headPic = headPic; 29 | this.nickName = nickName; 30 | this.phone = phone; 31 | this.sessionId = sessionId; 32 | this.sex = sex; 33 | this.status = status; 34 | } 35 | 36 | public UserInfo() { 37 | } 38 | 39 | public long getUserId() { 40 | return this.userId; 41 | } 42 | 43 | public void setUserId(long userId) { 44 | this.userId = userId; 45 | } 46 | 47 | public String getHeadPic() { 48 | return this.headPic; 49 | } 50 | 51 | public void setHeadPic(String headPic) { 52 | this.headPic = headPic; 53 | } 54 | 55 | public String getNickName() { 56 | return this.nickName; 57 | } 58 | 59 | public void setNickName(String nickName) { 60 | this.nickName = nickName; 61 | } 62 | 63 | public String getPhone() { 64 | return this.phone; 65 | } 66 | 67 | public void setPhone(String phone) { 68 | this.phone = phone; 69 | } 70 | 71 | public String getSessionId() { 72 | return this.sessionId; 73 | } 74 | 75 | public void setSessionId(String sessionId) { 76 | this.sessionId = sessionId; 77 | } 78 | 79 | public int getSex() { 80 | return this.sex; 81 | } 82 | 83 | public void setSex(int sex) { 84 | this.sex = sex; 85 | } 86 | 87 | public int getStatus() { 88 | return this.status; 89 | } 90 | 91 | public void setStatus(int status) { 92 | this.status = status; 93 | } 94 | 95 | 96 | } 97 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/bean/shop/Commodity.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.bean.shop; 2 | 3 | /** 4 | * desc 5 | * author VcStrong 6 | * github VcStrong 7 | * date 2020/5/28 1:42 PM 8 | */ 9 | public class Commodity { 10 | long commodityId; 11 | String commodityName; 12 | String masterPic; 13 | double price; 14 | int saleNum; 15 | 16 | public long getCommodityId() { 17 | return commodityId; 18 | } 19 | 20 | public void setCommodityId(long commodityId) { 21 | this.commodityId = commodityId; 22 | } 23 | 24 | public String getCommodityName() { 25 | return commodityName; 26 | } 27 | 28 | public void setCommodityName(String commodityName) { 29 | this.commodityName = commodityName; 30 | } 31 | 32 | public String getMasterPic() { 33 | return masterPic; 34 | } 35 | 36 | public void setMasterPic(String masterPic) { 37 | this.masterPic = masterPic; 38 | } 39 | 40 | public double getPrice() { 41 | return price; 42 | } 43 | 44 | public void setPrice(double price) { 45 | this.price = price; 46 | } 47 | 48 | public int getSaleNum() { 49 | return saleNum; 50 | } 51 | 52 | public void setSaleNum(int saleNum) { 53 | this.saleNum = saleNum; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/bean/shop/CommodityList.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.bean.shop; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * desc 7 | * author VcStrong 8 | * github VcStrong 9 | * date 2020/5/28 1:42 PM 10 | */ 11 | public class CommodityList { 12 | 13 | List commodityList; 14 | long id; 15 | String name; 16 | 17 | public List getCommodityList() { 18 | return commodityList; 19 | } 20 | 21 | public void setCommodityList(List commodityList) { 22 | this.commodityList = commodityList; 23 | } 24 | 25 | public long getId() { 26 | return id; 27 | } 28 | 29 | public void setId(long id) { 30 | this.id = id; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/bean/shop/HomeList.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.bean.shop; 2 | 3 | /** 4 | * desc 5 | * author VcStrong 6 | * github VcStrong 7 | * date 2020/5/28 1:42 PM 8 | */ 9 | public class HomeList { 10 | CommodityList rxxp; 11 | CommodityList mlss; 12 | CommodityList pzsh; 13 | 14 | public CommodityList getRxxp() { 15 | return rxxp; 16 | } 17 | 18 | public void setRxxp(CommodityList rxxp) { 19 | this.rxxp = rxxp; 20 | } 21 | 22 | public CommodityList getMlss() { 23 | return mlss; 24 | } 25 | 26 | public void setMlss(CommodityList mlss) { 27 | this.mlss = mlss; 28 | } 29 | 30 | public CommodityList getPzsh() { 31 | return pzsh; 32 | } 33 | 34 | public void setPzsh(CommodityList pzsh) { 35 | this.pzsh = pzsh; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/core/DataCall.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.core; 2 | 3 | 4 | import com.vc.wd.common.core.exception.ApiException; 5 | 6 | /** 7 | * desc 8 | * author VcStrong 9 | * github VcStrong 10 | * date 2020/5/28 1:42 PM 11 | */ 12 | public interface DataCall { 13 | 14 | void success(T data); 15 | void fail(ApiException data); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/core/IWDApplication.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.core; 2 | 3 | import android.app.Application; 4 | 5 | /** 6 | * desc 支持多个Module—Application共存,方便处理推送,IM等组件初始化问题; 7 | * 用法:module模块自定义的Application实现这个接口,然后把实现类的包名+类名写在下方常量中。 8 | * 加载过程:打开WDApplication代码,使用反射进行各个*Application的初始化 9 | * author VcStrong 10 | * github VcStrong 11 | * date 2020/5/28 2:27 PM 12 | */ 13 | public interface IWDApplication { 14 | String[] MODULE_APP= new String[]{ 15 | "com.vc.wd.push.core.PushApplication", 16 | "com.vc.wd.im.core.IMApplication", 17 | "com.vc.wd.debug.core.DebugApplication" 18 | }; 19 | void onCreate(Application application); 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/core/WDListAdpater.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.core; 2 | 3 | import android.view.View; 4 | import android.view.ViewGroup; 5 | import android.widget.BaseAdapter; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * desc 12 | * author VcStrong 13 | * github VcStrong 14 | * date 2020/5/28 1:42 PM 15 | */ 16 | public abstract class WDListAdpater extends BaseAdapter { 17 | 18 | List mList = new ArrayList<>(); 19 | 20 | @Override 21 | public int getCount() { 22 | return mList.size(); 23 | } 24 | 25 | @Override 26 | public T getItem(int position) { 27 | return mList.get(position); 28 | } 29 | 30 | @Override 31 | public long getItemId(int position) { 32 | return position; 33 | } 34 | 35 | @Override 36 | public View getView(int position, View convertView, ViewGroup parent) { 37 | MH mh; 38 | if (convertView==null){ 39 | convertView = View.inflate(parent.getContext(),getLayoutId(),null); 40 | mh = creatHolder(convertView); 41 | convertView.setTag(mh); 42 | }else{ 43 | mh = (MH) convertView.getTag(); 44 | } 45 | bindItemView(mh,position); 46 | return convertView; 47 | } 48 | 49 | protected abstract void bindItemView(MH mh,int position); 50 | 51 | public abstract int getLayoutId(); 52 | 53 | public abstract class Hodler{ 54 | public View itemView; 55 | public Hodler(View itemView){ 56 | this.itemView = itemView; 57 | } 58 | } 59 | 60 | public abstract MH creatHolder(View view); 61 | 62 | } 63 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/core/WDRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.core; 2 | 3 | import android.view.LayoutInflater; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.databinding.DataBindingUtil; 9 | import androidx.databinding.ViewDataBinding; 10 | import androidx.recyclerview.widget.RecyclerView; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * desc 17 | * author VcStrong 18 | * github VcStrong 19 | * date 2020/5/28 1:42 PM 20 | */ 21 | public abstract class WDRecyclerAdapter extends RecyclerView.Adapter { 22 | 23 | protected List mList = new ArrayList<>(); 24 | 25 | public void addAll(List list) { 26 | if (list != null) 27 | mList.addAll(list); 28 | } 29 | 30 | public void clear() { 31 | mList.clear(); 32 | } 33 | 34 | public void add(T item) { 35 | if (item != null) { 36 | mList.add(item); 37 | } 38 | } 39 | 40 | public T getItem(int position){ 41 | return mList.get(position); 42 | } 43 | 44 | public void remove(T item){ 45 | mList.remove(item); 46 | } 47 | 48 | @NonNull 49 | @Override 50 | public MyHodler onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 51 | ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), getLayoutId(), 52 | parent, false); 53 | initBindingField(parent,binding); 54 | return new MyHodler(binding.getRoot()); 55 | } 56 | 57 | protected void initBindingField(ViewGroup parent,ViewDataBinding binding){} 58 | 59 | protected abstract int getLayoutId(); 60 | 61 | @Override 62 | public void onBindViewHolder(@NonNull MyHodler holder, int position) { 63 | bindView(DataBindingUtil.bind(holder.itemView),getItem(position), position); 64 | } 65 | 66 | protected abstract void bindView(ViewDataBinding binding,T item, int position); 67 | 68 | 69 | public List getList() { 70 | return mList; 71 | } 72 | 73 | @Override 74 | public int getItemCount() { 75 | return mList.size(); 76 | } 77 | 78 | public static class MyHodler extends RecyclerView.ViewHolder { 79 | public MyHodler(@NonNull View itemView) { 80 | super(itemView); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/core/exception/ApiException.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.core.exception; 2 | 3 | import android.net.ParseException; 4 | 5 | import com.google.gson.JsonParseException; 6 | 7 | import org.json.JSONException; 8 | 9 | import java.net.ConnectException; 10 | import java.net.SocketTimeoutException; 11 | import java.net.UnknownHostException; 12 | 13 | /** 14 | * desc 封装了自定义的异常,页面拿着我的异常做出友好提示 15 | * author VcStrong 16 | * github VcStrong 17 | * date 2019/1/2 7:01 PM 18 | */ 19 | public class ApiException extends Exception { 20 | private String code;// 21 | private String displayMessage;//提示的消息 22 | 23 | /** 24 | * 未知错误 25 | */ 26 | public static final String UNKNOWN = "1000"; 27 | 28 | /** 29 | * 解析错误 30 | */ 31 | public static final String PARSE_ERROR = "1001"; 32 | 33 | /** 34 | * 网络错误 35 | */ 36 | public static final String NETWORK_ERROR = "1002"; 37 | 38 | /** 39 | * 协议错误 40 | */ 41 | public static final String HTTP_ERROR = "1003"; 42 | 43 | 44 | public ApiException(String code, String displayMessage) { 45 | this.code = code; 46 | this.displayMessage = displayMessage; 47 | } 48 | 49 | public ApiException(String code, String message, String displayMessage) { 50 | super(message); 51 | this.code = code; 52 | this.displayMessage = displayMessage; 53 | } 54 | 55 | /** 56 | * 处理系统异常,封装成ApiException 57 | * Throwable包含Error和Exception 58 | */ 59 | public static ApiException handleException(Throwable e) { 60 | 61 | e.printStackTrace();//打印异常 62 | 63 | ApiException ex; 64 | if (e instanceof JsonParseException 65 | || e instanceof JSONException 66 | || e instanceof ParseException) { 67 | //解析错误 68 | ex = new ApiException(PARSE_ERROR, "解析异常"); 69 | return ex; 70 | } else if (e instanceof ConnectException || e instanceof UnknownHostException || e instanceof SocketTimeoutException) { 71 | //网络错误 72 | ex = new ApiException(NETWORK_ERROR, e.getMessage()); 73 | return ex; 74 | } else { 75 | //未知错误 76 | ex = new ApiException(UNKNOWN, e.getMessage()); 77 | return ex; 78 | } 79 | } 80 | 81 | public String getCode() { 82 | return code; 83 | } 84 | 85 | public void setCode(String code) { 86 | this.code = code; 87 | } 88 | 89 | public String getDisplayMessage() { 90 | return displayMessage; 91 | } 92 | 93 | public void setDisplayMessage(String displayMessage) { 94 | this.displayMessage = displayMessage; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/core/http/IBaiduRequest.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.core.http; 2 | 3 | /** 4 | * desc 建议放到相关的module中,不建议在common包中写接口 5 | * author VcStrong 6 | * github VcStrong 7 | * date 2020/5/28 1:42 PM 8 | */ 9 | public interface IBaiduRequest { 10 | } 11 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/core/http/NetworkManager.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.core.http; 2 | 3 | 4 | import com.google.gson.Gson; 5 | import com.vc.wd.common.BuildConfig; 6 | import com.vc.wd.common.core.WDViewModel; 7 | 8 | import org.json.JSONException; 9 | import org.json.JSONObject; 10 | 11 | import java.util.concurrent.TimeUnit; 12 | 13 | import okhttp3.MediaType; 14 | import okhttp3.OkHttpClient; 15 | import okhttp3.RequestBody; 16 | import okhttp3.logging.HttpLoggingInterceptor; 17 | import retrofit2.Retrofit; 18 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 19 | import retrofit2.converter.gson.GsonConverterFactory; 20 | 21 | /** 22 | * desc 23 | * author VcStrong 24 | * github VcStrong 25 | * date 2020/5/28 1:42 PM 26 | */ 27 | public class NetworkManager { 28 | 29 | private static Gson gson = new Gson(); 30 | private static NetworkManager instance; 31 | 32 | //这个是模仿应用多模块采用不同的域名,域名配置参见config.gradle 33 | private Retrofit app_retrofit, baidu_retrofit; 34 | 35 | private NetworkManager() { 36 | init(); 37 | } 38 | 39 | public static NetworkManager instance() { 40 | if (instance == null) { 41 | instance = new NetworkManager(); 42 | } 43 | return instance; 44 | } 45 | 46 | private void init() { 47 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); 48 | interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);//打印请求参数,请求结果 49 | 50 | //OKHttp最大同时请求5个不同域名 51 | OkHttpClient okHttpClient = new OkHttpClient.Builder() 52 | .addInterceptor(interceptor) 53 | .connectTimeout(5, TimeUnit.SECONDS) 54 | .writeTimeout(5, TimeUnit.SECONDS) 55 | .readTimeout(5, TimeUnit.SECONDS) 56 | .build(); 57 | 58 | //这个是模仿应用多模块采用不同的域名,域名配置参见config.gradle 59 | app_retrofit = new Retrofit.Builder() 60 | .client(okHttpClient) 61 | .baseUrl(BuildConfig.SERVER_URL)//base_url:http+域名 62 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())//使用Rxjava对回调数据进行处理 63 | .addConverterFactory(GsonConverterFactory.create())//响应结果的解析器,包含gson,xml,protobuf 64 | .build(); 65 | 66 | //这个是模仿应用多模块采用不同的域名,域名配置参见config.gradle 67 | baidu_retrofit = new Retrofit.Builder() 68 | .client(okHttpClient) 69 | .baseUrl(BuildConfig.BAIDU_URL)//base_url:http+域名 70 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())//使用Rxjava对回调数据进行处理 71 | .addConverterFactory(GsonConverterFactory.create())//响应结果的解析器,包含gson,xml,protobuf 72 | .build(); 73 | } 74 | 75 | public T create(int requestType, final Class service) { 76 | if (requestType == WDViewModel.REQUEST_TYPE_SDK_BD) {//如果请求百度SDK的接口 77 | return baidu_retrofit.create(service); 78 | } 79 | return app_retrofit.create(service); 80 | } 81 | 82 | /** 83 | * 把传递数据转为json格式,返回RequestBody 84 | * 85 | * @param keys 请求参数 86 | * @param values 数据 87 | * @return 88 | */ 89 | public static RequestBody convertJsonBody(String[] keys, Object[] values) { 90 | JSONObject json = new JSONObject(); 91 | 92 | for (int i = 0; i < keys.length; i++) { 93 | String key = keys[i]; 94 | Object value = values[i]; 95 | try {//减小数据中某一项对于所有数据的影响 96 | json.put(key, value); 97 | } catch (JSONException e) { 98 | e.printStackTrace(); 99 | } 100 | } 101 | RequestBody body = RequestBody.create(MediaType.parse("application/json"), json.toString()); 102 | return body; 103 | } 104 | 105 | /** 106 | * 把传递数据转为json格式,返回RequestBody 107 | * 108 | * @param obj 数据 109 | * @return 110 | */ 111 | public static RequestBody convertJsonBody(Object obj) { 112 | RequestBody body = RequestBody.create(MediaType.parse("application/json"), gson.toJson(obj)); 113 | return body; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/Constant.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util; 2 | 3 | /** 4 | * desc 5 | * author VcStrong 6 | * github VcStrong 7 | * date 2020/5/28 1:42 PM 8 | */ 9 | public class Constant { 10 | //-----------open_login------------- 11 | public final static String ACTIVITY_URL_LOGIN = "/login/LoginActivity"; 12 | public final static String ACTIVITY_URL_REGISTER = "/login/RegisterActivity"; 13 | public final static String ACTIVITY_URL_WELCOME = "/login/WelcomeActivity"; 14 | 15 | 16 | //-----------open_login------------- 17 | 18 | 19 | //-----------open_main--------- 20 | 21 | public final static String ACTIVITY_URL_MAIN = "/main/MainActivity"; 22 | public final static String ACTIVITY_URL_ADD_CIRCLE = "/main/AddCircleActivity"; 23 | public final static String ACTIVITY_URL_SET = "/main/SetActivity"; 24 | 25 | 26 | //-----------open_main--------- 27 | 28 | //-----------open_user--------- 29 | public final static String FRAGMENT_URL_ME = "/user/MeFragment"; 30 | 31 | //-----------open_user--------- 32 | 33 | //-----------open_debug--------- 34 | public final static String ACTIVITY_URL_DEBUG = "/debug/DebugActivity"; 35 | 36 | //-----------open_debug--------- 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/MD5Utils.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util; 2 | 3 | import java.security.MessageDigest; 4 | 5 | public class MD5Utils { 6 | //公盐 7 | private static final String PUBLIC_SALT = "w928r982r"; 8 | //十六进制下数字到字符的映射数组 9 | private final static String[] hexDigits = {"0", "1", "2", "3", "4", 10 | "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"}; 11 | 12 | /** 13 | * 用户密码加密,盐值为 :私盐+公盐 14 | * @param password 密码 15 | * @return MD5加密字符串 16 | */ 17 | public static String md5(String password){ 18 | return encodeByMD5(PUBLIC_SALT+password); 19 | } 20 | 21 | /** 22 | * md5加密算法 23 | * @param originString 24 | * @return 25 | */ 26 | private static String encodeByMD5(String originString){ 27 | if (originString != null){ 28 | try{ 29 | //创建具有指定算法名称的信息摘要 30 | MessageDigest md = MessageDigest.getInstance("MD5"); 31 | //使用指定的字节数组对摘要进行最后更新,然后完成摘要计算 32 | byte[] results = md.digest(originString.getBytes()); 33 | //将得到的字节数组变成字符串返回 34 | String resultString = byteArrayToHexString(results); 35 | return resultString.toUpperCase(); 36 | } catch(Exception ex){ 37 | ex.printStackTrace(); 38 | } 39 | } 40 | return null; 41 | } 42 | 43 | /** 44 | * 转换字节数组为十六进制字符串 45 | * @return 十六进制字符串 46 | */ 47 | private static String byteArrayToHexString(byte[] b){ 48 | StringBuffer resultSb = new StringBuffer(); 49 | for (int i = 0; i < b.length; i++){ 50 | resultSb.append(byteToHexString(b[i])); 51 | } 52 | return resultSb.toString(); 53 | } 54 | 55 | /** 将一个字节转化成十六进制形式的字符串 */ 56 | private static String byteToHexString(byte b){ 57 | int n = b; 58 | if (n < 0) 59 | n = 256 + n; 60 | int d1 = n / 16; 61 | int d2 = n % 16; 62 | return hexDigits[d1] + hexDigits[d2]; 63 | } 64 | 65 | public static void main(String[] args) { 66 | String pasMd5 = md5("12345a"); 67 | System.out.println(pasMd5); 68 | } 69 | } -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/StringUtils.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | /** 7 | * Created by mwqi on 2014/6/8. 8 | */ 9 | public class StringUtils { 10 | public final static String UTF_8 = "UTF-8"; 11 | 12 | /** 13 | * 判断字符串是否有值,如果为null或者是空字符串或者只有空格或者为"null"字符串,则返回true,否则则返回false 14 | */ 15 | public static boolean isEmpty(String value) { 16 | if (value != null && !"".equalsIgnoreCase(value.trim()) 17 | && !"null".equalsIgnoreCase(value.trim())) { 18 | return false; 19 | } else { 20 | return true; 21 | } 22 | } 23 | 24 | /** 25 | * 验证手机号码 26 | * 27 | * @param mobiles 28 | * @return [0-9]{5,9} 29 | */ 30 | public boolean isMobileNO(String mobiles) { 31 | try { 32 | Pattern p = Pattern 33 | .compile("^((13[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$"); 34 | Matcher m = p.matcher(mobiles); 35 | return m.matches(); 36 | } catch (Exception e) { 37 | } 38 | return false; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/logger/Logger.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util.logger; 2 | 3 | import android.util.Log; 4 | 5 | import com.vc.wd.common.util.logger.conf.LogConfiger; 6 | import com.vc.wd.common.util.logger.printer.LogPrinter; 7 | 8 | public final class Logger { 9 | 10 | public static Logger createLogger(String tag) { 11 | return new Logger(tag, LogConfiger.getDefaultPrinter()); 12 | } 13 | 14 | public static Logger createLogger(Class cls) { 15 | return createLogger(cls.getName()); 16 | } 17 | 18 | public static Logger createOnlineDebugLogger(String tag) { 19 | return new Logger(tag, LogConfiger.getOnlineDebugPrinter()); 20 | } 21 | 22 | public static Logger createOnlineDebugLogger(Class cls) { 23 | return createOnlineDebugLogger(cls.getName()); 24 | } 25 | 26 | public static String getStackTraceString(Throwable tr) { 27 | return Log.getStackTraceString(tr); 28 | } 29 | 30 | private final String tag; 31 | private LogPrinter printer; 32 | 33 | private Logger(String tag, LogPrinter printer) { 34 | this.tag = tag; 35 | this.printer = printer; 36 | } 37 | 38 | public String getTag() { 39 | return tag; 40 | } 41 | 42 | public int v(String msg, Object... args) { 43 | return printer.v(tag, msg, args); 44 | } 45 | 46 | public int v(Throwable tr, String msg, Object... args) { 47 | return printer.v(tag, tr, msg, args); 48 | } 49 | 50 | public int v(Object msg) { 51 | return printer.v(tag, msg); 52 | } 53 | 54 | public int d(String msg, Object... args) { 55 | return printer.d(tag, msg, args); 56 | } 57 | 58 | public int d(Throwable tr, String msg, Object... args) { 59 | return printer.d(tag, tr, msg, args); 60 | } 61 | 62 | public int d(Object msg) { 63 | return printer.d(tag, msg); 64 | } 65 | 66 | public int i(String msg, Object... args) { 67 | return printer.i(tag, msg, args); 68 | } 69 | 70 | public int i(Throwable tr, String msg, Object... args) { 71 | return printer.i(tag, tr, msg, args); 72 | } 73 | 74 | public int i(Object msg) { 75 | return printer.i(tag, msg); 76 | } 77 | 78 | public int w(String msg, Object... args) { 79 | return printer.w(tag, msg, args); 80 | } 81 | 82 | public int w(Throwable tr, String msg, Object... args) { 83 | return printer.w(tag, tr, msg, args); 84 | } 85 | 86 | public int w(Throwable tr) { 87 | return printer.w(tag, tr); 88 | } 89 | 90 | public int w(Object msg) { 91 | return printer.w(tag, msg); 92 | } 93 | 94 | public int e(String msg, Object... args) { 95 | return printer.e(tag, msg, args); 96 | } 97 | 98 | public int e(Throwable tr, String msg, Object... args) { 99 | return printer.e(tag, tr, msg, args); 100 | } 101 | 102 | public int e(Object msg) { 103 | return printer.e(tag, msg); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/logger/conf/LogConfiger.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util.logger.conf; 2 | 3 | import com.vc.wd.common.util.logger.printer.ConsolePrinter; 4 | import com.vc.wd.common.util.logger.printer.LogPrinter; 5 | 6 | public class LogConfiger { 7 | 8 | private static final LogProxyPrinter DEF_LOG_PROXY = new LogProxyPrinter(new ConsolePrinter()); 9 | private static final LogProxyPrinter ON_LOG_PROXY = new LogProxyPrinter(new ConsolePrinter()); 10 | 11 | public static LogPrinter getDefaultPrinter() { 12 | return DEF_LOG_PROXY; 13 | } 14 | 15 | public static LogPrinter getOnlineDebugPrinter() { 16 | return ON_LOG_PROXY; 17 | } 18 | 19 | public static void setDefaultPrinter(LogPrinter logPrinter) { 20 | DEF_LOG_PROXY.setLogPrinter(logPrinter); 21 | } 22 | 23 | public static void setOnlineDebugPrinter(LogPrinter logPrinter) { 24 | ON_LOG_PROXY.setLogPrinter(logPrinter); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/logger/conf/LogProxyPrinter.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util.logger.conf; 2 | 3 | import com.vc.wd.common.util.logger.printer.LogPrinter; 4 | 5 | public class LogProxyPrinter implements LogPrinter { 6 | private LogPrinter logPrinter; 7 | 8 | public LogProxyPrinter(LogPrinter logPrinter) { 9 | this.logPrinter = logPrinter; 10 | } 11 | 12 | public void setLogPrinter(LogPrinter logPrinter) { 13 | this.logPrinter = logPrinter; 14 | } 15 | 16 | @Override 17 | public int v(String tag, String msg, Object... args) { 18 | return logPrinter.v(tag, msg, args); 19 | } 20 | 21 | @Override 22 | public int v(String tag, Throwable tr, String msg, Object... args) { 23 | return logPrinter.v(tag, tr, msg, args); 24 | } 25 | 26 | @Override 27 | public int v(String tag, Object msg) { 28 | return logPrinter.v(tag, msg); 29 | } 30 | 31 | @Override 32 | public int d(String tag, String msg, Object... args) { 33 | return logPrinter.d(tag, msg, args); 34 | } 35 | 36 | @Override 37 | public int d(String tag, Throwable tr, String msg, Object... args) { 38 | return logPrinter.d(tag, tr, msg, args); 39 | } 40 | 41 | @Override 42 | public int d(String tag, Object msg) { 43 | return logPrinter.d(tag, msg); 44 | } 45 | 46 | @Override 47 | public int i(String tag, String msg, Object... args) { 48 | return logPrinter.i(tag, msg, args); 49 | } 50 | 51 | @Override 52 | public int i(String tag, Throwable tr, String msg, Object... args) { 53 | return logPrinter.i(tag, tr, msg, args); 54 | } 55 | 56 | @Override 57 | public int i(String tag, Object msg) { 58 | return logPrinter.i(tag, msg); 59 | } 60 | 61 | @Override 62 | public int w(String tag, String msg, Object... args) { 63 | return logPrinter.w(tag, msg, args); 64 | } 65 | 66 | @Override 67 | public int w(String tag, Throwable tr, String msg, Object... args) { 68 | return logPrinter.w(tag, tr, msg, args); 69 | } 70 | 71 | @Override 72 | public int w(String tag, Throwable tr) { 73 | return logPrinter.w(tag, tr); 74 | } 75 | 76 | @Override 77 | public int w(String tag, Object msg) { 78 | return logPrinter.w(tag, msg); 79 | } 80 | 81 | @Override 82 | public int e(String tag, String msg, Object... args) { 83 | return logPrinter.e(tag, msg, args); 84 | } 85 | 86 | @Override 87 | public int e(String tag, Throwable tr, String msg, Object... args) { 88 | return logPrinter.e(tag, tr, msg, args); 89 | } 90 | 91 | @Override 92 | public int e(String tag, Object msg) { 93 | return logPrinter.e(tag, msg); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/logger/printer/ConsolePrinter.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util.logger.printer; 2 | 3 | import android.util.Log; 4 | 5 | import java.util.Locale; 6 | 7 | public class ConsolePrinter implements LogPrinter { 8 | 9 | public ConsolePrinter() { 10 | } 11 | 12 | @Override 13 | public int v(String tag, String msg, Object... args) { 14 | return Log.v(tag, format(msg, args)); 15 | } 16 | 17 | @Override 18 | public int v(String tag, Throwable tr, String msg, Object... args) { 19 | return Log.v(tag, format(msg, args), tr); 20 | } 21 | 22 | @Override 23 | public int d(String tag, String msg, Object... args) { 24 | return Log.d(tag, format(msg, args)); 25 | } 26 | 27 | @Override 28 | public int d(String tag, Throwable tr, String msg, Object... args) { 29 | return Log.d(tag, format(msg, args), tr); 30 | } 31 | 32 | @Override 33 | public int i(String tag, String msg, Object... args) { 34 | return Log.i(tag, format(msg, args)); 35 | } 36 | 37 | @Override 38 | public int i(String tag, Throwable tr, String msg, Object... args) { 39 | return Log.i(tag, format(msg, args), tr); 40 | } 41 | 42 | @Override 43 | public int w(String tag, String msg, Object... args) { 44 | return Log.w(tag, format(msg, args)); 45 | } 46 | 47 | @Override 48 | public int w(String tag, Throwable tr, String msg, Object... args) { 49 | return Log.w(tag, format(msg, args), tr); 50 | } 51 | 52 | @Override 53 | public int w(String tag, Throwable tr) { 54 | return Log.w(tag, tr); 55 | } 56 | 57 | @Override 58 | public int e(String tag, String msg, Object... args) { 59 | return Log.e(tag, format(msg, args)); 60 | } 61 | 62 | @Override 63 | public int e(String tag, Throwable tr, String msg, Object... args) { 64 | return Log.e(tag, format(msg, args), tr); 65 | } 66 | 67 | private String format(String msg, Object... args) { 68 | return String.format(Locale.CHINA, msg, args); 69 | } 70 | 71 | @Override 72 | public int v(String tag, Object msg) { 73 | return Log.v(tag, msg.toString()); 74 | } 75 | 76 | @Override 77 | public int d(String tag, Object msg) { 78 | return Log.d(tag, msg.toString()); 79 | } 80 | 81 | @Override 82 | public int i(String tag, Object msg) { 83 | return Log.i(tag, msg.toString()); 84 | } 85 | 86 | @Override 87 | public int w(String tag, Object msg) { 88 | return Log.w(tag, msg.toString()); 89 | } 90 | 91 | @Override 92 | public int e(String tag, Object msg) { 93 | return Log.e(tag, msg.toString()); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/logger/printer/EmptyPrinter.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util.logger.printer; 2 | 3 | public class EmptyPrinter implements LogPrinter { 4 | @Override 5 | public int v(String tag, String msg, Object... args) { 6 | return 0; 7 | } 8 | 9 | @Override 10 | public int v(String tag, Throwable tr, String msg, Object... args) { 11 | return 0; 12 | } 13 | 14 | @Override 15 | public int d(String tag, String msg, Object... args) { 16 | return 0; 17 | } 18 | 19 | @Override 20 | public int d(String tag, Throwable tr, String msg, Object... args) { 21 | return 0; 22 | } 23 | 24 | @Override 25 | public int i(String tag, String msg, Object... args) { 26 | return 0; 27 | } 28 | 29 | @Override 30 | public int i(String tag, Throwable tr, String msg, Object... args) { 31 | return 0; 32 | } 33 | 34 | @Override 35 | public int w(String tag, String msg, Object... args) { 36 | return 0; 37 | } 38 | 39 | @Override 40 | public int w(String tag, Throwable tr, String msg, Object... args) { 41 | return 0; 42 | } 43 | 44 | @Override 45 | public int w(String tag, Throwable tr) { 46 | return 0; 47 | } 48 | 49 | @Override 50 | public int e(String tag, String msg, Object... args) { 51 | return 0; 52 | } 53 | 54 | @Override 55 | public int e(String tag, Throwable tr, String msg, Object... args) { 56 | return 0; 57 | } 58 | 59 | @Override 60 | public int v(String tag, Object msg) { 61 | return 0; 62 | } 63 | 64 | @Override 65 | public int d(String tag, Object msg) { 66 | return 0; 67 | } 68 | 69 | @Override 70 | public int i(String tag, Object msg) { 71 | return 0; 72 | } 73 | 74 | @Override 75 | public int w(String tag, Object msg) { 76 | return 0; 77 | } 78 | 79 | @Override 80 | public int e(String tag, Object msg) { 81 | return 0; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/logger/printer/FileLogPrinter.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util.logger.printer; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | 6 | import java.util.Locale; 7 | 8 | public class FileLogPrinter implements LogPrinter { 9 | 10 | 11 | private static FileLogger fileLogger = new FileLogger(); 12 | 13 | public static void init(String path, Context ctx) { 14 | fileLogger.init(path, ctx); 15 | } 16 | 17 | public static void flush() { 18 | fileLogger.flush(); 19 | } 20 | 21 | public FileLogPrinter() { 22 | } 23 | 24 | @Override 25 | public int v(String tag, String msg, Object... args) { 26 | fileLogger.write(Log.VERBOSE, tag, this.format(msg, args)); 27 | return 0; 28 | } 29 | 30 | @Override 31 | public int v(String tag, Throwable throwable, String msg, Object... args) { 32 | fileLogger.write(Log.VERBOSE, tag, this.format(msg, args)); 33 | return 0; 34 | } 35 | 36 | @Override 37 | public int v(String tag, Object msg) { 38 | fileLogger.write(Log.VERBOSE, tag, String.valueOf(msg)); 39 | return 0; 40 | } 41 | 42 | @Override 43 | public int d(String tag, String msg, Object... args) { 44 | fileLogger.write(Log.DEBUG, tag, this.format(msg, args)); 45 | return 0; 46 | } 47 | 48 | @Override 49 | public int d(String tag, Throwable throwable, String msg, Object... args) { 50 | fileLogger.write(Log.DEBUG, tag, this.format(msg, args) + "\r\n" + Log.getStackTraceString(throwable)); 51 | return 0; 52 | } 53 | 54 | @Override 55 | public int d(String tag, Object msg) { 56 | fileLogger.write(Log.DEBUG, tag, String.valueOf(msg)); 57 | return 0; 58 | } 59 | 60 | 61 | @Override 62 | public int i(String tag, String msg, Object... args) { 63 | fileLogger.write(Log.INFO, tag, this.format(msg, args)); 64 | return 0; 65 | } 66 | 67 | @Override 68 | public int i(String tag, Throwable throwable, String msg, Object... args) { 69 | fileLogger.write(Log.INFO, tag, this.format(msg, args) + "\r\n" + Log.getStackTraceString(throwable)); 70 | return 0; 71 | } 72 | 73 | @Override 74 | public int i(String tag, Object msg) { 75 | fileLogger.write(Log.INFO, tag, String.valueOf(msg)); 76 | return 0; 77 | } 78 | 79 | @Override 80 | public int w(String tag, String msg, Object... args) { 81 | fileLogger.write(Log.WARN, tag, this.format(msg, args)); 82 | return 0; 83 | } 84 | 85 | @Override 86 | public int w(String tag, Throwable throwable, String msg, Object... args) { 87 | fileLogger.write(Log.WARN, tag, this.format(msg, args) + "\r\n" + Log.getStackTraceString(throwable)); 88 | return 0; 89 | } 90 | 91 | @Override 92 | public int w(String tag, Throwable throwable) { 93 | fileLogger.write(Log.WARN, tag, Log.getStackTraceString(throwable)); 94 | return 0; 95 | } 96 | 97 | @Override 98 | public int w(String tag, Object msg) { 99 | fileLogger.write(Log.WARN, tag, String.valueOf(msg)); 100 | return 0; 101 | } 102 | 103 | @Override 104 | public int e(String tag, String msg, Object... args) { 105 | fileLogger.write(Log.ERROR, tag, this.format(msg, args)); 106 | return 0; 107 | } 108 | 109 | @Override 110 | public int e(String tag, Throwable throwable, String msg, Object... args) { 111 | fileLogger.write(Log.ERROR, tag, this.format(msg, args) + "\r\n" + Log.getStackTraceString(throwable)); 112 | return 0; 113 | } 114 | 115 | @Override 116 | public int e(String tag, Object msg) { 117 | fileLogger.write(Log.ERROR, tag, String.valueOf(msg)); 118 | return 0; 119 | } 120 | 121 | private String format(String msg, Object... args) { 122 | for (int i = 0; i < args.length; i++) { 123 | args[i] = args[i] == null ? "null" : args[i]; 124 | } 125 | return String.format(Locale.CHINA, msg, args); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/logger/printer/LogPrinter.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util.logger.printer; 2 | 3 | import android.util.Log; 4 | 5 | public interface LogPrinter { 6 | 7 | /** 8 | * Send a {@link Log#VERBOSE} log message. 9 | * 10 | * @param msg The message you would like logged. 11 | */ 12 | int v(String tag, String msg, Object... args); 13 | 14 | /** 15 | * Send a {@link Log#VERBOSE} log message and log the exception. 16 | * 17 | * @param msg The message you would like logged. 18 | * @param tr An exception to log 19 | */ 20 | int v(String tag, Throwable tr, String msg, Object... args); 21 | 22 | /** 23 | * Send a {@link Log#VERBOSE} log message and log the exception. 24 | * 25 | * @param msg The message you would like logged. 26 | */ 27 | int v(String tag, Object msg); 28 | 29 | /** 30 | * Send a {@link Log#DEBUG} log message. 31 | * 32 | * @param msg The message you would like logged. 33 | */ 34 | int d(String tag, String msg, Object... args); 35 | 36 | /** 37 | * Send a {@link Log#DEBUG} log message and log the exception. 38 | * 39 | * @param msg The message you would like logged. 40 | * @param tr An exception to log 41 | */ 42 | int d(String tag, Throwable tr, String msg, Object... args); 43 | 44 | /** 45 | * Send a {@link Log#DEBUG} log message and log the exception. 46 | * 47 | * @param msg The message you would like logged. 48 | */ 49 | int d(String tag, Object msg); 50 | 51 | /** 52 | * Send an {@link Log#INFO} log message. 53 | * 54 | * @param msg The message you would like logged. 55 | */ 56 | int i(String tag, String msg, Object... args); 57 | 58 | /** 59 | * Send a {@link Log#INFO} log message and log the exception. 60 | * 61 | * @param msg The message you would like logged. 62 | * @param tr An exception to log 63 | */ 64 | int i(String tag, Throwable tr, String msg, Object... args); 65 | 66 | /** 67 | * Send a {@link Log#INFO} log message and log the exception. 68 | * 69 | * @param msg The message you would like logged. 70 | */ 71 | int i(String tag, Object msg); 72 | 73 | /** 74 | * Send a {@link Log#WARN} log message. 75 | * 76 | * @param msg The message you would like logged. 77 | */ 78 | int w(String tag, String msg, Object... args); 79 | 80 | /** 81 | * Send a {@link Log#WARN} log message and log the exception. 82 | * 83 | * @param msg The message you would like logged. 84 | * @param tr An exception to log 85 | */ 86 | int w(String tag, Throwable tr, String msg, Object... args); 87 | 88 | /** 89 | * Send a {@link Log#WARN} log message and log the exception. 90 | * 91 | * @param tr An exception to log 92 | */ 93 | int w(String tag, Throwable tr); 94 | 95 | /** 96 | * Send a {@link Log#WARN} log message and log the exception. 97 | * 98 | * @param msg The message you would like logged. 99 | */ 100 | int w(String tag, Object msg); 101 | 102 | /** 103 | * Send an {@link Log#ERROR} log message. 104 | * 105 | * @param msg The message you would like logged. 106 | */ 107 | int e(String tag, String msg, Object... args); 108 | 109 | /** 110 | * Send a {@link Log#ERROR} log message and log the exception. 111 | * 112 | * @param msg The message you would like logged. 113 | * @param tr An exception to log 114 | */ 115 | int e(String tag, Throwable tr, String msg, Object... args); 116 | 117 | /** 118 | * Send a {@link Log#ERROR} log message and log the exception. 119 | * 120 | * @param msg The message you would like logged. 121 | */ 122 | int e(String tag, Object msg); 123 | } 124 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/recycleview/SpacingItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util.recycleview; 2 | 3 | import android.graphics.Rect; 4 | import android.view.View; 5 | 6 | import androidx.recyclerview.widget.RecyclerView; 7 | 8 | /** 9 | * desc 10 | * author VcStrong 11 | * github VcStrong 12 | * date 2020/5/28 1:42 PM 13 | */ 14 | public class SpacingItemDecoration extends RecyclerView.ItemDecoration { 15 | 16 | private int spacing; 17 | 18 | public SpacingItemDecoration(int spacing) { 19 | this.spacing = spacing; 20 | } 21 | 22 | @Override 23 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 24 | outRect.top = spacing / 2; 25 | outRect.bottom = spacing / 2; 26 | outRect.left = spacing / 2; 27 | outRect.right = spacing / 2; 28 | } 29 | } -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/shared/Pair.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util.shared; 2 | 3 | import io.objectbox.annotation.Entity; 4 | import io.objectbox.annotation.Id; 5 | import io.objectbox.annotation.Unique; 6 | 7 | /** 8 | * author dingtao 9 | * date 5/13/21 4:24 PM 10 | * desc 11 | */ 12 | @Entity 13 | public class Pair { 14 | @Id 15 | public long id; 16 | @Unique 17 | public String key; 18 | public String value; 19 | 20 | public Pair() { 21 | } 22 | 23 | public Pair(String key, String value) { 24 | this.key = key; 25 | this.value = value; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/com/vc/wd/common/util/shared/SharedUtils.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.common.util.shared; 2 | 3 | import com.vc.wd.common.core.WDApplication; 4 | import com.vc.wd.common.util.logger.Logger; 5 | 6 | import org.json.JSONException; 7 | import org.json.JSONObject; 8 | 9 | import io.objectbox.Box; 10 | 11 | /** 12 | * author dingtao 13 | * date 5/13/21 4:22 PM 14 | * desc 15 | */ 16 | public class SharedUtils { 17 | private static Logger logger = Logger.createLogger(SharedUtils.class); 18 | private final static String VALUE = "value"; 19 | private Box box; 20 | private static SharedUtils instance; 21 | 22 | private SharedUtils() { 23 | box = WDApplication.getBoxStore().boxFor(Pair.class); 24 | } 25 | 26 | public static SharedUtils getInstance() { 27 | if (instance == null) { 28 | synchronized (SharedUtils.class) { 29 | if (instance == null) { 30 | instance = new SharedUtils(); 31 | } 32 | } 33 | } 34 | return instance; 35 | } 36 | 37 | public static void put(String key, Object value) { 38 | JSONObject valueJson = new JSONObject(); 39 | try { 40 | valueJson.put(VALUE, value); 41 | Pair pair = get(key); 42 | if (pair == null) { 43 | pair = new Pair(key, valueJson.toString()); 44 | } else { 45 | pair.value = valueJson.toString(); 46 | } 47 | getInstance().box.put(pair); 48 | } catch (Exception e) { 49 | logger.e(e); 50 | } 51 | } 52 | 53 | private static Pair get(String key) { 54 | Pair pair = getInstance().box.query() 55 | .equal(Pair_.key, key) 56 | .build().findUnique(); 57 | return pair; 58 | } 59 | 60 | public static boolean getBoolen(String key) { 61 | return getBoolen(key, false); 62 | } 63 | 64 | public static boolean getBoolen(String key, boolean defValue) { 65 | Pair pair = get(key); 66 | if (pair != null) { 67 | try { 68 | JSONObject jsonObject = new JSONObject(pair.value); 69 | return jsonObject.getBoolean(VALUE); 70 | } catch (Exception e) { 71 | e.printStackTrace(); 72 | } 73 | } 74 | return defValue; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /common/src/main/res/layout/base.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /common/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /config.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | 3 | //开发-分支 4 | dev = [ 5 | branch : "dev", 6 | applicationId : "com.vc.wd.dev", 7 | versionCode : 2, 8 | versionName : "2.1dev", 9 | appName : "商城dev", 10 | serverUrl : "http://mobile.bwstudent.com/small/", 11 | baiduUrl : "http://www.baidu.com/api/v2/" 12 | // im_key : "1111kkkkkk", 13 | // push_key : "1111ppppp" 14 | ] 15 | 16 | //测试-分支 17 | beta = [ 18 | branch : "beta", 19 | applicationId : "com.vc.wd.beta", 20 | versionCode : 2, 21 | versionName : "2.1beta", 22 | appName : "商城beta", 23 | serverUrl : "http://mobile.bwstudent.com/small/", 24 | baiduUrl : "http://www.baidu.com/api/v2/" 25 | // im_key : "2222kkkkkk", 26 | // push_key : "2222ppppp" 27 | ] 28 | 29 | //发布版上线-分支 30 | release = [ 31 | branch : "release", 32 | applicationId : "com.vc.wd", 33 | versionCode : 1, 34 | versionName : "1.0", 35 | appName : "商城release", 36 | serverUrl : "http://mobile.bwstudent.com/small/", 37 | baiduUrl : "http://www.baidu.com/api/v1/" 38 | // im_key : "3333kkkkkk", 39 | // push_key : "3333ppppp" 40 | ] 41 | 42 | //①方便自定义各种常量,统一项目中配置输出 43 | //②方便后续接入即时通讯、推送等服务之后,不同分支使用不同的第三方api_key,防止开发或者测试阶段发送"test"这样的推送消息造成A类事故 44 | //根据项目阶段自行改变(dev,beta,release),方便各部门协作,减少沟通成本 45 | //千万不要错误的认成build.gradle中debug和release,上面只是项目各阶段的配置,和apk打包互不影响。 46 | active = release 47 | 48 | //建议用来记录不会因为发布分支改变的参数 49 | SDK_VERSION = [ 50 | compileSdkVersion: 29, 51 | minSdkVersion : 15,//4.0.3 52 | targetSdkVersion : 29 53 | ] 54 | 55 | //全部都打包,如果只运行模块,请改为false;true则所有模块都参与打包 56 | allPackage = true 57 | //需要运行的组件,当allPackage为false的时候,此变量生效,模块名参照settings.gradle中的 58 | needPackage = ["open_main"] 59 | 60 | //组件和全量包都会优先判断此变量中的模块,如果配置了,此模块不参与打包 61 | ignorePackage = [] 62 | } -------------------------------------------------------------------------------- /debug_mode/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /debug_mode/build.gradle: -------------------------------------------------------------------------------- 1 | apply from: '../module.gradle' 2 | 3 | android { 4 | 5 | defaultConfig { 6 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 7 | consumerProguardFiles "consumer-rules.pro" 8 | } 9 | } 10 | 11 | dependencies { 12 | testImplementation 'junit:junit:4.+' 13 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 14 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 15 | 16 | // UEtool 17 | debugImplementation 'me.ele:uetool:1.2.9' 18 | releaseImplementation 'me.ele:uetool-no-op:1.2.9' 19 | // if you want to show more attrs about Fresco's DraweeView 20 | debugImplementation 'me.ele:uetool-fresco:1.2.9' 21 | } -------------------------------------------------------------------------------- /debug_mode/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/debug_mode/consumer-rules.pro -------------------------------------------------------------------------------- /debug_mode/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 -------------------------------------------------------------------------------- /debug_mode/src/androidTest/java/com/vc/wd/debug/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.debug; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.vc.wd.debug.test", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /debug_mode/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /debug_mode/src/main/java/com/vc/wd/debug/activity/DebugActivity.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.debug.activity; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.alibaba.android.arouter.facade.annotation.Route; 6 | import com.vc.wd.common.core.WDActivity; 7 | import com.vc.wd.common.util.Constant; 8 | import com.vc.wd.debug.R; 9 | import com.vc.wd.debug.databinding.ActivityDebugBinding; 10 | import com.vc.wd.debug.vm.DebugViewModel; 11 | 12 | /** 13 | * debug功能页 14 | */ 15 | @Route(path = Constant.ACTIVITY_URL_DEBUG) 16 | public class DebugActivity extends WDActivity { 17 | @Override 18 | protected int getLayoutId() { 19 | return R.layout.activity_debug; 20 | } 21 | 22 | @Override 23 | protected void initView(Bundle savedInstanceState) { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /debug_mode/src/main/java/com/vc/wd/debug/core/DebugApplication.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.debug.core; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | import android.os.Bundle; 6 | 7 | import com.vc.wd.common.core.IWDApplication; 8 | import com.vc.wd.common.core.WDApplication; 9 | import com.vc.wd.common.util.logger.Logger; 10 | import com.vc.wd.common.util.shared.SharedUtils; 11 | import com.vc.wd.debug.BuildConfig; 12 | import com.vc.wd.debug.vm.DebugViewModel; 13 | 14 | import io.objectbox.android.AndroidObjectBrowser; 15 | import me.ele.uetool.UETool; 16 | 17 | /** 18 | * desc Module的Application不要去清单文件中配置,请打开common包的IWDAppcation接口把路径(包名+类名)配置上, 19 | * WDApplication会自动初始化这些子模块App 20 | * author VcStrong 21 | * github VcStrong 22 | * date 2021/1/14 1:42 PM 23 | */ 24 | public class DebugApplication implements IWDApplication { 25 | private final Logger logger = Logger.createLogger(getClass()); 26 | 27 | @Override 28 | public void onCreate(Application application) { 29 | logger.i("Debug模块初始化"); 30 | if (BuildConfig.DEBUG) { 31 | boolean started = new AndroidObjectBrowser(WDApplication.getBoxStore()).start(application); 32 | logger.i("ObjectBrowser Started: " + started + " " + WDApplication.getBoxStore().getObjectBrowserPort()); 33 | } 34 | 35 | application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() { 36 | 37 | private int visibleActivityCount; 38 | 39 | @Override 40 | public void onActivityCreated(Activity activity, Bundle savedInstanceState) { 41 | 42 | } 43 | 44 | @Override 45 | public void onActivityStarted(Activity activity) { 46 | visibleActivityCount++; 47 | boolean ue = SharedUtils.getBoolen(DebugViewModel.SWITCH_UETOOL); 48 | if (ue) { 49 | UETool.showUETMenu(); 50 | } 51 | } 52 | 53 | @Override 54 | public void onActivityResumed(Activity activity) { 55 | 56 | } 57 | 58 | @Override 59 | public void onActivityPaused(Activity activity) { 60 | 61 | } 62 | 63 | @Override 64 | public void onActivityStopped(Activity activity) { 65 | visibleActivityCount--; 66 | if (visibleActivityCount == 0) { 67 | UETool.dismissUETMenu(); 68 | } 69 | } 70 | 71 | @Override 72 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) { 73 | 74 | } 75 | 76 | @Override 77 | public void onActivityDestroyed(Activity activity) { 78 | 79 | } 80 | }); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /debug_mode/src/main/java/com/vc/wd/debug/util/ClassScannerUtil.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.debug.util; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.annotation.NonNull; 6 | 7 | import java.io.IOException; 8 | import java.util.Enumeration; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | import dalvik.system.DexFile; 13 | 14 | /** 15 | * 通过package名,查找package下面的指定类的类名 16 | */ 17 | public class ClassScannerUtil { 18 | 19 | /** 20 | * @param context 21 | * @param packageName 完整的包名 22 | * @param excludeString 结尾字符串 23 | * @param endTag map中key是否需要结尾字符串 24 | * @param keyWords 关键字 25 | * @return key value 类名键值对 26 | */ 27 | public static Map scan(Context context, String packageName, @NonNull String excludeString, @NonNull String endTag, String keyWords) { 28 | //生成类名对应类名的映射 WifiController --> com.kehuantiantang.controller.WifiController 29 | Map classes = new HashMap<>(); 30 | try { 31 | //apk的dex文件,获得源码来反射 32 | DexFile dex = new DexFile(context.getPackageCodePath()); 33 | //枚举类,来遍历所有源代码 34 | Enumeration entries = dex.entries(); 35 | while (entries.hasMoreElements()) { 36 | String className = entries.nextElement(); 37 | //Add whole classname --> package + classname 38 | //classList.add(className); 39 | //指定package包里面的文件 40 | if (className.contains(packageName) && className.contains(keyWords)) { 41 | //排除包含有excludeString的类 42 | if (!className.matches(excludeString)) { 43 | 44 | //需不需要留结尾的tag 45 | if (!"".equals(endTag)) { 46 | classes.put(className, className.substring(className.lastIndexOf(".") + 1, className.length() - endTag.length())); 47 | } else { 48 | classes.put(className, className.substring(className.lastIndexOf(".") + 1, className.length())); 49 | } 50 | } 51 | } 52 | } 53 | } catch (IOException e) { 54 | e.printStackTrace(); 55 | } 56 | return classes; 57 | } 58 | 59 | public static Map scan(Context context, String packageName, @NonNull String excludeString, String keyWords) { 60 | return scan(context, packageName, excludeString, "", keyWords); 61 | } 62 | 63 | /** 64 | * .*\$.*防止内部类和空文件 65 | * 66 | * @param context 67 | * @param packageName 68 | * @return 69 | */ 70 | public static Map scan(Context context, String packageName, String keyWords) { 71 | return scan(context, packageName, ".*\\$.*", "", keyWords == null ? "" : keyWords); 72 | } 73 | 74 | public static Map scan(Context context, String packageName) { 75 | return scan(context, packageName, ""); 76 | } 77 | } -------------------------------------------------------------------------------- /debug_mode/src/main/java/com/vc/wd/debug/vm/DebugViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.debug.vm; 2 | 3 | import androidx.databinding.ObservableField; 4 | 5 | import com.vc.wd.common.core.WDApplication; 6 | import com.vc.wd.common.core.WDViewModel; 7 | import com.vc.wd.common.util.shared.Pair; 8 | import com.vc.wd.common.util.shared.SharedUtils; 9 | import com.vc.wd.debug.util.ClassScannerUtil; 10 | 11 | import java.io.IOException; 12 | import java.net.URL; 13 | import java.util.Enumeration; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | 17 | import me.ele.uetool.UETool; 18 | 19 | /** 20 | * author dingtao 21 | * date 1/14/21 4:47 PM 22 | * desc 23 | */ 24 | public class DebugViewModel extends WDViewModel { 25 | 26 | public final static String SWITCH_UETOOL = "switch_uetool"; 27 | public ObservableField uetoolCheck = new ObservableField<>(); 28 | public ObservableField classList = new ObservableField<>(); 29 | 30 | @Override 31 | protected void create() { 32 | super.create(); 33 | boolean ue = SharedUtils.getBoolen(SWITCH_UETOOL); 34 | uetoolCheck.set(ue); 35 | 36 | updataModule(); 37 | } 38 | 39 | private void updataModule() { 40 | Map map = ClassScannerUtil.scan(WDApplication.getContext(), "com.vc.wd", "BuildConfig"); 41 | if (map!=null){ 42 | StringBuilder builder = new StringBuilder(); 43 | for (Map.Entry entry:map.entrySet()) { 44 | builder.append(entry.getKey()); 45 | builder.append("\n"); 46 | } 47 | classList.set(builder.toString()); 48 | } 49 | } 50 | 51 | public void uetool() { 52 | if (uetoolCheck.get()) { 53 | UETool.showUETMenu(); 54 | } else { 55 | UETool.dismissUETMenu(); 56 | } 57 | SharedUtils.put(SWITCH_UETOOL, uetoolCheck.get()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /debug_mode/src/main/res/layout/activity_debug.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 15 | 16 | 20 | 21 | 25 | 26 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /debug_mode/src/test/java/com/vc/wd/debug/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.debug; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /gct/commit-template-idea-plugin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/gct/commit-template-idea-plugin.jar -------------------------------------------------------------------------------- /gct/scope.json: -------------------------------------------------------------------------------- 1 | { 2 | "bean": [ 3 | { 4 | "title": "main", 5 | "description": "首页模块" 6 | }, 7 | { 8 | "title": "login", 9 | "description": "登录模块" 10 | }, 11 | { 12 | "title": "push", 13 | "description": "推送模块" 14 | }, 15 | { 16 | "title": "user", 17 | "description": "用户信息模块" 18 | }, 19 | { 20 | "title": "common", 21 | "description": "公共基础包", 22 | "sub": [ 23 | { 24 | "title": "http", 25 | "description": "http网络工具" 26 | }, 27 | { 28 | "title": "sql", 29 | "description": "数据库", 30 | "sub": [] 31 | }, 32 | { 33 | "title": "control", 34 | "description": "控制层", 35 | "sub": [] 36 | }, 37 | { 38 | "title": "log", 39 | "description": "日志工具" 40 | } 41 | ] 42 | }, 43 | { 44 | "title": "debug", 45 | "description": "debug调试", 46 | "sub": [] 47 | } 48 | ] 49 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | 21 | -------------------------------------------------------------------------------- /module.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.vc.constant' 3 | 4 | android { 5 | 6 | compileSdkVersion SDK_VERSION.compileSdkVersion 7 | defaultConfig { 8 | minSdkVersion SDK_VERSION.minSdkVersion 9 | targetSdkVersion SDK_VERSION.targetSdkVersion 10 | versionCode active.versionCode 11 | versionName active.versionName 12 | 13 | javaCompileOptions { 14 | annotationProcessorOptions { 15 | arguments = [AROUTER_MODULE_NAME: project.getName()] 16 | } 17 | } 18 | ndk { 19 | abiFilters 'armeabi', 'armeabi-v7a' 20 | } 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | buildFeatures { 30 | dataBinding = true 31 | } 32 | 33 | compileOptions { 34 | sourceCompatibility = 1.8 35 | targetCompatibility = 1.8 36 | } 37 | 38 | } 39 | 40 | dependencies { 41 | implementation fileTree(dir: 'libs', include: ['*.jar']) 42 | testImplementation 'junit:junit:4.13.2' 43 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 44 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 45 | 46 | annotationProcessor 'com.alibaba:arouter-compiler:1.2.1' 47 | api project(path: ':common') 48 | } 49 | -------------------------------------------------------------------------------- /open_im/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /open_im/build.gradle: -------------------------------------------------------------------------------- 1 | apply from: '../module.gradle' 2 | -------------------------------------------------------------------------------- /open_im/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_im/consumer-rules.pro -------------------------------------------------------------------------------- /open_im/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 | -------------------------------------------------------------------------------- /open_im/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /open_im/src/main/java/com/vc/wd/im/activity/ChatActivity.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.im.activity; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | public class ChatActivity extends AppCompatActivity { 6 | } 7 | -------------------------------------------------------------------------------- /open_im/src/main/java/com/vc/wd/im/core/IMApplication.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.im.core; 2 | 3 | import android.app.Application; 4 | 5 | import com.vc.wd.common.core.IWDApplication; 6 | import com.vc.wd.common.util.logger.Logger; 7 | 8 | /** 9 | * desc Module的Application不要去清单文件中配置,请打开common包的IWDAppcation接口把路径(包名+类名)配置上, 10 | * WDApplication会自动初始化这些子模块App 11 | * author VcStrong 12 | * github VcStrong 13 | * date 2020/5/28 1:42 PM 14 | */ 15 | public class IMApplication implements IWDApplication { 16 | private final Logger logger = Logger.createLogger(getClass()); 17 | @Override 18 | public void onCreate(Application application) { 19 | //IM的初始化等等 20 | logger.i("初始化"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /open_im/src/test/java/com/vc/wd/im/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.im; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /open_login/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /open_login/build.gradle: -------------------------------------------------------------------------------- 1 | apply from: '../module.gradle' 2 | 3 | android { 4 | 5 | //组件化运行和总包运行建议使用不同的AndroidManifest文件; 6 | //如果使用默认的AndroidManifest.xml,则去掉下面代码 7 | sourceSets { 8 | main { 9 | if (!allPackage) { 10 | manifest.srcFile 'src/test/AndroidManifest.xml' 11 | } 12 | } 13 | } 14 | } 15 | 16 | constant { 17 | enable false//不进行编译 18 | moduleName "common"//生成新代码存放在的moduleName 19 | packageName "com.vc.wd.common.util"//生成的新代码放在哪个包下 20 | className "Constant"//生成的常量类名 21 | fieldMap = [ 22 | ACTIVITY_URL_LOGIN : "/login/LoginActivity", 23 | ACTIVITY_URL_REGISTER: "/login/RegisterActivity", 24 | ACTIVITY_URL_WELCOME : "/login/WelcomeActivity" 25 | ]//属性参数 26 | } 27 | -------------------------------------------------------------------------------- /open_login/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_login/consumer-rules.pro -------------------------------------------------------------------------------- /open_login/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 | -------------------------------------------------------------------------------- /open_login/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /open_login/src/main/java/com/vc/wd/login/activity/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.login.activity; 2 | 3 | import android.os.Bundle; 4 | import android.text.method.HideReturnsTransformationMethod; 5 | import android.text.method.PasswordTransformationMethod; 6 | import androidx.lifecycle.Observer; 7 | 8 | import com.alibaba.android.arouter.facade.annotation.Route; 9 | import com.vc.wd.login.R; 10 | import com.vc.wd.common.core.WDActivity; 11 | import com.vc.wd.common.core.WDApplication; 12 | import com.vc.wd.login.databinding.ActivityLoginBinding; 13 | import com.vc.wd.common.util.Constant; 14 | import com.vc.wd.login.vm.LoginViewModel; 15 | 16 | @Route(path = Constant.ACTIVITY_URL_LOGIN) 17 | public class LoginActivity extends WDActivity { 18 | 19 | @Override 20 | protected int getLayoutId() { 21 | return R.layout.activity_login; 22 | } 23 | 24 | @Override 25 | protected void initView(Bundle savedInstanceState) { 26 | viewModel.pasVis.observe(this, new Observer() { 27 | @Override 28 | public void onChanged(Boolean aBoolean) { 29 | if (aBoolean) {//密码显示,则隐藏 30 | binding.loginPas.setTransformationMethod(PasswordTransformationMethod.getInstance()); 31 | } else {//密码隐藏则显示 32 | binding.loginPas.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); 33 | } 34 | } 35 | }); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /open_login/src/main/java/com/vc/wd/login/activity/RegisterActivity.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.login.activity; 2 | 3 | import android.os.Bundle; 4 | import android.text.TextUtils; 5 | import android.text.method.HideReturnsTransformationMethod; 6 | import android.text.method.PasswordTransformationMethod; 7 | import android.widget.EditText; 8 | 9 | import androidx.lifecycle.Observer; 10 | 11 | import com.alibaba.android.arouter.facade.annotation.Route; 12 | import com.vc.wd.login.R; 13 | import com.vc.wd.common.core.WDActivity; 14 | import com.vc.wd.login.databinding.ActivityRegisterBinding; 15 | import com.vc.wd.common.util.Constant; 16 | import com.vc.wd.login.vm.RegisterViewModel; 17 | 18 | @Route(path = Constant.ACTIVITY_URL_REGISTER) 19 | public class RegisterActivity extends WDActivity { 20 | @Override 21 | protected int getLayoutId() { 22 | return R.layout.activity_register; 23 | } 24 | 25 | @Override 26 | protected void initView(Bundle savedInstanceState) { 27 | viewModel.pasVis.observe(this, new Observer() { 28 | @Override 29 | public void onChanged(Boolean aBoolean) { 30 | if (aBoolean) {//密码显示,则隐藏 31 | binding.loginPas.setTransformationMethod(PasswordTransformationMethod.getInstance()); 32 | } else {//密码隐藏则显示 33 | binding.loginPas.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); 34 | } 35 | } 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /open_login/src/main/java/com/vc/wd/login/activity/WelcomeActivity.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.login.activity; 2 | 3 | import android.os.Bundle; 4 | import android.os.Handler; 5 | import android.os.Message; 6 | import android.widget.TextView; 7 | 8 | import com.alibaba.android.arouter.facade.annotation.Route; 9 | import com.vc.wd.login.R; 10 | import com.vc.wd.common.core.WDActivity; 11 | import com.vc.wd.login.databinding.ActivityWelcomeBinding; 12 | import com.vc.wd.common.util.Constant; 13 | import com.vc.wd.login.vm.WelcomeViewModel; 14 | 15 | @Route(path = Constant.ACTIVITY_URL_WELCOME) 16 | public class WelcomeActivity extends WDActivity { 17 | 18 | @Override 19 | protected void initView(Bundle bundle) { 20 | 21 | } 22 | 23 | @Override 24 | protected int getLayoutId() { 25 | return R.layout.activity_welcome; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /open_login/src/main/java/com/vc/wd/login/request/ILoginRequest.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.login.request; 2 | 3 | import com.vc.wd.common.bean.Result; 4 | import com.vc.wd.common.bean.UserInfo; 5 | 6 | import io.reactivex.Observable; 7 | import okhttp3.RequestBody; 8 | import retrofit2.http.Body; 9 | import retrofit2.http.POST; 10 | 11 | /** 12 | * desc 13 | * author VcStrong 14 | * github VcStrong 15 | * date 2020/5/28 1:42 PM 16 | */ 17 | public interface ILoginRequest { 18 | 19 | /** 20 | * 密码规则是数字加字母超过8位即可 21 | * @return 22 | */ 23 | @POST("user/v1/register") 24 | Observable register(@Body RequestBody json); 25 | 26 | /** 27 | * 密码规则是数字加字母超过8位即可 28 | * @return 29 | */ 30 | @POST("user/v1/login") 31 | Observable> login(@Body RequestBody json); 32 | } 33 | -------------------------------------------------------------------------------- /open_login/src/main/java/com/vc/wd/login/vm/LoginViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.login.vm; 2 | 3 | import android.text.TextUtils; 4 | 5 | import androidx.databinding.ObservableField; 6 | import androidx.lifecycle.MutableLiveData; 7 | 8 | import com.vc.wd.common.bean.UserInfo; 9 | import com.vc.wd.common.core.DataCall; 10 | import com.vc.wd.common.core.WDApplication; 11 | import com.vc.wd.common.core.WDViewModel; 12 | import com.vc.wd.common.core.exception.ApiException; 13 | import com.vc.wd.common.core.http.NetworkManager; 14 | import com.vc.wd.common.util.Constant; 15 | import com.vc.wd.common.util.UIUtils; 16 | import com.vc.wd.login.request.ILoginRequest; 17 | 18 | import okhttp3.RequestBody; 19 | 20 | public class LoginViewModel extends WDViewModel { 21 | 22 | public ObservableField remPas = new ObservableField<>(); 23 | public ObservableField mobile = new ObservableField<>(); 24 | public ObservableField pas = new ObservableField<>(); 25 | public MutableLiveData pasVis = new MutableLiveData<>(); 26 | 27 | public void pasVisibility() { 28 | pasVis.setValue(pasVis.getValue() == null ? false : !pasVis.getValue()); 29 | } 30 | 31 | @Override 32 | protected void create() { 33 | super.create(); 34 | boolean rem = WDApplication.getShare().getBoolean("remPas", true); 35 | if (rem) { 36 | remPas.set(rem); 37 | mobile.set(WDApplication.getShare().getString("mobile", "")); 38 | pas.set(WDApplication.getShare().getString("pas", "")); 39 | } 40 | } 41 | 42 | public void debug() { 43 | intentByRouter(Constant.ACTIVITY_URL_DEBUG); 44 | } 45 | 46 | public void login() { 47 | String m = mobile.get(); 48 | String p = pas.get(); 49 | if (TextUtils.isEmpty(m)) { 50 | UIUtils.showToastSafe("请输入正确的手机号"); 51 | return; 52 | } 53 | if (TextUtils.isEmpty(p)) { 54 | UIUtils.showToastSafe("请输入密码"); 55 | return; 56 | } 57 | if (remPas.get()) { 58 | WDApplication.getShare().edit().putString("mobile", m) 59 | .putString("pas", p).commit(); 60 | } 61 | dialog.setValue(true); 62 | 63 | RequestBody body = NetworkManager.convertJsonBody(new String[]{"phone", "pwd"}, new String[]{m, p}); 64 | request(iRequest.login(body), new DataCall() { 65 | @Override 66 | public void success(UserInfo result) { 67 | dialog.setValue(false); 68 | result.setStatus(1);//设置登录状态,保存到数据库 69 | userInfoBox.put(result); 70 | intentByRouter(Constant.ACTIVITY_URL_MAIN); 71 | finish(); 72 | } 73 | 74 | @Override 75 | public void fail(ApiException e) { 76 | dialog.setValue(false); 77 | UIUtils.showToastSafe(e.getCode() + " " + e.getDisplayMessage()); 78 | } 79 | }); 80 | } 81 | 82 | public void register() { 83 | intentByRouter(Constant.ACTIVITY_URL_REGISTER); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /open_login/src/main/java/com/vc/wd/login/vm/RegisterViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.login.vm; 2 | 3 | import android.text.TextUtils; 4 | 5 | import androidx.databinding.ObservableField; 6 | import androidx.lifecycle.MutableLiveData; 7 | 8 | import com.vc.wd.common.core.DataCall; 9 | import com.vc.wd.common.core.WDViewModel; 10 | import com.vc.wd.common.core.exception.ApiException; 11 | import com.vc.wd.common.core.http.NetworkManager; 12 | import com.vc.wd.common.util.UIUtils; 13 | import com.vc.wd.login.request.ILoginRequest; 14 | 15 | import okhttp3.RequestBody; 16 | 17 | public class RegisterViewModel extends WDViewModel { 18 | public ObservableField mobile = new ObservableField<>(); 19 | public ObservableField pas = new ObservableField<>(); 20 | public MutableLiveData pasVis = new MutableLiveData<>(); 21 | 22 | public void pasVisibility(){ 23 | pasVis.setValue(pasVis.getValue()==null?false:!pasVis.getValue()); 24 | } 25 | 26 | public void register() { 27 | String m = mobile.get(); 28 | String p = pas.get(); 29 | if (TextUtils.isEmpty(m)) { 30 | UIUtils.showToastSafe("请输入正确的手机号"); 31 | return; 32 | } 33 | if (TextUtils.isEmpty(p)) { 34 | UIUtils.showToastSafe("请输入密码"); 35 | return; 36 | } 37 | dialog.setValue(true); 38 | 39 | RequestBody body = NetworkManager.convertJsonBody(new String[]{"phone","pwd"},new String[]{m,p}); 40 | request(iRequest.register(body), new DataCall() { 41 | 42 | @Override 43 | public void success(Void data) { 44 | dialog.setValue(false); 45 | UIUtils.showToastSafe("注册成功,请登录"); 46 | finish(); 47 | } 48 | 49 | @Override 50 | public void fail(ApiException e) { 51 | dialog.setValue(false); 52 | UIUtils.showToastSafe(e.getCode() + " " + e.getDisplayMessage()); 53 | } 54 | }); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /open_login/src/main/java/com/vc/wd/login/vm/WelcomeViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.login.vm; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | 6 | import androidx.databinding.ObservableField; 7 | 8 | import com.vc.wd.common.core.WDViewModel; 9 | import com.vc.wd.common.util.Constant; 10 | import com.vc.wd.login.request.ILoginRequest; 11 | 12 | public class WelcomeViewModel extends WDViewModel { 13 | public ObservableField seekText = new ObservableField<>(); 14 | private int count = 3; 15 | 16 | private Handler handler = new Handler() { 17 | @Override 18 | public void handleMessage(Message msg) { 19 | if (count==0){ 20 | if (LOGIN_USER!=null){ 21 | intentByRouter(Constant.ACTIVITY_URL_MAIN);//跳转到主页面 22 | }else{ 23 | intentByRouter(Constant.ACTIVITY_URL_LOGIN);//跳转到登录页 24 | } 25 | finish(); 26 | }else{//消息不能复用,必须新建 27 | seekText.set("跳过"+count+"s"); 28 | count--; 29 | handler.sendEmptyMessageDelayed(1,1000); 30 | } 31 | } 32 | }; 33 | 34 | @Override 35 | protected void create() { 36 | super.create(); 37 | handler.sendEmptyMessage(1); 38 | } 39 | 40 | public void seek(){ 41 | handler.removeMessages(1); 42 | if (LOGIN_USER!=null){ 43 | intentByRouter(Constant.ACTIVITY_URL_MAIN); 44 | }else{ 45 | intentByRouter(Constant.ACTIVITY_URL_LOGIN); 46 | } 47 | finish(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /open_login/src/main/res/drawable-xhdpi/check_f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_login/src/main/res/drawable-xhdpi/check_f.png -------------------------------------------------------------------------------- /open_login/src/main/res/drawable-xhdpi/check_t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_login/src/main/res/drawable-xhdpi/check_t.png -------------------------------------------------------------------------------- /open_login/src/main/res/drawable-xhdpi/login_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_login/src/main/res/drawable-xhdpi/login_bg.png -------------------------------------------------------------------------------- /open_login/src/main/res/drawable-xhdpi/login_icon_eye_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_login/src/main/res/drawable-xhdpi/login_icon_eye_n.png -------------------------------------------------------------------------------- /open_login/src/main/res/drawable-xhdpi/login_icon_lock_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_login/src/main/res/drawable-xhdpi/login_icon_lock_n.png -------------------------------------------------------------------------------- /open_login/src/main/res/drawable-xhdpi/login_icon_phone_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_login/src/main/res/drawable-xhdpi/login_icon_phone_n.png -------------------------------------------------------------------------------- /open_login/src/main/res/drawable-xhdpi/login_icon_verify_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_login/src/main/res/drawable-xhdpi/login_icon_verify_n.png -------------------------------------------------------------------------------- /open_login/src/main/res/drawable/login_btn_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /open_login/src/main/res/drawable/seek_text_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 9 | 10 | -------------------------------------------------------------------------------- /open_login/src/main/res/layout/activity_welcome.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 10 | 11 | 12 | 16 | 17 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /open_login/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ff5f71 4 | 5 | -------------------------------------------------------------------------------- /open_login/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /open_login/src/test/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /open_main/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /open_main/build.gradle: -------------------------------------------------------------------------------- 1 | apply from: '../module.gradle' 2 | 3 | android { 4 | 5 | //组件化运行和总包运行建议使用不同的AndroidManifest文件; 6 | //如果使用默认的AndroidManifest.xml,则去掉下面代码 7 | sourceSets { 8 | main { 9 | if (!allPackage) { 10 | manifest.srcFile 'src/test/AndroidManifest.xml' 11 | } 12 | } 13 | } 14 | } 15 | 16 | constant { 17 | enable false//不进行编译 18 | moduleName "common"//生成新代码存放在的moduleName 19 | packageName "com.vc.wd.common.util"//生成的新代码放在哪个包下 20 | className "Constant"//生成的常量类名 21 | fieldMap = [ 22 | ACTIVITY_URL_MAIN : '/main/MainActivity', 23 | ACTIVITY_URL_ADD_CIRCLE : '/main/AddCircleActivity', 24 | ACTIVITY_URL_SET : '/main/SetActivity' 25 | ]//属性参数 26 | } -------------------------------------------------------------------------------- /open_main/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/consumer-rules.pro -------------------------------------------------------------------------------- /open_main/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 | -------------------------------------------------------------------------------- /open_main/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/activity/AddCircleActivity.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.activity; 2 | 3 | import android.Manifest; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.widget.EditText; 8 | 9 | import androidx.lifecycle.Observer; 10 | import androidx.recyclerview.widget.GridLayoutManager; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | 13 | import com.alibaba.android.arouter.facade.annotation.Route; 14 | import com.tbruyelle.rxpermissions2.RxPermissions; 15 | import com.vc.wd.main.R; 16 | import com.vc.wd.main.adapter.ImageAdapter; 17 | import com.vc.wd.common.core.WDActivity; 18 | import com.vc.wd.main.databinding.ActivityAddCircleBinding; 19 | import com.vc.wd.common.util.Constant; 20 | import com.vc.wd.common.util.StringUtils; 21 | import com.vc.wd.main.vm.AddCircleViewModel; 22 | 23 | @Route(path = Constant.ACTIVITY_URL_ADD_CIRCLE) 24 | public class AddCircleActivity extends WDActivity { 25 | 26 | ImageAdapter mImageAdapter; 27 | final RxPermissions rxPermissions = new RxPermissions(this); // where this is an Activity or Fragment instance 28 | 29 | @Override 30 | protected int getLayoutId() { 31 | return R.layout.activity_add_circle; 32 | } 33 | 34 | @Override 35 | protected void initView(Bundle bundle) { 36 | mImageAdapter = new ImageAdapter(); 37 | mImageAdapter.setSign(1); 38 | mImageAdapter.add(R.drawable.mask_01); 39 | binding.boImageList.setLayoutManager(new GridLayoutManager(this,3)); 40 | binding.boImageList.setAdapter(mImageAdapter); 41 | binding.send.setOnClickListener(view->{ 42 | viewModel.publish(mImageAdapter.getList()); 43 | }); 44 | viewModel.forResult.observe(this, new Observer() { 45 | @Override 46 | public void onChanged(Void aVoid) { 47 | setResult(RESULT_OK); 48 | } 49 | }); 50 | 51 | permessionPhoto(); 52 | } 53 | 54 | public void permessionPhoto(){ 55 | // Must be done during an initialization phase like onCreate 56 | rxPermissions 57 | .request(Manifest.permission.READ_EXTERNAL_STORAGE, 58 | Manifest.permission.WRITE_EXTERNAL_STORAGE) 59 | .subscribe(granted -> { 60 | if (granted) { // Always true pre-M 61 | // I can control the camera now 62 | } else { 63 | // Oups permission denied 64 | permessionPhoto(); 65 | } 66 | }); 67 | } 68 | 69 | @Override 70 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 71 | super.onActivityResult(requestCode, resultCode, data); 72 | if (resultCode == Activity.RESULT_OK) {//resultcode是setResult里面设置的code值 73 | String filePath = getFilePath(null,requestCode,data); 74 | if (!StringUtils.isEmpty(filePath)) { 75 | mImageAdapter.add(filePath); 76 | mImageAdapter.notifyDataSetChanged(); 77 | } 78 | } 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.activity; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.os.Message; 6 | 7 | import androidx.annotation.Nullable; 8 | import androidx.fragment.app.Fragment; 9 | import androidx.fragment.app.FragmentTransaction; 10 | import androidx.lifecycle.Observer; 11 | 12 | import com.alibaba.android.arouter.facade.annotation.Route; 13 | import com.alibaba.android.arouter.launcher.ARouter; 14 | import com.vc.wd.common.core.WDFragment; 15 | import com.vc.wd.main.R; 16 | import com.vc.wd.common.core.WDActivity; 17 | import com.vc.wd.main.databinding.ActivityMainBinding; 18 | import com.vc.wd.main.fragment.CircleFragment; 19 | import com.vc.wd.main.fragment.HomeFragment; 20 | import com.vc.wd.common.util.Constant; 21 | import com.vc.wd.main.vm.MainViewModel; 22 | 23 | /** 24 | * 本页面使用FragmentManager的add/hide/show,如果要使用ViewPager+Fragment,请参照MainFromViewPagerActivity 25 | */ 26 | //@Route(path = Constant.ACTIVITY_URL_MAIN) 27 | public class MainActivity extends WDActivity { 28 | 29 | private HomeFragment homeFragment; 30 | private CircleFragment circleFragment; 31 | private WDFragment meFragment; 32 | private Fragment currentFragment; 33 | 34 | @Override 35 | protected int getLayoutId() { 36 | return R.layout.activity_main; 37 | } 38 | 39 | @Override 40 | protected void initView(Bundle savedInstanceState) { 41 | homeFragment = new HomeFragment(); 42 | circleFragment = new CircleFragment(); 43 | meFragment = (WDFragment) ARouter.getInstance().build(Constant.FRAGMENT_URL_ME).navigation(); 44 | if (meFragment!=null){//加载组件之后再赋值 45 | viewModel.addFragViewModel(meFragment.getFragViewModel()); 46 | } 47 | 48 | viewModel.addFragViewModel(homeFragment.getFragViewModel()); 49 | viewModel.addFragViewModel(circleFragment.getFragViewModel()); 50 | 51 | currentFragment = homeFragment; 52 | FragmentTransaction tx = getSupportFragmentManager().beginTransaction(); 53 | tx.add(R.id.container, homeFragment) 54 | .show(homeFragment).commit(); 55 | viewModel.cId.observe(this, new Observer() { 56 | @Override 57 | public void onChanged(Integer checkedId) { 58 | if (checkedId == R.id.home_btn) { 59 | showFragment(homeFragment); 60 | } else if (checkedId == R.id.circle_btn) { 61 | showFragment(circleFragment); 62 | }else if (checkedId == R.id.me_btn){ 63 | showFragment(meFragment); 64 | } 65 | } 66 | }); 67 | 68 | viewModel.fragDataShare.observe(this, new Observer() { 69 | @Override 70 | public void onChanged(Message message) { 71 | if (message.what==100){ 72 | binding.homeBtn.setChecked(true); 73 | } 74 | } 75 | }); 76 | } 77 | 78 | 79 | /** 80 | * 展示Fragment 81 | */ 82 | private void showFragment(Fragment fragment) { 83 | if (currentFragment != fragment) { 84 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 85 | transaction.hide(currentFragment); 86 | currentFragment = fragment; 87 | if (!fragment.isAdded()) { 88 | transaction.add(R.id.container, fragment).show(fragment).commit(); 89 | } else { 90 | transaction.show(fragment).commit(); 91 | } 92 | } 93 | } 94 | 95 | @Override 96 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { 97 | super.onActivityResult(requestCode, resultCode, data); 98 | circleFragment.onActivityResult(requestCode,resultCode,data); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/activity/SetActivity.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.activity; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.alibaba.android.arouter.facade.annotation.Route; 6 | import com.vc.wd.main.R; 7 | import com.vc.wd.common.core.WDActivity; 8 | import com.vc.wd.common.util.Constant; 9 | import com.vc.wd.main.databinding.ActivitySetBinding; 10 | import com.vc.wd.main.vm.SetViewModel; 11 | 12 | @Route(path = Constant.ACTIVITY_URL_SET) 13 | public class SetActivity extends WDActivity { 14 | @Override 15 | protected int getLayoutId() { 16 | return R.layout.activity_set; 17 | } 18 | 19 | @Override 20 | protected void initView(Bundle bundle) { 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/adapter/CircleAdpater.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.adapter; 2 | 3 | import android.net.Uri; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.databinding.ViewDataBinding; 9 | import androidx.recyclerview.widget.GridLayoutManager; 10 | import com.vc.wd.main.BR; 11 | import com.vc.wd.main.R; 12 | import com.vc.wd.common.bean.Circle; 13 | import com.vc.wd.common.core.WDRecyclerAdapter; 14 | import com.vc.wd.main.databinding.CircleItemBinding; 15 | import com.vc.wd.common.util.DateUtils; 16 | import com.vc.wd.common.util.StringUtils; 17 | import com.vc.wd.common.util.recycleview.SpacingItemDecoration; 18 | 19 | import java.text.ParseException; 20 | import java.util.Arrays; 21 | import java.util.Date; 22 | 23 | public class CircleAdpater extends WDRecyclerAdapter { 24 | 25 | @Override 26 | protected int getLayoutId() { 27 | return R.layout.circle_item; 28 | } 29 | 30 | @Override 31 | protected void initBindingField(ViewGroup parent,ViewDataBinding binding) { 32 | super.initBindingField(parent,binding); 33 | CircleItemBinding b = (CircleItemBinding) binding; 34 | ImageAdapter imageAdapter = new ImageAdapter(); 35 | int space = parent.getContext().getResources() 36 | .getDimensionPixelSize(R.dimen.dip_10);;//图片间距 37 | GridLayoutManager gridLayoutManager = new GridLayoutManager(parent.getContext(), 38 | 3); 39 | b.gridView.addItemDecoration(new SpacingItemDecoration(space)); 40 | b.gridView.setLayoutManager(gridLayoutManager); 41 | b.gridView.setAdapter(imageAdapter); 42 | 43 | //由于没有自定义holder,需要灵活使用复杂对象binding寄存 44 | b.setVariable(BR.imageAdapter,imageAdapter); 45 | b.setVariable(BR.layoutManager,gridLayoutManager); 46 | } 47 | 48 | @Override 49 | protected void bindView(ViewDataBinding binding,Circle circle, int position) { 50 | CircleItemBinding b = (CircleItemBinding) binding; 51 | //不建议调用binding.setVariable(), 52 | // 由于xml暂时不包含时间计算,不能进行列表嵌套处理等复杂操作, 53 | // 所以尽量不要给自己增加难度,像下面这样写代码会让你略去xml中填充值碰到不必要的麻烦 54 | b.image.setImageURI(Uri.parse(circle.getHeadPic())); 55 | b.nickname.setText(circle.getNickName()); 56 | try { 57 | b.time.setText(DateUtils.dateFormat(new Date(circle.getCreateTime()),DateUtils.MINUTE_PATTERN)); 58 | } catch (ParseException e) { 59 | e.printStackTrace(); 60 | } 61 | b.text.setText(circle.getContent()); 62 | 63 | if (StringUtils.isEmpty(circle.getImage())){ 64 | b.gridView.setVisibility(View.GONE); 65 | }else{ 66 | b.gridView.setVisibility(View.VISIBLE); 67 | String[] images = circle.getImage().split(","); 68 | 69 | int imageCount = images.length; 70 | 71 | int colNum;//列数 72 | if (imageCount == 1){ 73 | colNum = 1; 74 | }else if (imageCount == 2||imageCount == 4){ 75 | colNum = 2; 76 | }else { 77 | colNum = 3; 78 | } 79 | b.getImageAdapter().clear();//清空 80 | b.getImageAdapter().addStringListAll(Arrays.asList(images)); 81 | b.getLayoutManager().setSpanCount(colNum);//设置列数 82 | 83 | 84 | b.getImageAdapter().notifyDataSetChanged(); 85 | } 86 | 87 | if (circle.getWhetherGreat() == 1){ 88 | b.priseImage.setImageResource(R.drawable.common_btn_prise_s); 89 | }else{ 90 | b.priseImage.setImageResource(R.drawable.common_btn_prise_n); 91 | } 92 | 93 | b.priseCount.setText(circle.getGreatNum()+""); 94 | b.priseLayout.setTag(position); 95 | b.priseLayout.setOnClickListener(new View.OnClickListener() { 96 | @Override 97 | public void onClick(View v) { 98 | if (greatListener!=null){ 99 | int p = (int) v.getTag(); 100 | greatListener.great(p,getItem(p)); 101 | } 102 | } 103 | }); 104 | } 105 | 106 | private GreatListener greatListener; 107 | 108 | public void setGreatListener(GreatListener greatListener) { 109 | this.greatListener = greatListener; 110 | } 111 | 112 | public interface GreatListener{ 113 | void great(int position, Circle circle); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/adapter/CommodityAdpater.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.adapter; 2 | 3 | import android.content.Context; 4 | import android.net.Uri; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.TextView; 8 | 9 | import androidx.annotation.NonNull; 10 | import androidx.databinding.ViewDataBinding; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | 13 | import com.facebook.drawee.view.SimpleDraweeView; 14 | import com.vc.wd.main.R; 15 | import com.vc.wd.common.bean.shop.Commodity; 16 | import com.vc.wd.common.core.WDRecyclerAdapter; 17 | import com.vc.wd.main.databinding.FashionItemBinding; 18 | import com.vc.wd.main.databinding.HotItemBinding; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | public class CommodityAdpater extends WDRecyclerAdapter { 24 | 25 | public static final int HOT_TYPE = 0; 26 | public static final int FASHION_TYPE = 1; 27 | private int type; 28 | 29 | public CommodityAdpater( int type){ 30 | this.type = type; 31 | } 32 | 33 | @Override 34 | protected int getLayoutId() { 35 | if (type == HOT_TYPE) { 36 | return R.layout.hot_item; 37 | }else { 38 | return R.layout.fashion_item; 39 | } 40 | } 41 | 42 | @Override 43 | protected void bindView(ViewDataBinding binding,Commodity commodity, int position) { 44 | if (type == HOT_TYPE) { 45 | HotItemBinding h = (HotItemBinding) binding; 46 | setValue(commodity,h.image,h.price,h.text,h.getRoot()); 47 | }else { 48 | FashionItemBinding f = (FashionItemBinding) binding; 49 | setValue(commodity,f.image,f.price,f.text,f.getRoot()); 50 | } 51 | } 52 | 53 | private void setValue(Commodity commodity,SimpleDraweeView image,TextView price,TextView text,View itemView){ 54 | image.setImageURI(Uri.parse(commodity.getMasterPic())); 55 | price.setText(commodity.getPrice()+""); 56 | text.setText(commodity.getCommodityName()); 57 | 58 | itemView.setOnClickListener(new View.OnClickListener() { 59 | @Override 60 | public void onClick(View v) { 61 | 62 | //获取分类id 63 | // intent.putExtras("id",) 64 | 65 | } 66 | }); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/adapter/HomeBannerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.adapter; 2 | 3 | import android.net.Uri; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import androidx.annotation.NonNull; 9 | import androidx.databinding.DataBindingUtil; 10 | import androidx.databinding.ViewDataBinding; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | 13 | import com.vc.wd.common.bean.Banner; 14 | import com.vc.wd.main.R; 15 | import com.vc.wd.main.databinding.BannerItemBinding; 16 | import com.youth.banner.adapter.BannerAdapter; 17 | 18 | import java.util.List; 19 | 20 | public class HomeBannerAdapter extends BannerAdapter { 21 | 22 | public HomeBannerAdapter(List mDatas) { 23 | //设置数据,也可以调用banner提供的方法,或者自己在adapter中实现 24 | super(mDatas); 25 | } 26 | 27 | //更新数据 28 | public void updateData(List data) { 29 | //这里的代码自己发挥,比如如下的写法等等 30 | mDatas.clear(); 31 | mDatas.addAll(data); 32 | notifyDataSetChanged(); 33 | } 34 | 35 | 36 | //创建ViewHolder,可以用viewType这个字段来区分不同的ViewHolder 37 | @Override 38 | public ImageHolder onCreateHolder(ViewGroup parent, int viewType) { 39 | ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), 40 | R.layout.banner_item, parent, false); 41 | return new ImageHolder(binding.getRoot()); 42 | } 43 | 44 | @Override 45 | public void onBindView(ImageHolder holder, Banner data, int position, int size) { 46 | BannerItemBinding binding = DataBindingUtil.bind(holder.itemView); 47 | binding.bannerImage.setImageURI(Uri.parse(data.getImageUrl())); 48 | } 49 | 50 | static class ImageHolder extends RecyclerView.ViewHolder { 51 | 52 | public ImageHolder(@NonNull View view) { 53 | super(view); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/adapter/ImageAdapter.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.adapter; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.view.View; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.databinding.ViewDataBinding; 9 | 10 | import com.vc.wd.main.R; 11 | import com.vc.wd.common.core.WDActivity; 12 | import com.vc.wd.common.core.WDRecyclerAdapter; 13 | import com.vc.wd.main.databinding.CircleImageItemBinding; 14 | import com.vc.wd.common.util.UIUtils; 15 | 16 | import java.util.List; 17 | 18 | public class ImageAdapter extends WDRecyclerAdapter { 19 | 20 | private int sign;//0:普通点击,1自定义 21 | 22 | public void addStringListAll(List list) { 23 | mList.addAll(list); 24 | } 25 | 26 | public void setSign(int sign) { 27 | this.sign = sign; 28 | } 29 | 30 | @Override 31 | protected int getLayoutId() { 32 | return R.layout.circle_image_item; 33 | } 34 | 35 | @Override 36 | protected void bindView(ViewDataBinding b,Object o, int position) { 37 | CircleImageItemBinding binding = (CircleImageItemBinding) b; 38 | if (o instanceof String) { 39 | String imageUrl = (String) o; 40 | if (imageUrl.contains("http:")) {//加载http 41 | binding.circleImage.setImageURI(Uri.parse(imageUrl)); 42 | } else {//加载sd卡 43 | Uri uri = Uri.parse("file://" + imageUrl); 44 | binding.circleImage.setImageURI(uri); 45 | } 46 | } else {//加载资源文件 47 | int id = (int) o; 48 | Uri uri = Uri.parse("res://com.dingtao.rrmmp/" + id); 49 | binding.circleImage.setImageURI(uri); 50 | } 51 | 52 | binding.getRoot().setTag(position); 53 | binding.getRoot().setOnClickListener(new View.OnClickListener() { 54 | @Override 55 | public void onClick(View v) { 56 | if (sign == 1) {//自定义点击 57 | int p = (int)v.getTag(); 58 | if (p == 0) { 59 | 60 | Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 61 | intent.addCategory(Intent.CATEGORY_OPENABLE); 62 | intent.setType("image/*"); 63 | WDActivity.getForegroundActivity().startActivityForResult(intent, WDActivity.PHOTO); 64 | } else { 65 | UIUtils.showToastSafe("点击了图片"); 66 | } 67 | } else { 68 | UIUtils.showToastSafe("点击了图片"); 69 | } 70 | } 71 | }); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/fragment/CircleFragment.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.fragment; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import androidx.annotation.Nullable; 8 | import androidx.lifecycle.Observer; 9 | import androidx.recyclerview.widget.GridLayoutManager; 10 | 11 | import com.jcodecraeer.xrecyclerview.XRecyclerView; 12 | import com.vc.wd.main.R; 13 | import com.vc.wd.main.adapter.CircleAdpater; 14 | import com.vc.wd.common.bean.Circle; 15 | import com.vc.wd.common.core.WDFragment; 16 | import com.vc.wd.main.databinding.FragCircleBinding; 17 | import com.vc.wd.common.util.Constant; 18 | import com.vc.wd.common.util.UIUtils; 19 | import com.vc.wd.common.util.recycleview.SpacingItemDecoration; 20 | import com.vc.wd.main.vm.CircleViewModel; 21 | import com.vc.wd.main.vm.MainViewModel; 22 | 23 | import java.util.List; 24 | 25 | public class CircleFragment extends WDFragment implements XRecyclerView.LoadingListener, CircleAdpater.GreatListener { 26 | 27 | public static boolean addCircle;//如果添加成功,则为true 28 | 29 | private CircleAdpater mCircleAdapter; 30 | 31 | @Override 32 | protected CircleViewModel initFragViewModel() { 33 | return new CircleViewModel(); 34 | } 35 | 36 | @Override 37 | protected int getLayoutId() { 38 | return R.layout.frag_circle; 39 | } 40 | 41 | @Override 42 | protected void initView(Bundle bundle) { 43 | 44 | mCircleAdapter = new CircleAdpater(); 45 | 46 | binding.circleList.setLayoutManager(new GridLayoutManager(getContext(), 1)); 47 | 48 | int space = getResources().getDimensionPixelSize(R.dimen.dip_20); 49 | 50 | binding.circleList.addItemDecoration(new SpacingItemDecoration(space)); 51 | 52 | mCircleAdapter.setGreatListener(this); 53 | 54 | binding.circleList.setAdapter(mCircleAdapter); 55 | binding.circleList.setLoadingListener(this); 56 | 57 | viewModel.circleData.observe(getActivity(), new Observer>() { 58 | @Override 59 | public void onChanged(List circles) { 60 | if (circles == null) 61 | return; 62 | binding.circleList.refreshComplete(); 63 | binding.circleList.loadMoreComplete(); 64 | //添加列表并刷新 65 | if (viewModel.getCirclePage() == 1) { 66 | mCircleAdapter.clear(); 67 | } 68 | mCircleAdapter.addAll(circles); 69 | mCircleAdapter.notifyDataSetChanged(); 70 | } 71 | }); 72 | 73 | viewModel.circleGreat.observe(getActivity(), new Observer() { 74 | @Override 75 | public void onChanged(Object[] objects) { 76 | if (objects==null){ 77 | UIUtils.showToastSafe("点赞失败"); 78 | }else{ 79 | int position = (int) objects[1]; 80 | UIUtils.showToastSafe("点击" + position + " adapter条目:" + mCircleAdapter.getItemCount() 81 | + " recycler条目:" + binding.circleList.getChildCount()); 82 | Circle circle = (Circle) objects[2]; 83 | Circle nowCircle = mCircleAdapter.getItem(position); 84 | if (nowCircle.getId() == circle.getId()) { 85 | nowCircle.setGreatNum(nowCircle.getGreatNum() + 1); 86 | nowCircle.setWhetherGreat(1); 87 | mCircleAdapter.notifyItemChanged(position + 1, 0); 88 | } 89 | } 90 | } 91 | }); 92 | 93 | viewModel.addCircle.observe(getActivity(), new Observer() { 94 | @Override 95 | public void onChanged(Void aVoid) { 96 | intentForResultByRouter(Constant.ACTIVITY_URL_ADD_CIRCLE,100); 97 | } 98 | }); 99 | 100 | // 设置数据 101 | binding.circleList.refresh(); 102 | } 103 | 104 | @Override 105 | public void onResume() { 106 | super.onResume(); 107 | if (addCircle) {//publish new message,so you have to refresh 108 | addCircle = false; 109 | binding.circleList.refresh(); 110 | } 111 | } 112 | 113 | @Override 114 | public void onRefresh() { 115 | if (viewModel.isCircleRunning()) { 116 | binding.circleList.refreshComplete(); 117 | return; 118 | } 119 | viewModel.requestCircleData(true); 120 | } 121 | 122 | @Override 123 | public void onLoadMore() { 124 | if (viewModel.isCircleRunning()) { 125 | binding.circleList.loadMoreComplete(); 126 | return; 127 | } 128 | viewModel.requestCircleData(false); 129 | } 130 | 131 | @Override 132 | public void great(int position, Circle circle) { 133 | viewModel.reqeustGreatCircle(position, circle); 134 | } 135 | 136 | @Override 137 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { 138 | super.onActivityResult(requestCode, resultCode, data); 139 | if (requestCode==100&&resultCode== Activity.RESULT_OK){ 140 | binding.circleList.refresh(); 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/fragment/HomeFragment.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.os.Message; 5 | 6 | import androidx.lifecycle.Observer; 7 | import androidx.recyclerview.widget.GridLayoutManager; 8 | 9 | import com.vc.wd.common.util.UIUtils; 10 | import com.vc.wd.main.R; 11 | import com.vc.wd.main.adapter.CommodityAdpater; 12 | import com.vc.wd.common.bean.Banner; 13 | import com.vc.wd.common.bean.shop.HomeList; 14 | import com.vc.wd.common.core.WDFragment; 15 | import com.vc.wd.main.adapter.HomeBannerAdapter; 16 | import com.vc.wd.main.databinding.FragMainBinding; 17 | import com.vc.wd.common.util.recycleview.SpacingItemDecoration; 18 | import com.vc.wd.main.vm.HomeViewModel; 19 | import com.vc.wd.main.vm.MainViewModel; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | public class HomeFragment extends WDFragment { 25 | 26 | private CommodityAdpater mHotAdapter, mFashionAdapter, mLifeAdapter; 27 | private HomeBannerAdapter mBannerAdapter; 28 | 29 | @Override 30 | protected HomeViewModel initFragViewModel() { 31 | return new HomeViewModel(); 32 | } 33 | 34 | @Override 35 | protected int getLayoutId() { 36 | return R.layout.frag_main; 37 | } 38 | 39 | @Override 40 | protected void initView(Bundle bundle) { 41 | mHotAdapter = new CommodityAdpater(CommodityAdpater.HOT_TYPE); 42 | mFashionAdapter = new CommodityAdpater(CommodityAdpater.FASHION_TYPE); 43 | mLifeAdapter = new CommodityAdpater(CommodityAdpater.HOT_TYPE); 44 | 45 | binding.hotList.setLayoutManager(new GridLayoutManager(getContext(), 3)); 46 | binding.fashionList.setLayoutManager(new GridLayoutManager(getContext(), 1)); 47 | binding.lifeList.setLayoutManager(new GridLayoutManager(getContext(), 2)); 48 | 49 | int space = getResources().getDimensionPixelSize(R.dimen.dip_10); 50 | 51 | binding.hotList.addItemDecoration(new SpacingItemDecoration(space)); 52 | binding.fashionList.addItemDecoration(new SpacingItemDecoration(space)); 53 | binding.lifeList.addItemDecoration(new SpacingItemDecoration(space)); 54 | 55 | binding.hotList.setAdapter(mHotAdapter); 56 | binding.fashionList.setAdapter(mFashionAdapter); 57 | binding.lifeList.setAdapter(mLifeAdapter); 58 | 59 | mBannerAdapter = new HomeBannerAdapter(new ArrayList()); 60 | binding.banner.setAdapter(mBannerAdapter) 61 | .addBannerLifecycleObserver(this) 62 | .setDelayTime(3000) 63 | .setBannerGalleryMZ(20); 64 | 65 | viewModel.bannerData.observe(this, new Observer>() { 66 | @Override 67 | public void onChanged(List banners) { 68 | mBannerAdapter.updateData(banners); 69 | } 70 | }); 71 | 72 | viewModel.homeListData.observe(this, new Observer() { 73 | @Override 74 | public void onChanged(HomeList data) { 75 | mHotAdapter.addAll(data.getRxxp().getCommodityList()); 76 | mFashionAdapter.addAll(data.getMlss().getCommodityList()); 77 | mLifeAdapter.addAll(data.getPzsh().getCommodityList()); 78 | mHotAdapter.notifyDataSetChanged(); 79 | mFashionAdapter.notifyDataSetChanged(); 80 | mLifeAdapter.notifyDataSetChanged(); 81 | } 82 | }); 83 | 84 | viewModel.fragDataShare.observe(this, new Observer() { 85 | @Override 86 | public void onChanged(Message message) { 87 | if (message.what==100){//提示我的页面发送过来的消息,实现数据共享 88 | UIUtils.showToastSafe((String) message.obj); 89 | } 90 | } 91 | }); 92 | } 93 | 94 | @Override 95 | public void onResume() { 96 | super.onResume(); 97 | binding.banner.start(); 98 | } 99 | 100 | @Override 101 | public void onPause() { 102 | super.onPause(); 103 | binding.banner.stop(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/fragment/TestFragment.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.fragment; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.vc.wd.common.core.WDFragment; 6 | import com.vc.wd.main.R; 7 | import com.vc.wd.main.databinding.FragTestBinding; 8 | import com.vc.wd.main.vm.TestViewModel; 9 | 10 | public class TestFragment extends WDFragment { 11 | @Override 12 | protected TestViewModel initFragViewModel() { 13 | return new TestViewModel(); 14 | } 15 | 16 | @Override 17 | protected int getLayoutId() { 18 | return R.layout.frag_test; 19 | } 20 | 21 | @Override 22 | protected void initView(Bundle savedInstanceState) { 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/request/IMainRequest.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.request; 2 | 3 | import com.vc.wd.common.bean.Banner; 4 | import com.vc.wd.common.bean.Circle; 5 | import com.vc.wd.common.bean.Result; 6 | import com.vc.wd.common.bean.UserInfo; 7 | import com.vc.wd.common.bean.shop.HomeList; 8 | 9 | import java.util.List; 10 | 11 | import io.reactivex.Observable; 12 | import okhttp3.MultipartBody; 13 | import retrofit2.http.Body; 14 | import retrofit2.http.Field; 15 | import retrofit2.http.FormUrlEncoded; 16 | import retrofit2.http.GET; 17 | import retrofit2.http.Header; 18 | import retrofit2.http.POST; 19 | import retrofit2.http.PUT; 20 | import retrofit2.http.Path; 21 | import retrofit2.http.Query; 22 | 23 | /** 24 | * desc 25 | * author VcStrong 26 | * github VcStrong 27 | * date 2020/5/28 1:42 PM 28 | */ 29 | public interface IMainRequest { 30 | 31 | /** 32 | * banner 33 | */ 34 | @GET("commodity/v1/bannerShow") 35 | Observable>> bannerShow(); 36 | 37 | /** 38 | * 首页商品列表 39 | */ 40 | @GET("commodity/v1/commodityList") 41 | Observable> commodityList(); 42 | 43 | /** 44 | * 圈子 45 | */ 46 | @GET("circle/v1/findCircleList") 47 | Observable>> findCircleList( 48 | @Header("userId") long userId, 49 | @Header("sessionId") String sessionId, 50 | @Query("page") int page, 51 | @Query("count") int count); 52 | 53 | /** 54 | * 圈子点赞 55 | */ 56 | @FormUrlEncoded 57 | @POST("circle/verify/v1/addCircleGreat") 58 | Observable addCircleGreat( 59 | @Header("userId") long userId, 60 | @Header("sessionId") String sessionId, 61 | @Field("circleId") long circleId); 62 | 63 | /** 64 | * 发布圈子 65 | */ 66 | @POST("circle/verify/v1/releaseCircle") 67 | Observable releaseCircle(@Header("userId") long userId, 68 | @Header("sessionId") String sessionId, 69 | @Body MultipartBody body); 70 | } 71 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/vm/AddCircleViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.vm; 2 | 3 | import androidx.databinding.ObservableField; 4 | 5 | import com.vc.wd.common.core.DataCall; 6 | import com.vc.wd.common.core.WDViewModel; 7 | import com.vc.wd.common.core.exception.ApiException; 8 | import com.vc.wd.common.util.UIUtils; 9 | import com.vc.wd.main.request.IMainRequest; 10 | 11 | import java.io.File; 12 | import java.util.List; 13 | 14 | import okhttp3.MediaType; 15 | import okhttp3.MultipartBody; 16 | import okhttp3.RequestBody; 17 | 18 | public class AddCircleViewModel extends WDViewModel { 19 | 20 | public ObservableField content = new ObservableField<>(); 21 | 22 | public void publish(List list){ 23 | MultipartBody.Builder builder = new MultipartBody.Builder() 24 | .setType(MultipartBody.FORM); 25 | builder.addFormDataPart("content", content.get()); 26 | builder.addFormDataPart("commodityId", "1"); 27 | if (list.size()>1) { 28 | for (int i = 1; i < list.size(); i++) { 29 | File file = new File((String) list.get(i)); 30 | builder.addFormDataPart("image", file.getName(), 31 | RequestBody.create(MediaType.parse("multipart/octet-stream"), 32 | file)); 33 | } 34 | } 35 | request(iRequest.releaseCircle(LOGIN_USER.getUserId(), 36 | LOGIN_USER.getSessionId(),builder.build()), 37 | new DataCall() { 38 | @Override 39 | public void success(Object data) { 40 | forResult.setValue(null); 41 | finish(); 42 | } 43 | 44 | @Override 45 | public void fail(ApiException e) { 46 | UIUtils.showToastSafe(e.getCode()+" "+e.getDisplayMessage()); 47 | } 48 | }); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/vm/CircleViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.vm; 2 | 3 | import androidx.lifecycle.MutableLiveData; 4 | 5 | import com.vc.wd.common.bean.Circle; 6 | import com.vc.wd.common.core.DataCall; 7 | import com.vc.wd.common.core.WDFragViewModel; 8 | import com.vc.wd.common.core.exception.ApiException; 9 | import com.vc.wd.common.util.Constant; 10 | import com.vc.wd.main.request.IMainRequest; 11 | 12 | import java.util.List; 13 | 14 | 15 | public class CircleViewModel extends WDFragViewModel { 16 | public MutableLiveData> circleData = new MutableLiveData<>(); 17 | public MutableLiveData addCircle = new MutableLiveData<>(); 18 | 19 | public MutableLiveData circleGreat = new MutableLiveData<>(); 20 | 21 | public void addCircle() { 22 | addCircle.setValue(null); 23 | } 24 | 25 | private boolean circleRunning; 26 | private int circlePage; 27 | public void requestCircleData(boolean isRefresh){ 28 | if (circleRunning) 29 | return; 30 | 31 | if (isRefresh){ 32 | circlePage = 1; 33 | }else{ 34 | circlePage++; 35 | } 36 | circleRunning = true; 37 | request(iRequest.findCircleList(LOGIN_USER.getUserId() 38 | ,LOGIN_USER.getSessionId(),circlePage,20), 39 | new DataCall>(){ 40 | 41 | @Override 42 | public void success(List data) { 43 | circleRunning = false; 44 | circleData.setValue(data); 45 | } 46 | 47 | @Override 48 | public void fail(ApiException data) { 49 | circleRunning = false; 50 | circleData.setValue(null); 51 | } 52 | }); 53 | } 54 | 55 | public boolean isCircleRunning() { 56 | return circleRunning; 57 | } 58 | 59 | public int getCirclePage() { 60 | return circlePage; 61 | } 62 | 63 | public void reqeustGreatCircle(final int position, final Circle circle) { 64 | request(iRequest.addCircleGreat(LOGIN_USER.getUserId(), LOGIN_USER.getSessionId(), circle.getId()), 65 | new DataCall() { 66 | @Override 67 | public void success(Object data) { 68 | circleGreat.setValue(new Object[]{position,circle}); 69 | } 70 | 71 | @Override 72 | public void fail(ApiException data) { 73 | circleGreat.setValue(null); 74 | } 75 | }); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/vm/HomeViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.vm; 2 | 3 | import androidx.lifecycle.MutableLiveData; 4 | 5 | import com.vc.wd.common.bean.Banner; 6 | import com.vc.wd.common.bean.shop.HomeList; 7 | import com.vc.wd.common.core.DataCall; 8 | import com.vc.wd.common.core.WDFragViewModel; 9 | import com.vc.wd.common.core.exception.ApiException; 10 | import com.vc.wd.common.util.Constant; 11 | import com.vc.wd.main.request.IMainRequest; 12 | 13 | import java.util.List; 14 | 15 | 16 | public class HomeViewModel extends WDFragViewModel { 17 | 18 | public MutableLiveData> bannerData = new MutableLiveData<>(); 19 | public MutableLiveData homeListData = new MutableLiveData<>(); 20 | 21 | @Override 22 | protected void create() { 23 | super.create(); 24 | request(iRequest.bannerShow(), new DataCall>() { 25 | @Override 26 | public void success(List data) { 27 | bannerData.setValue(data); 28 | } 29 | 30 | @Override 31 | public void fail(ApiException e) { 32 | 33 | } 34 | }); 35 | 36 | request(iRequest.commodityList(),new DataCall(){ 37 | 38 | @Override 39 | public void success(HomeList data) { 40 | homeListData.setValue(data); 41 | } 42 | 43 | @Override 44 | public void fail(ApiException data) { 45 | 46 | } 47 | }); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/vm/MainFromViewPagerViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.vm; 2 | 3 | import android.view.View; 4 | import android.widget.RadioGroup; 5 | 6 | import androidx.databinding.ObservableField; 7 | import androidx.lifecycle.MutableLiveData; 8 | 9 | import com.vc.wd.common.core.WDViewModel; 10 | import com.vc.wd.common.util.Constant; 11 | import com.vc.wd.main.BuildConfig; 12 | import com.vc.wd.main.request.IMainRequest; 13 | 14 | public class MainFromViewPagerViewModel extends WDViewModel { 15 | public MutableLiveData cId = new MutableLiveData<>(); 16 | public ObservableField debug = new ObservableField<>(); 17 | 18 | @Override 19 | protected void create() { 20 | super.create(); 21 | debug.set(BuildConfig.DEBUG); 22 | } 23 | 24 | public void click(View view) { 25 | cId.setValue(view.getId()); 26 | } 27 | 28 | public void debug() { 29 | intentByRouter(Constant.ACTIVITY_URL_DEBUG); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/vm/MainViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.vm; 2 | 3 | import android.content.Intent; 4 | import android.widget.RadioGroup; 5 | 6 | import androidx.databinding.ObservableField; 7 | import androidx.lifecycle.MutableLiveData; 8 | 9 | import com.vc.wd.common.bean.Banner; 10 | import com.vc.wd.common.bean.Circle; 11 | import com.vc.wd.common.bean.shop.HomeList; 12 | import com.vc.wd.common.core.DataCall; 13 | import com.vc.wd.common.core.WDViewModel; 14 | import com.vc.wd.common.core.exception.ApiException; 15 | import com.vc.wd.common.util.Constant; 16 | import com.vc.wd.main.BuildConfig; 17 | import com.vc.wd.main.request.IMainRequest; 18 | 19 | import java.util.List; 20 | 21 | public class MainViewModel extends WDViewModel { 22 | public MutableLiveData cId = new MutableLiveData<>(); 23 | public ObservableField debug = new ObservableField<>(); 24 | 25 | @Override 26 | protected void create() { 27 | super.create(); 28 | debug.set(BuildConfig.DEBUG); 29 | } 30 | 31 | public void onCheckedChanged(RadioGroup group, int checkId) { 32 | cId.setValue(checkId); 33 | } 34 | 35 | public void debug() { 36 | intentByRouter(Constant.ACTIVITY_URL_DEBUG); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/vm/SetViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.vm; 2 | 3 | import android.content.Intent; 4 | 5 | import com.alibaba.android.arouter.launcher.ARouter; 6 | import com.vc.wd.common.core.WDViewModel; 7 | import com.vc.wd.common.util.Constant; 8 | import com.vc.wd.main.request.IMainRequest; 9 | 10 | public class SetViewModel extends WDViewModel { 11 | 12 | public void logout(){ 13 | userInfoBox.remove(LOGIN_USER); 14 | //Intent清除栈FLAG_ACTIVITY_CLEAR_TASK会把当前栈内所有Activity清空; 15 | //FLAG_ACTIVITY_NEW_TASK配合使用,才能完成跳转 16 | ARouter.getInstance().build(Constant.ACTIVITY_URL_LOGIN) 17 | .withFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK) 18 | .navigation(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /open_main/src/main/java/com/vc/wd/main/vm/TestViewModel.java: -------------------------------------------------------------------------------- 1 | package com.vc.wd.main.vm; 2 | 3 | import com.vc.wd.common.core.WDFragViewModel; 4 | import com.vc.wd.main.request.IMainRequest; 5 | 6 | public class TestViewModel extends WDFragViewModel { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/btn_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/btn_close.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/btn_send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/btn_send.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_btn_more_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_btn_more_n.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_btn_prise_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_btn_prise_n.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_btn_prise_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_btn_prise_s.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_nav_btn_back_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_nav_btn_back_n.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_nav_btn_menu_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_nav_btn_menu_n.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_nav_btn_search_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_nav_btn_search_n.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_tab_btn_circle_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_tab_btn_circle_n.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_tab_btn_circle_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_tab_btn_circle_s.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_tab_btn_home_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_tab_btn_home_n.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_tab_btn_home_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_tab_btn_home_s.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_tab_btn_list_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_tab_btn_list_n.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_tab_btn_list_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_tab_btn_list_s.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_tab_btn_my_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_tab_btn_my_n.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_tab_btn_my_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_tab_btn_my_s.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/common_tab_btn_shop_cart_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/common_tab_btn_shop_cart_n.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/main_frag_fashion_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/main_frag_fashion_bg.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/main_frag_hot_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/main_frag_hot_bg.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/main_frag_life_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/main_frag_life_bg.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable-xhdpi/mask_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable-xhdpi/mask_01.png -------------------------------------------------------------------------------- /open_main/src/main/res/drawable/common_tab_btn_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /open_main/src/main/res/drawable/common_tab_btn_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /open_main/src/main/res/drawable/common_tab_btn_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /open_main/src/main/res/drawable/common_tab_btn_my.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /open_main/src/main/res/drawable/item_layer_shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 13 | 14 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 34 | 35 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /open_main/src/main/res/drawable/rectangle.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcStrong/JetpackMVVM/c31a14d7e19dc7176c378e84464280bbe6e8087f/open_main/src/main/res/drawable/rectangle.9.png -------------------------------------------------------------------------------- /open_main/src/main/res/layout/activity_add_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 17 | 18 | 21 | 22 | 26 | 27 | 34 | 35 | 39 | 40 | 41 | 42 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 74 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /open_main/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 16 | 17 | 25 | 26 | 27 | 28 |