kukyxs / coroutineswanandroid Goto Github PK
View Code? Open in Web Editor NEW超完整的「玩 Android」客户端,项目采用 MVVM, Android Jetpack, Retrofit, Kotlin 协程, Koin 编写。如果该项目对你学习过程有用,请给个 star,感谢
超完整的「玩 Android」客户端,项目采用 MVVM, Android Jetpack, Retrofit, Kotlin 协程, Koin 编写。如果该项目对你学习过程有用,请给个 star,感谢
Application namespace for attribute bind:img will be ignored.
@kukyxs build 提示缺少此class
在HomeArtRemoteMediator
的load里面如果没有缓存的情况下,获取page的条件下PREPEND
和APPEND
会抛出InvalidObjectException
异常。请问为什么不会崩溃,是哪里捕获了么。
每个接口都来一个 写着累啊
.onStart {
mAppViewModel.showLoading()
}.onCompletion {
mAppViewModel.dismissLoading()
在首页任意栏目中,下拉使刷新动画出现,但不松开手指,再上滑至顶部。则刷新圆圈会一直显示,不会消失。此时需要再正常刷新一次,圆圈正常消失。
current verison can`t start
我在使用RxJava时可以在onError中轻松的捕获到所有的异常信息,但是在使用了协程后发现居然没有onError的回调方法,难道只能通过try catch 这种方式么???
MainViewModel:
val hasLogin = MutableLiveData<Boolean>()
// 未找到较好的解决方案,目前使用回调进行处理,有较好的方案请提 issue
fun login(username: String, password: String, success: () -> Unit, fail: (String) -> Unit) {
viewModelScope.safeLaunch {
val result = repository.login(username, password)
if (result.code == CODE_SUCCEED) {
success()
hasLogin.value = true
} else {
fail(result.message)
hasLogin.value = false
}
}
}
LoginDialogFragment:
fun login(view: View) {
val username = mBinding.root.user_name.text.toString()
val password = mBinding.root.password.text.toString()
if (username.isBlank() || password.isBlank()) {
requireContext().toast("请输入完整")
} else {
mViewModel.login(username, password, {
requireContext().toast("登录成功")
dialog?.dismiss()
}, { message ->
requireContext().toast(message)
dialog?.dismiss()
})
}
}
1.在MainViewModel中的hasLogin.value=true 数据类型太单一了,只是没有在LoginDialogFragment中 hasLogin.observe ,没必要回掉。hasLogin这个liveData 不用boolean 用一个data class 会处理点吧。
2.代码中 并没有对错误消息进行处理和显示。
3.有一点比较困惑的地方 ,希望大佬指教一下 为什么要用
class MainModelFactory(private val repository: MainRepository) : ViewModelProvider.NewInstanceFactory() {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return MainViewModel(repository) as T
}
}
这个?假如View销毁了 ,Repository会不会持有ViewModel 的引用 造成内存泄漏啊?
你好,
我是个初学者。
下载了体验版后无法在手机上启动。
系统核心是安卓10(H2OS 10.0.0),语言切了中文,权限设置成允许这些都试过了,还是闪退。
请问有什么调查方法么?
谢谢,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.