refactor(frame): 调整项目结构
移除buildGradleScript、lib_net模块,将网络层迁移至lib_common层 升级Gradle版本及
This commit is contained in:
@ -20,9 +20,6 @@
|
||||
|
||||
**app壳** 工程,是依赖所有组件的壳,该模块不应该包含任何代码,它只作为一个空壳存在,由于项目中使用了EventBusAPT技术,需要索引到各业务组件的对应的APT生成类,所以在 **app壳** 内有这一部分的代码。
|
||||
|
||||
- **buildGradleScript:**
|
||||
|
||||
脚本模块,该模块下存放的都是各个组件及封装的一些 **Gradle** 脚本文件。初衷是将所有的脚本统一管理,事实上我在组件内查找脚本的习惯还是没有改掉。
|
||||
|
||||
- **buildSrc:**
|
||||
|
||||
@ -36,10 +33,6 @@
|
||||
|
||||
项目的业务公共模块,这里面存放着项目里各个业务组件的公共部分,还有一些项目特定需要的一些文件等,该组件是和项目业务有关系的。
|
||||
|
||||
- **lib_net:**
|
||||
|
||||
网络模块,网络模块的配置、封装等,专门设立了一个组件来负责网路模块部分。
|
||||
|
||||
## 组件化相关
|
||||
|
||||
### 组件初始化
|
||||
|
||||
@ -1 +0,0 @@
|
||||
apply("../buildGradleScript/app.gradle")
|
||||
@ -1,6 +1,6 @@
|
||||
package com.quyunshuo.androidbaseframemvvm.app
|
||||
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.BaseApplication
|
||||
import com.quyunshuo.androidbaseframemvvm.base.BaseApplication
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
//****************************************
|
||||
//*********** lib_net 的配置文件 ***********
|
||||
//****************************************
|
||||
|
||||
apply from: '../buildGradleScript/base/base_lib.gradle'
|
||||
apply plugin: 'dagger.hilt.android.plugin'
|
||||
|
||||
import com.quyunshuo.androidbaseframemvvm.buildsrc.*
|
||||
|
||||
android {
|
||||
resourcePrefix "net_"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
|
||||
implementation project(path: ':lib_base')
|
||||
|
||||
api DependencyConfig.GitHub.OkHttp
|
||||
api DependencyConfig.GitHub.OkHttpInterceptorLogging
|
||||
api DependencyConfig.GitHub.Retrofit
|
||||
api DependencyConfig.GitHub.RetrofitConverterGson
|
||||
api DependencyConfig.JetPack.HiltCore
|
||||
|
||||
kapt DependencyConfig.GitHub.AutoServiceAnnotations
|
||||
kapt DependencyConfig.JetPack.HiltApt
|
||||
kapt DependencyConfig.JetPack.HiltAndroidx
|
||||
}
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
//********** lib_base 的配置文件 ***********
|
||||
//****************************************
|
||||
|
||||
apply from: '../buildGradleScript/base/base_lib.gradle'
|
||||
apply from: '../base_lib.gradle'
|
||||
apply plugin: 'dagger.hilt.android.plugin'
|
||||
|
||||
import com.quyunshuo.androidbaseframemvvm.buildsrc.*
|
||||
@ -48,6 +48,10 @@ dependencies {
|
||||
api DependencyConfig.GitHub.EventBus
|
||||
api DependencyConfig.GitHub.PermissionX
|
||||
api DependencyConfig.GitHub.AutoService
|
||||
api DependencyConfig.GitHub.OkHttp
|
||||
api DependencyConfig.GitHub.OkHttpInterceptorLogging
|
||||
api DependencyConfig.GitHub.Retrofit
|
||||
api DependencyConfig.GitHub.RetrofitConverterGson
|
||||
|
||||
api DependencyConfig.SDK.TencentBugly
|
||||
api DependencyConfig.SDK.TencentBuglyNative
|
||||
@ -1 +0,0 @@
|
||||
apply("../buildGradleScript/lib_base.gradle")
|
||||
@ -1,9 +1,11 @@
|
||||
package com.quyunshuo.androidbaseframemvvm.base.app
|
||||
package com.quyunshuo.androidbaseframemvvm.base
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.multidex.MultiDexApplication
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.ActivityLifecycleCallbacksImpl
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.LoadModuleProxy
|
||||
import kotlinx.coroutines.*
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
@ -4,7 +4,7 @@ import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.BaseApplication
|
||||
import com.quyunshuo.androidbaseframemvvm.base.BaseApplication
|
||||
import java.lang.reflect.Field
|
||||
|
||||
/**
|
||||
|
||||
@ -11,7 +11,7 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.BaseApplication;
|
||||
import com.quyunshuo.androidbaseframemvvm.base.BaseApplication;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
|
||||
@ -1,14 +1,10 @@
|
||||
package com.quyunshuo.androidbaseframemvvm.base.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.NetworkInfo
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.BaseApplication
|
||||
import com.quyunshuo.androidbaseframemvvm.base.BaseApplication
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.catch
|
||||
@ -16,15 +12,6 @@ import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
|
||||
/**
|
||||
* 以顶层函数存在的常用工具方法
|
||||
* startPolling() -> 开启一个轮询
|
||||
* sendEvent() -> 发送普通EventBus事件
|
||||
* isNetworkAvailable() -> 检查是否连接网络
|
||||
* aRouterJump() -> 阿里路由不带参数跳转
|
||||
* toast() -> 封装ToastUtils
|
||||
*/
|
||||
/**************************************************************************************************/
|
||||
/**
|
||||
* 使用 Flow 做的简单的轮询
|
||||
* 请使用单独的协程来进行管理该 Flow
|
||||
@ -50,29 +37,6 @@ suspend fun startPolling(intervals: Long, block: () -> Unit) {
|
||||
*/
|
||||
fun sendEvent(event: Any) = EventBusUtils.postEvent(event)
|
||||
|
||||
/**************************************************************************************************/
|
||||
/**
|
||||
* 判断是否连接网络
|
||||
*/
|
||||
@SuppressLint("MissingPermission")
|
||||
fun isNetworkAvailable(): Boolean {
|
||||
val connectivityManager: ConnectivityManager? =
|
||||
BaseApplication.context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
if (connectivityManager == null) {
|
||||
return false
|
||||
} else {
|
||||
val allNetworkInfo: Array<NetworkInfo>? = connectivityManager.allNetworkInfo
|
||||
if (allNetworkInfo != null && allNetworkInfo.isNotEmpty()) {
|
||||
allNetworkInfo.forEach {
|
||||
if (it.state == NetworkInfo.State.CONNECTED) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**************************************************************************************************/
|
||||
/**
|
||||
* 阿里路由不带参数跳转
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
//********* lib_common 的配置文件 **********
|
||||
//****************************************
|
||||
|
||||
apply from: '../buildGradleScript/base/base_lib.gradle'
|
||||
apply from: '../base_lib.gradle'
|
||||
|
||||
import com.quyunshuo.androidbaseframemvvm.buildsrc.*
|
||||
|
||||
@ -25,7 +25,6 @@ dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
|
||||
api project(path: ':lib_base')
|
||||
api project(path: ':lib_net')
|
||||
|
||||
api DependencyConfig.JetPack.HiltCore
|
||||
|
||||
@ -1 +0,0 @@
|
||||
apply("../buildGradleScript/lib_common.gradle")
|
||||
@ -7,7 +7,7 @@ import android.util.Log
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.google.auto.service.AutoService
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.ApplicationLifecycle
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.BaseApplication
|
||||
import com.quyunshuo.androidbaseframemvvm.base.BaseApplication
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.InitDepend
|
||||
import com.quyunshuo.androidbaseframemvvm.base.constant.VersionStatus
|
||||
import com.quyunshuo.androidbaseframemvvm.base.utils.ProcessUtils
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.quyunshuo.androidbaseframemvvm.net
|
||||
package com.quyunshuo.androidbaseframemvvm.common.constant
|
||||
|
||||
/**
|
||||
* 接口公共地址
|
||||
@ -8,7 +8,7 @@ package com.quyunshuo.androidbaseframemvvm.net
|
||||
*/
|
||||
internal object NetBaseUrlConstant {
|
||||
|
||||
val MAIN_URL = ""
|
||||
val MAIN_URL = "http://www.baidu.com"
|
||||
get() {
|
||||
if (field.isEmpty()){
|
||||
throw NotImplementedError("请求改你的 MAIN_URL 的值为自己的请求地址")
|
||||
@ -1,7 +1,7 @@
|
||||
package com.quyunshuo.androidbaseframemvvm.net.di
|
||||
package com.quyunshuo.androidbaseframemvvm.common.di
|
||||
|
||||
import com.quyunshuo.androidbaseframemvvm.base.BuildConfig
|
||||
import com.quyunshuo.androidbaseframemvvm.net.NetBaseUrlConstant
|
||||
import com.quyunshuo.androidbaseframemvvm.common.constant.NetBaseUrlConstant
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
1
lib_net/.gitignore
vendored
1
lib_net/.gitignore
vendored
@ -1 +0,0 @@
|
||||
/build
|
||||
@ -1 +0,0 @@
|
||||
apply("../buildGradleScript/lib_net.gradle")
|
||||
21
lib_net/proguard-rules.pro
vendored
21
lib_net/proguard-rules.pro
vendored
@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.quyunshuo.androidbaseframemvvm.net">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
</manifest>
|
||||
@ -1,47 +0,0 @@
|
||||
package com.quyunshuo.androidbaseframemvvm.net
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import com.google.auto.service.AutoService
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.ApplicationLifecycle
|
||||
import com.quyunshuo.androidbaseframemvvm.base.app.InitDepend
|
||||
|
||||
/**
|
||||
* 网络模块的Application
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since 4/23/21 6:14 PM
|
||||
*/
|
||||
@AutoService(ApplicationLifecycle::class)
|
||||
class NetApplication : ApplicationLifecycle {
|
||||
|
||||
/**
|
||||
* 同[Application.attachBaseContext]
|
||||
* @param context Context
|
||||
*/
|
||||
override fun onAttachBaseContext(context: Context) {}
|
||||
|
||||
/**
|
||||
* 同[Application.onCreate]
|
||||
* @param application Application
|
||||
*/
|
||||
override fun onCreate(application: Application) {}
|
||||
|
||||
/**
|
||||
* 同[Application.onTerminate]
|
||||
* @param application Application
|
||||
*/
|
||||
override fun onTerminate(application: Application) {}
|
||||
|
||||
/**
|
||||
* 需要立即进行初始化的放在这里进行并行初始化
|
||||
* 需要必须在主线程初始化的放在[InitDepend.mainThreadDepends],反之放在[InitDepend.workerThreadDepends]
|
||||
* @return InitDepend 初始化方法集合
|
||||
*/
|
||||
override fun initByFrontDesk(): InitDepend = InitDepend(mutableListOf(), mutableListOf())
|
||||
|
||||
/**
|
||||
* 不需要立即初始化的放在这里进行后台初始化
|
||||
*/
|
||||
override fun initByBackstage() {}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
//******** module_home 的配置文件 *********
|
||||
//****************************************
|
||||
|
||||
apply from: '../buildGradleScript/base/base_module.gradle'
|
||||
apply from: '../base_module.gradle'
|
||||
|
||||
android {
|
||||
resourcePrefix "home_"
|
||||
@ -1 +0,0 @@
|
||||
apply("../buildGradleScript/module_home.gradle")
|
||||
@ -2,6 +2,5 @@ include(
|
||||
":app",
|
||||
":lib_base",
|
||||
":lib_common",
|
||||
":lib_net",
|
||||
":module_home"
|
||||
)
|
||||
Reference in New Issue
Block a user