Skip to content

Commit

Permalink
commit 1.1.7_version
Browse files Browse the repository at this point in the history
  • Loading branch information
hegj committed Aug 28, 2022
1 parent 33dc7e8 commit 9798b8f
Show file tree
Hide file tree
Showing 64 changed files with 5,868 additions and 380 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ clone慢的可以用 gitee链接 https://gitee.com/hegaojian/MvvmHelper

## 1.如何集成

- **1.1 在root's build.gradle中加入 Jitpack 仓库**
- **1.1 在root's build.gradle中加入 Jitpack 仓库 **

```gradle
allprojects {
Expand Down
43 changes: 25 additions & 18 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ plugins {
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'com.google.devtools.ksp' version '1.7.10-1.0.6'
}

//让IDE知道ksp生成的kotlin代码(仅使用ksp时才需要)
kotlin {
sourceSets.debug {
//如果通过productFlavors配置了多渠道,则配置 /../ksp/xxxDebug/kotlin
kotlin.srcDir("build/generated/ksp/debug/kotlin")
}
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

android {
compileSdkVersion 31
defaultConfig {
applicationId "com.zhixinhuixue.zsyte.xxx"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 31
versionCode 16
versionName "1.1.5"
}
Expand All @@ -36,8 +44,8 @@ android {
viewBinding = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "1.8"
Expand All @@ -52,25 +60,24 @@ android {
}
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//banner
implementation "com.github.zhpanvip:BannerViewPager:3.5.2"
implementation "com.github.zhpanvip:BannerViewPager:3.5.4"
//微信开源项目,替代SP
implementation 'com.tencent:mmkv-static:1.2.10'
implementation project(path: ':helper')
// implementation 'com.github.hegaojian:MvvmHelper:1.1.6'
kapt 'com.github.liujingxing.rxhttp:rxhttp-compiler:2.8.3'
//这是用来测试 navigation 的 可以忽略
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
// implementation 'com.github.hegaojian:MvvmHelper:1.1.7'
ksp "com.github.liujingxing.rxhttp:rxhttp-compiler:2.9.3"


}
10 changes: 4 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:exported="true"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"

tools:ignore="GoogleAppIndexingWarning,UnusedAttribute,LockedOrientationActivity"
tools:replace="android:allowBackup,android:networkSecurityConfig">
<activity
android:name=".ui.activity.SplashActivity"
android:theme="@style/SplashTheme"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -56,12 +59,7 @@
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activity.NavigationActivity"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait" />



<provider
android:name="androidx.core.content.FileProvider"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/zhixinhuixue/zsyte/xxx/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ class App : Application() {
AnchorsManager.getInstance()
.debuggable(BuildConfig.DEBUG)
//设置锚点
.addAnchor(InitNetWork.TASK_ID, InitUtils.TASK_ID, InitComm.TASK_ID, InitToast.TASK_ID).start(
.addAnchor(InitNetWork.TASK_ID, InitUtils.TASK_ID, InitComm.TASK_ID).start(
Project.Builder("app", AppTaskFactory())
.add(InitNetWork.TASK_ID)
.add(InitComm.TASK_ID)
.add(InitUtils.TASK_ID)
.add(InitToast.TASK_ID)
.build()
)
}
Expand Down
35 changes: 9 additions & 26 deletions app/src/main/java/com/zhixinhuixue/zsyte/xxx/app/AppTaskFactory.kt
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package com.zhixinhuixue.zsyte.xxx.app

import android.view.Gravity
import com.effective.android.anchors.Project
import com.effective.android.anchors.Task
import com.effective.android.anchors.TaskCreator
import com.hjq.toast.ToastUtils
import com.kingja.loadsir.callback.SuccessCallback
import com.kingja.loadsir.core.LoadSir
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.header.ClassicsHeader
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.tencent.mmkv.MMKV
import com.zhixinhuixue.library.common.ext.dp
import com.zhixinhuixue.zsyte.xxx.BuildConfig
import com.zhixinhuixue.zsyte.xxx.R
import com.zhixinhuixue.zsyte.xxx.app.api.NetHttpClient
import me.hgj.mvvmhelper.base.appContext
import me.hgj.mvvmhelper.ext.getColorExt
import me.hgj.mvvmhelper.util.mvvmHelperLog
import me.hgj.mvvmhelper.loadsir.callback.SuccessCallback
import me.hgj.mvvmhelper.loadsir.core.LoadSir
import me.hgj.mvvmhelper.widget.state.BaseEmptyCallback
import me.hgj.mvvmhelper.widget.state.BaseErrorCallback
import me.hgj.mvvmhelper.widget.state.BaseLoadingCallback
Expand All @@ -36,7 +31,6 @@ object TaskCreator : TaskCreator {
InitNetWork.TASK_ID -> InitNetWork()
InitComm.TASK_ID -> InitComm()
InitUtils.TASK_ID -> InitUtils()
InitToast.TASK_ID -> InitToast()
else -> InitDefault()
}
}
Expand All @@ -46,6 +40,7 @@ class InitDefault : Task(TASK_ID, true) {
companion object {
const val TASK_ID = "0"
}

override fun run(name: String) {

}
Expand All @@ -59,14 +54,14 @@ class InitNetWork : Task(TASK_ID, true) {
companion object {
const val TASK_ID = "1"
}

override fun run(name: String) {
//传入自己的OKHttpClient 并添加了自己的拦截器
RxHttpPlugins.init(NetHttpClient.getDefaultOkHttpClient().build())
}
}



//初始化常用控件类
class InitComm : Task(TASK_ID, true) {
companion object {
Expand All @@ -91,11 +86,12 @@ class InitComm : Task(TASK_ID, true) {
setAccentColor(getColorExt(R.color.colorBlack))
}
}
//注册界面状态管理
//注册界面状态管理: 以下代码 其实 在调用MvvmHelper.init()的时候就已经注册了
//这里写的原因是 框架的 状态布局页面可能不适用于你的项目,你可以添加自己的 错误 空 加载中全局配置
LoadSir.beginBuilder()
.addCallback(BaseErrorCallback())
.addCallback(BaseEmptyCallback())
.addCallback(BaseLoadingCallback())
.setErrorCallBack(BaseErrorCallback())
.setEmptyCallBack(BaseEmptyCallback())
.setLoadingCallBack(BaseLoadingCallback())
.setDefaultCallback(SuccessCallback::class.java)
.commit()
}
Expand All @@ -113,19 +109,6 @@ class InitUtils : Task(TASK_ID, true) {
}
}

//初始化Utils
class InitToast : Task(TASK_ID, false) {
companion object {
const val TASK_ID = "4"
}

override fun run(name: String) {
//初始化吐司 这个吐司必须要主线程中初始化
ToastUtils.init(appContext)
ToastUtils.setGravity(Gravity.BOTTOM, 0, 100.dp)
}
}

class AppTaskFactory : Project.TaskFactory(TaskCreator)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ package com.zhixinhuixue.zsyte.xxx.app.base

import android.view.LayoutInflater
import android.view.View
import androidx.databinding.ViewDataBinding
import androidx.viewbinding.ViewBinding
import com.gyf.immersionbar.ImmersionBar
import com.zhixinhuixue.zsyte.xxx.R
import com.zhixinhuixue.zsyte.xxx.app.widget.CustomToolBar
import me.hgj.mvvmhelper.base.BaseDbActivity
import me.hgj.mvvmhelper.base.BaseVBActivity
import me.hgj.mvvmhelper.base.BaseViewModel

/**
* 作者 : hegaojian
* 时间 : 2021/6/9
* 描述 : 使用DataBinding 需要自定义修改什么就重写什么 具体方法可以 搜索 BaseIView 查看
* 描述 : 使用了 ViewBinding的基类 需要自定义修改什么就重写什么 具体方法可以 搜索 BaseIView 查看
*/
abstract class BaseActivity<VM : BaseViewModel, DB : ViewDataBinding> : BaseDbActivity<VM, DB>() {
abstract class BaseActivity<VM : BaseViewModel, VB : ViewBinding> : BaseVBActivity<VM, VB>() {

lateinit var mToolbar: CustomToolBar

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import me.hgj.mvvmhelper.util.decoration.DividerOrientation
*/
class ListActivity: BaseActivity<ListViewModel, ActivityListBinding>() {

private val testAdapter: TestAdapter by lazy { TestAdapter(arrayListOf()) }
private val testAdapter: TestAdapter by lazy { TestAdapter() }

override fun initView(savedInstanceState: Bundle?) {
mToolbar.initBack("列表界面") {
Expand All @@ -36,13 +36,19 @@ class ListActivity: BaseActivity<ListViewModel, ActivityListBinding>() {
}
//初始化recyclerview
mBind.listRecyclerView.run {
//设置 recyclerview 模式 为 网格
grid(3)
divider {
//分割线颜色
setColor(getColorExt(R.color.colorWhite))
//分割线高度
setDivider(10.dp)
//是否首尾都有分割线
includeVisible = true
//分割线方向
orientation = DividerOrientation.GRID
}
//设置适配器
adapter = testAdapter
}
//发起请求
Expand Down Expand Up @@ -78,5 +84,4 @@ class ListActivity: BaseActivity<ListViewModel, ActivityListBinding>() {
override fun onLoadRetry() {
mViewModel.getList(isRefresh = true, loadingXml = true)
}

}
Loading

0 comments on commit 9798b8f

Please sign in to comment.