[英]How to Providing Drawable for Repository in MVVM, Clean Architecture
i am trying to code with SOLID, and MVVM architecture.我正在尝试使用 SOLID 和 MVVM 架构进行编码。 But i am confused how to provide drawable to Repository in MVVM但我很困惑如何在 MVVM 中向 Repository 提供 drawable
interface IStringProvider {
val mengenaliPotensiDiri: String
val eventSpesial: String
val pentingMengenaliDiri: String
val mengenaliAspekDiri: String
val mulaiRencanaKarier: String
}
class AssessmentListRepository(private val stringProvider: IStringProvider) {
fun getAssessmentTopicMengenaliDiri(): List<AssessmentProgressItem> {
return listOf(
AssessmentProgressItem(
stringProvider.kerangkaPerencanaanKuliahDanKarier,
R.drawable.ic_home_video_open, //How should i provide it?
R.drawable.ic_home_video_lock,
R.drawable.ic_home_video_open,
{ AssessmentProgressItem.PROGRESS_STATUS_OPEN },
true,
0,
{}
),
AssessmentProgressItem(
stringProvider.caraMengenaliDiri,
R.drawable.ic_home_video_open,
R.drawable.ic_home_video_lock,
R.drawable.ic_home_video_open,
{ AssessmentProgressItem.PROGRESS_STATUS_OPEN },
true,
0,
{}
)
)
}
}
So, how should i provide drawable to my AssessmentListRepository?那么,我应该如何向我的 AssessmentListRepository 提供 drawable 呢? shall i providing Drawable class, or i just providing integer IDs?我应该提供 Drawable class,还是只提供 integer ID?
Is Drawable an AndroidComponent? Drawable 是 Android 组件吗?
interesting question.有趣的问题。 Hope I understood you correctly, because I don't understand why your repository needs drawables?希望我理解正确,因为我不明白为什么您的存储库需要可绘制对象? What are going to do with those drawables?这些drawables要做什么? Return they back to VM?将它们返回给 VM?
Actually, I'm not sure that repository has to provide Drawable in general.实际上,我不确定存储库是否必须提供 Drawable。 And R.java is definitely Android specific class, so we can say that your Repository class depends on Android specific class. And R.java is definitely Android specific class, so we can say that your Repository class depends on Android specific class. I think better way do something like this:我认为更好的方法是这样做:
Cheers干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.