lulululbj / wanandroid Goto Github PK
View Code? Open in Web Editor NEWJetpack MVVM For Wanandroid 最佳实践 !
Home Page: https://juejin.im/post/5cb473e66fb9a068af37a6ce
License: GNU General Public License v3.0
Jetpack MVVM For Wanandroid 最佳实践 !
Home Page: https://juejin.im/post/5cb473e66fb9a068af37a6ce
License: GNU General Public License v3.0
大佬,看到你的公众号文章OOM优化,评论中有提到线程优化的两个方案:
Retrofit的协程接口内部用的是异步的enqueue()方法,请求会调度到Okhttp线程池中,所以协程是不是没有必要调度到子线程呢
Could not find luyao.util.ktx:AndroidUtilKTX:0.0.4.
如题!
如题
在用协程替换RxJava的情况下,协程有相关api能做到例如RxJava zip处理多个网络请求、retryWhen处理错误重试吗?
可以看到很多时候都是一样的 为什么不进行抽离呢
作者大大写的很好,点赞!
我有一些短浅看法关于处理 loading/success/failure 的操作
我放在了这个仓库中 https://github.com/yang163email/AnotherEdenTool
使用类似于 kotlin 标准库中提供 Result 将 loading/success/failure 进行封装
luyao.util.ktx:AndroidUtilKTX:0.0.2
这个库的源码可以提供吗
但是处于学习阶段,还不是特别清楚怎么去封装比较好。
Android Studio : 3.4.1
Gradle: com.android.tools.build:gradle:3.4.2
Kotlin: ext.kotlin_version = '1.3.31'
Error Message:
luyao/wanandroid/ui/home/HomeViewModel.kt
(23, 45): Unresolved reference: liveData
(24, 21): Suspend function 'withContext' should be called only from a coroutine or another suspend function
(25, 9): Unresolved reference: emit
兄弟你好,拜读了代码,有一个疑问
把网络请求丢在Repository层该怎么取消网络请求呢
看您的代码是在Repository处理网络请求,VM把请求数据转化为LiveData
类似于之前call.cancel()或者Rxjava中取消观察这种
继承 BaseQuickAdapter 实现了databining,如果继承BaseMultiItemQuickAdapter 实现多布局 怎么使用databinding?求大佬指教!
我看代码里使用了databinding、koin之类的,与readme有些出入
为什么要两个livedata 用一个然后private set 是一样的效果吗
private val _uiState = MutableLiveData<ArticleUiModel>()
val uiState: LiveData<ArticleUiModel>
get() = _uiState
您好,Json字符串转数据类有插件吗?类似GsonFormat
BrowserNormalActivity->WebSettingsExtension.mContext
最新版本是3.x的不兼容升级,抽空改一下吧😂
报错信息如下:
2019-12-30 14:33:59.604 22417-22417/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: luyao.wanandroid, PID: 22417
java.lang.RuntimeException: Unable to start activity ComponentInfo{luyao.wanandroid/luyao.wanandroid.ui.NavigationActivity}: android.view.InflateException: Binary XML file line #8 in luyao.wanandroid:layout/activity_navigation: Binary XML file line #8 in luyao.wanandroid:layout/activity_navigation: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
@lulululbj @gdmec07120731
看了下代码一直没看明白怎么把 Retrofit 返回的 Call 转换为具体的实体类,后来查了下是 Retrofit 2.6.0 添加了对协程的支持,可以直接返回了,可以在 README 更新说明下。
Activity和Fragment里有充斥着大量的模板代码,
fun executeResponse(
response: MyResponse, successBlock: () -> Unit,
errorBlock: () -> Unit
, finishBlock: () -> Unit
) {
if (response.code == -1) {
errorBlock()
} else {
successBlock()
}
finishBlock()
}
但是是两个不同的vm对象,请问这个问题是getviewmode()这个方法导致的嘛?请问该怎么解决
每个请求都要判断成功失败,不大优雅呀
if (result is Result.Success){
emitUiState(showProgress = false,showSuccess = result.data,enableShareButton = true)
}else if (result is Result.Error){
emitUiState(showProgress = false,showError = result.exception.message,enableShareButton = true)
}
运行的时候一直报这个错,网上说是.aar的问题,但是您这没用到aar呀,还望前辈指教一下
ERROR: Could not find luyao.plugin.classfixer:classfixer:1.0.0.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/luyao/plugin/classfixer/classfixer/1.0.0/classfixer-1.0.0.pom
https://dl.google.com/dl/android/maven2/luyao/plugin/classfixer/classfixer/1.0.0/classfixer-1.0.0.jar
https://jcenter.bintray.com/luyao/plugin/classfixer/classfixer/1.0.0/classfixer-1.0.0.pom
https://jcenter.bintray.com/luyao/plugin/classfixer/classfixer/1.0.0/classfixer-1.0.0.jar
why ?can't find locations
import luyao.dependencies.Deps
import luyao.dependencies.Versions
SquareViewModel:
data class SquareUiModel(
val showLoading: Boolean,
val showError: String?,
val showSuccess: ArticleList?,
val showEnd: Boolean, // 加载更多
val isRefresh: Boolean, // 刷新
val needLogin: Boolean? = null
)
1.每个viewmodel 中有一个model,这种model 有没有办法共用?
2.还有个问题请教大佬 如果是DialogFragment 怎么用viewmodel ,在假如 我继承BaseVMFragment 我没有viewmodel 咋处理啊?
我在使用中 发现 无网络情况下会奔溃 ,搜了一下
建议使用 runCatching{
}
包裹请求代码
通过 result 返回异常 做处理
有没有处理方案?
1.首页 Tab+ViewPager+Fragment
FragmentPagerAdapter(supportFragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT)
这段代码的原意是让不可见的Fragment执行到onResume 之前 ,但是我发现BaseFragment的初始化操作全部都放在了onCreateView中 这样使得懒加载失效,那么这些初始化操作是否应该放在onResume中进行操作,使用变量控制判断是否初始化已完成
问个问题,我看你项目中用到了koin依赖注入用来初始化viewmodel,我项目中直接用反射初始化viewmodel,就是BaseViewModel中直接初始化子类的ViewModel对象,两者性能有差别吗?用反射直接就父类生成了,子类直接调用,省了很多代码
大佬,请教个问题。。
suspend fun login(@Field("username") userName: String, @Field("password") passWord: String): WanResponse<User>
这么写的话,我想根据401,403的错误码进行特定提示或者后续操作,该怎么捕捉这种http异常呢
是在safeApiCall的try,catch中,if(e is HttpException)这样吗。
如题,
看了一下项目,对比其他的mvvm+jetpack+协程,感觉这个项目是写的最好,想把大神的这套框架用到新的项目中,这个混淆文件有吗?
buildSrc 一直找不到依赖
Could not get unknown property 'Versions' for extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.
各种重启,清缓存都没用 ,androidstudio4.0 gradle 6.1.1 kotlin1.3.72
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.