Source name in list header
This commit is contained in:
@@ -20,6 +20,9 @@ abstract class RemoteMangaRepository(
|
||||
loaderContext.getSettings(source)
|
||||
}
|
||||
|
||||
val title: String
|
||||
get() = source.title
|
||||
|
||||
override val sortOrders: Set<SortOrder> get() = emptySet()
|
||||
|
||||
override suspend fun getPageUrl(page: MangaPage): String = page.url.withDomain()
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.koitharu.kotatsu.list.ui.adapter
|
||||
|
||||
import android.widget.TextView
|
||||
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegate
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.list.ui.model.ListHeader
|
||||
import org.koitharu.kotatsu.list.ui.model.ListModel
|
||||
|
||||
fun listHeaderAD() = adapterDelegate<ListHeader, ListModel>(R.layout.item_header) {
|
||||
|
||||
bind {
|
||||
(itemView as TextView).text = item.text
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ class MangaListAdapter(
|
||||
.addDelegate(ITEM_TYPE_ERROR_STATE, errorStateListAD(onRetryClick))
|
||||
.addDelegate(ITEM_TYPE_ERROR_FOOTER, errorFooterAD(onRetryClick))
|
||||
.addDelegate(ITEM_TYPE_EMPTY, emptyStateListAD())
|
||||
.addDelegate(ITEM_TYPE_HEADER, listHeaderAD())
|
||||
}
|
||||
|
||||
fun setItems(list: List<ListModel>, commitCallback: Runnable) {
|
||||
@@ -77,5 +78,6 @@ class MangaListAdapter(
|
||||
const val ITEM_TYPE_ERROR_STATE = 6
|
||||
const val ITEM_TYPE_ERROR_FOOTER = 7
|
||||
const val ITEM_TYPE_EMPTY = 8
|
||||
const val ITEM_TYPE_HEADER = 9
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.koitharu.kotatsu.list.ui.model
|
||||
|
||||
data class ListHeader(
|
||||
val text: CharSequence,
|
||||
) : ListModel
|
||||
@@ -10,12 +10,12 @@ import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
import org.koitharu.kotatsu.core.model.MangaFilter
|
||||
import org.koitharu.kotatsu.core.parser.MangaRepository
|
||||
import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.list.ui.MangaFilterConfig
|
||||
import org.koitharu.kotatsu.list.ui.MangaListViewModel
|
||||
import org.koitharu.kotatsu.list.ui.model.*
|
||||
import org.koitharu.kotatsu.utils.ext.asLiveDataDistinct
|
||||
import java.util.*
|
||||
|
||||
class RemoteListViewModel(
|
||||
private val repository: MangaRepository,
|
||||
@@ -27,6 +27,7 @@ class RemoteListViewModel(
|
||||
private val listError = MutableStateFlow<Throwable?>(null)
|
||||
private var appliedFilter: MangaFilter? = null
|
||||
private var loadingJob: Job? = null
|
||||
private val headerModel = ListHeader((repository as RemoteMangaRepository).title)
|
||||
|
||||
override val content = combine(
|
||||
mangaList,
|
||||
@@ -39,7 +40,8 @@ class RemoteListViewModel(
|
||||
list == null -> listOf(LoadingState)
|
||||
list.isEmpty() -> listOf(EmptyState(R.drawable.ic_book_cross, R.string.nothing_found, R.string._empty))
|
||||
else -> {
|
||||
val result = ArrayList<ListModel>(list.size + 1)
|
||||
val result = ArrayList<ListModel>(list.size + 2)
|
||||
result += headerModel
|
||||
list.toUi(result, mode)
|
||||
when {
|
||||
error != null -> result += error.toErrorFooter()
|
||||
|
||||
Reference in New Issue
Block a user