【发布时间】:2022-01-14 03:35:26
【问题描述】:
我使用自己的自定义适配器类,但是当我想提供它们时,我遇到了问题,我不明白为什么!
@Module
abstract class AppointmentListModule {
companion object {
@Provides
@PerChildFragment
fun adapter(appExecutors: AppExecutors): SingleDataAdapter<AppointmentDigestData> = SingleDataAdapter(
appExecutors,
R.layout.item_appointment_patient,
SimpleDiffCallback(AppointmentDigestData::id),
BR.item
)
}
}
这是我收到的错误:
error: @Provides methods can only be present within a @Module or @ProducerModule
public final ir.logicfan.core.ui.recyclerview.adapter.SingleDataAdapter<com.ennings.data.entity.patient.AppointmentDigestData> adapter(@org.jetbrains.annotations.NotNull()
SingleDataAdapter 构造函数:
open class SingleDataAdapter<T>(
appExecutors: AppExecutors,
@LayoutRes protected val itemLayout: Int,
diffCallback: DiffUtil.ItemCallback<T>,
private val bindingItemVariableId: Int,
private val positionBindingVariableId: Int? = null
) : ListAdapter<T, DataBindingViewHolder<T>>(
AsyncDifferConfig.Builder<T>(diffCallback)
.setBackgroundThreadExecutor(appExecutors.diskIO())
.build()
) {....}
有人有想法吗?
【问题讨论】:
-
你用的是什么版本的 Dagger?
标签: android kotlin gradle dagger-2