Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
hegaojian committed Jun 11, 2020
2 parents cae6f05 + d15baa8 commit a1fe615
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#### APK下载:

- [Github下载](https://github.com/hegaojian/JetpackMvvm/releases/download/1.1.0/app-release.apk)
- [Github下载](https://github.com/hegaojian/JetpackMvvm/releases/download/1.1.1/app-release.apk)

- [firm下载(推荐)](http://d.6short.com/v9q7)

Expand All @@ -47,7 +47,7 @@ allprojects {
```
dependencies {
...
implementation 'me.hegj:JetpackMvvm:1.1.0'
implementation 'me.hegj:JetpackMvvm:1.1.1'
}
```

Expand All @@ -63,7 +63,10 @@ android {
```

## 2.继承基类
一般我们项目中都会有一套自己定义的符合业务需求的基类 ***BaseActivity/BaseFragment***,所以我们的基类需要**继承本框架的Base类BaseVmDbActivity/BaseVmDbFragment**
一般我们项目中都会有一套自己定义的符合业务需求的基类 ***BaseActivity/BaseFragment***,所以我们的基类需要**继承本框架的Base类**

- 不想用Databinding的-------可以继承 BaseVmActivity/BaseVmFragment
- 用Databinding的-----------可以继承BaseVmDbActivity/BaseVmDbFragment**

**Activity:**

Expand Down Expand Up @@ -296,8 +299,7 @@ class RequestLoginViewModel(application: Application) : BaseViewModel(applicatio
class LoginFragment : BaseFragment<LoginViewModel, FragmentLoginBinding>() {
/** 注意,在by lazy中使用getViewModel一定要使用泛型,虽然他提示不报错,但是你不写是不行的 */
private val requestLoginRegisterViewModel: RequestLoginRegisterViewModel by lazy { getViewModel<RequestLoginRegisterViewModel>() }
private val requestLoginRegisterViewModel: RequestLoginRegisterViewModel by viewModels()
/**
* 当前fragment绑定的布局
Expand Down Expand Up @@ -365,7 +367,7 @@ class RequestLoginViewModel(application: Application) : BaseViewModel(applicatio
it.errorMsg.logd()
},true,"正在登录中...")
//2.拿到未脱壳的数据,你可以自己根据code做业务需求操作(项目没有基类的可以用
//2.拿到未脱壳的数据,你可以自己根据code做业务需求操作(项目没有基类或者不想框架帮忙脱壳的可以用
requestNoCheck({HttpRequestManger.instance.login(username,password)},{
//请求成功 自己拿到数据做业务需求操作
if(it.errorCode==0){
Expand All @@ -388,7 +390,7 @@ class RequestLoginViewModel(application: Application) : BaseViewModel(applicatio
val mainViewModel = ViewModelProvider(this,
ViewModelProvider.AndroidViewModelFactory(application)).get(MainViewModel::class.java)
```
**官方Ktx有拓展函数可以轻松调用
**现在官方Ktx有拓展函数可以轻松调用
```
//在activity中获取当前Activity级别作用域的ViewModel
private val mainViewModel:MainViewModel by viewModels()
Expand Down

0 comments on commit a1fe615

Please sign in to comment.