-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wumeng1
authored and
wumeng1
committed
Jun 17, 2022
0 parents
commit 90297b8
Showing
138 changed files
with
7,200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
/.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# MVM | ||
[](https://jitpack.io/#mirkowu/mvm) | ||
----------------------------------- | ||
### 前言 | ||
M:Model 数据层 | ||
V:View 显示层 | ||
M:Mediator 中间层 | ||
|
||
|
||
无论是MVP中的Presenter 还是MVVM中的ViewModel 其本质上都相当于中间人的性质,是连接Model层和View层的媒介。 | ||
中间层分别持有Model和View,我们在中间层 得到Model层实例获取数据,再通过回调的方式传递给View层,这里的回调无论是 | ||
接口回调,还是Observer等观察者模式,数据绑定,EventBus等类型的传递,其本质都是为了将数据传递给View层,在这方面无论是MVP、 | ||
MVVM或衍生出来的变种其行为目的都是一致的。 | ||
但由于数据的保存,处理方式,中间层的状态及更新UI方式的不同,才演化出这些架构。 | ||
|
||
回顾我们所写过的MVP,MVVM等模式,我们会发现其相同之处,都是作为一个中间层来进行数据交互,而最根本的解构方面似乎还是 | ||
很鸡肋,完全没达到传说中的高内聚低耦合,具体代码还要看个人水平。 | ||
|
||
### 使用 | ||
依赖jitpack | ||
``` | ||
maven { url 'https://jitpack.io' } | ||
``` | ||
|
||
//你可以直接使用 | ||
``` | ||
implementation("com.github.mirkowu:mvm:$ext.mvm_version") { //总仓库 | ||
exclude group: "com.github.mirkowu.mvm", module: "lib_bugly" //bugly 包含升级SDK 二选一 | ||
//exclude group: "com.github.mirkowu.mvm", module: "lib_crash" //bugly 不含升级SDK 二选一 | ||
} | ||
``` | ||
//也可以按需索取,部分库之间有依赖,请一同依赖 | ||
``` | ||
implementation "com.github.mirkowu.mvm:lib_base:$ext.mvm_version" //基础库 | ||
implementation "com.github.mirkowu.mvm:lib_widget:$ext.mvm_version" //UI组件库 | ||
implementation "com.github.mirkowu.mvm:lib_network:$ext.mvm_version" //网络库 | ||
implementation "com.github.mirkowu.mvm:lib_util:$ext.mvm_version" //工具库 | ||
implementation "com.github.mirkowu.mvm:lib_image:$ext.mvm_version" //图片加载库(默认glide) | ||
implementation "com.github.mirkowu.mvm:lib_webview:$ext.mvm_version" //X5 + JsBridge 的WebView | ||
implementation "com.github.mirkowu.mvm:lib_photo:$ext.mvm_version" //相册选择库 | ||
implementation "com.github.mirkowu.mvm:lib_qr:$ext.mvm_version" //二维码扫描 | ||
implementation "com.github.mirkowu.mvm:lib_camera:$ext.mvm_version" //摄像头 | ||
implementation "com.github.mirkowu.mvm:lib_upgrade:$ext.mvm_version" //版本更新(弹窗和下载安装功能) | ||
implementation "com.github.mirkowu.mvm:lib_stat:$ext.mvm_version" //umeng统计 | ||
implementation "com.github.mirkowu.mvm:lib_screen:$ext.mvm_version" //屏幕适配 | ||
implementation "com.github.mirkowu.mvm:lib_bugly:$ext.mvm_version" //bugly 包含升级SDK 二选一 | ||
// implementation "com.github.mirkowu.mvm:lib_crash:$ext.mvm_version" //bugly 不含升级SDK 二选一 | ||
``` | ||
|
||
你可以在Application的onCreate()中进行对应的初始化 | ||
```java | ||
LogUtil.init(BuildConfig.DEBUG); | ||
|
||
WebViewUtil.initMultiProcess(this); | ||
|
||
//换成你自己的bugly账号 请根据官方SDK对接,此处只做演示 | ||
BuglyManager.init(this, "buglyId", BuildConfig.DEBUG); | ||
|
||
/*** 防止初始化多次,视项目情况设置 | ||
* 需要多进程初始化的方法此方法前面 不需要多进程处理的放在后面 | ||
*/ | ||
if (!ProcessUtils.isMainProcess()) { | ||
return; | ||
} | ||
|
||
|
||
|
||
//umeng 请根据官方SDK对接,此处只做演示 | ||
UmengManager.preInit(this, "id", "umeng", BuildConfig.DEBUG); | ||
UmengManager.init(this, null); | ||
|
||
//屏幕适配 | ||
AutoSizeManager.getInstance().setConfig(this); | ||
|
||
//RxJava2 取消订阅后,抛出的异常无法捕获,导致程序崩溃 | ||
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() { | ||
@Override | ||
public void accept(Throwable throwable) throws Throwable { | ||
LogUtil.e(throwable, "RxJavaPlugins"); | ||
} | ||
}); | ||
``` | ||
|
||
### [Base组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_base) | ||
|
||
### [Widget组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_widget) | ||
|
||
### [Network组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_network) | ||
|
||
### [Util组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_util) | ||
|
||
### [Image组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_image) | ||
|
||
### [WebView组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_webview) | ||
|
||
### [Photo组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_photo) | ||
|
||
### [QR组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_qr) | ||
|
||
### [Camerax组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_camera) | ||
|
||
### [Upgrade组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_upgrade) | ||
|
||
### [Screen组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_screen) | ||
|
||
### [Stat组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_stat) | ||
|
||
### [Bugly组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_bugly) | ||
|
||
### [Crash组件库功能](https://github.com/MirkoWu/MVM/tree/master/lib_crash) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
|
||
apply plugin: 'bugly' | ||
|
||
bugly { | ||
appId = "3e2cd9bf87" | ||
appKey = "1b977565-a3ce-4188-9eea-255729b7ddc8" | ||
} | ||
|
||
static def getDate() { | ||
def date = new Date() | ||
def formattedDate = date.format('yyyy-MM-dd-HH-mm') | ||
return formattedDate | ||
} | ||
|
||
def ext = rootProject.ext | ||
android { | ||
compileSdkVersion ext.compileSdkVersion | ||
buildToolsVersion "30.0.3" | ||
|
||
defaultConfig { | ||
applicationId "com.mirkowu.mvm" | ||
minSdkVersion ext.minSdkVersion | ||
targetSdkVersion ext.targetSdkVersion | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
// ndk { | ||
// //设置支持的SO库架构 | ||
// abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'//, 'x86', 'x86_64' | ||
// } | ||
//只保留当前语言资源,加快编译 | ||
resConfigs "zh" | ||
} | ||
|
||
signingConfigs { | ||
release { | ||
storeFile file('../keystore.jks') | ||
storePassword '123456' | ||
keyAlias '123456' | ||
keyPassword '123456' | ||
} | ||
} | ||
|
||
buildTypes { | ||
debug { | ||
minifyEnabled true | ||
shrinkResources true | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
signingConfig signingConfigs.release | ||
|
||
//debug模式关闭crunchPng优化, 以加快构建 | ||
crunchPngs false | ||
} | ||
release { | ||
minifyEnabled true | ||
shrinkResources true | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
signingConfig signingConfigs.release | ||
|
||
debuggable false | ||
jniDebuggable false | ||
zipAlignEnabled true | ||
} | ||
} | ||
//AS4.0及以上 | ||
buildFeatures { | ||
viewBinding = true | ||
// dataBinding = true | ||
} | ||
//4.0以下 | ||
// viewBinding { | ||
// enabled = true | ||
// } | ||
// dataBinding { | ||
// enabled = true | ||
// } | ||
|
||
//支持Java1.8必加 | ||
compileOptions { | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
|
||
//忽略编译器的lint检查 | ||
lintOptions { | ||
checkReleaseBuilds false | ||
abortOnError false | ||
} | ||
|
||
// 自定义输出配置 | ||
applicationVariants.all { variant -> | ||
def versionName = variant.versionName | ||
def buildTypeName = variant.buildType.name | ||
variant.outputs.all { output -> | ||
outputFileName = "V" + versionName + "_" + getDate() + "_" + buildTypeName + ".apk" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: "libs", include: ["*.jar"]) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation "androidx.core:core-ktx:$ext.core_ktx_version" | ||
implementation "androidx.appcompat:appcompat:$ext.appcompat_version" | ||
// implementation "com.google.android.material:material:$ext.material_version" | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
|
||
//是否使用本地lib | ||
def useLocalModule = true | ||
if (!useLocalModule) { | ||
// implementation("com.github.mirkowu:mvm:$ext.mvm_version") { //总仓库 | ||
// exclude group: "com.github.mirkowu.mvm", module: "lib_bugly" | ||
//// exclude group: "com.github.mirkowu.mvm", module: "lib_crash" | ||
// } | ||
|
||
|
||
implementation "com.github.mirkowu.mvm:lib_stat:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_bugly:$ext.mvm_version" //bugly 包含升级SDK 二选一 | ||
// implementation "com.github.mirkowu.mvm:lib_crash:$ext.mvm_version" //bugly 不含升级SDK 二选一 | ||
} else { | ||
implementation "com.github.mirkowu.mvm:lib_base:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_util:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_widget:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_network:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_webview:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_image:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_photo:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_qr:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_camera:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_screen:$ext.mvm_version" | ||
implementation "com.github.mirkowu.mvm:lib_upgrade:$ext.mvm_version" | ||
implementation project(path: ':lib_umeng') | ||
implementation project(path: ':lib_bugly') //bugly 包含升级SDK 二选一 | ||
// implementation project(path: ':lib_crash') //bugly 不含升级SDK 二选一 | ||
} | ||
|
||
|
||
implementation "com.github.bumptech.glide:glide:$ext.glide_version" | ||
//检测内测泄露 | ||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7' | ||
|
||
//UE | ||
debugImplementation 'com.github.eleme.UETool:uetool:1.3.2' | ||
debugImplementation 'com.github.eleme.UETool:uetool-base:1.3.2' | ||
releaseImplementation 'com.github.eleme.UETool:uetool-no-op:1.3.2' | ||
} |
Oops, something went wrong.