Merge branch 'master' into devel
commit
f35f40ed27
@ -1,23 +1,31 @@
|
|||||||
package org.koitharu.kotatsu.list.ui.adapter
|
package org.koitharu.kotatsu.list.ui.adapter
|
||||||
|
|
||||||
|
import coil.ImageLoader
|
||||||
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
||||||
import org.koitharu.kotatsu.databinding.ItemEmptyStateBinding
|
import org.koitharu.kotatsu.databinding.ItemEmptyStateBinding
|
||||||
import org.koitharu.kotatsu.list.ui.model.EmptyState
|
import org.koitharu.kotatsu.list.ui.model.EmptyState
|
||||||
import org.koitharu.kotatsu.list.ui.model.ListModel
|
import org.koitharu.kotatsu.list.ui.model.ListModel
|
||||||
|
import org.koitharu.kotatsu.utils.ext.disposeImageRequest
|
||||||
|
import org.koitharu.kotatsu.utils.ext.enqueueWith
|
||||||
|
import org.koitharu.kotatsu.utils.ext.newImageRequest
|
||||||
import org.koitharu.kotatsu.utils.ext.setTextAndVisible
|
import org.koitharu.kotatsu.utils.ext.setTextAndVisible
|
||||||
|
|
||||||
fun emptyStateListAD(
|
fun emptyStateListAD(
|
||||||
|
coil: ImageLoader,
|
||||||
listener: ListStateHolderListener,
|
listener: ListStateHolderListener,
|
||||||
) = adapterDelegateViewBinding<EmptyState, ListModel, ItemEmptyStateBinding>(
|
) = adapterDelegateViewBinding<EmptyState, ListModel, ItemEmptyStateBinding>(
|
||||||
{ inflater, parent -> ItemEmptyStateBinding.inflate(inflater, parent, false) }
|
{ inflater, parent -> ItemEmptyStateBinding.inflate(inflater, parent, false) },
|
||||||
) {
|
) {
|
||||||
|
|
||||||
binding.buttonRetry.setOnClickListener { listener.onEmptyActionClick() }
|
binding.buttonRetry.setOnClickListener { listener.onEmptyActionClick() }
|
||||||
|
|
||||||
bind {
|
bind {
|
||||||
binding.icon.setImageResource(item.icon)
|
binding.icon.newImageRequest(item.icon)?.enqueueWith(coil)
|
||||||
binding.textPrimary.setText(item.textPrimary)
|
binding.textPrimary.setText(item.textPrimary)
|
||||||
binding.textSecondary.setTextAndVisible(item.textSecondary)
|
binding.textSecondary.setTextAndVisible(item.textSecondary)
|
||||||
binding.buttonRetry.setTextAndVisible(item.actionStringRes)
|
binding.buttonRetry.setTextAndVisible(item.actionStringRes)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
onViewRecycled {
|
||||||
|
binding.icon.disposeImageRequest()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue