Last few changes for comfortable grid
This commit is contained in:
parent
1ba236e551
commit
bc85e95d0a
@ -130,8 +130,10 @@ open class BrowseSourcePresenter(
|
||||
query = savedState.getString(::query.name, "")
|
||||
}
|
||||
|
||||
prefs.catalogueViewSetting().asObservable()
|
||||
.subscribe { setDisplayMode(it) }
|
||||
add(
|
||||
prefs.catalogueViewSetting().asObservable()
|
||||
.subscribe { setDisplayMode(it) }
|
||||
)
|
||||
|
||||
restartPager()
|
||||
}
|
||||
|
@ -13,15 +13,14 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import exh.util.updateLayoutParams
|
||||
import kotlinx.android.synthetic.main.source_grid_item.view.card
|
||||
import kotlinx.android.synthetic.main.source_grid_item.view.gradient
|
||||
|
||||
class SourceItem(val manga: Manga, private val catalogueAsList: Preference<Int>) :
|
||||
class SourceItem(val manga: Manga, private val catalogueViewSetting: Preference<Int>) :
|
||||
AbstractFlexibleItem<SourceHolder>() {
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return when (catalogueAsList.get()) {
|
||||
return when (catalogueViewSetting.get()) {
|
||||
0 -> R.layout.source_grid_item
|
||||
1 -> R.layout.source_list_item
|
||||
else -> R.layout.source_comfortable_grid_item
|
||||
@ -35,7 +34,7 @@ class SourceItem(val manga: Manga, private val catalogueAsList: Preference<Int>)
|
||||
val parent = adapter.recyclerView
|
||||
return if (parent is AutofitRecyclerView) {
|
||||
val coverHeight = parent.itemWidth / 3 * 4
|
||||
if (catalogueAsList.get() == 0) {
|
||||
if (catalogueViewSetting.get() == 0) {
|
||||
view.apply {
|
||||
card.layoutParams = FrameLayout.LayoutParams(
|
||||
MATCH_PARENT, coverHeight
|
||||
@ -47,9 +46,9 @@ class SourceItem(val manga: Manga, private val catalogueAsList: Preference<Int>)
|
||||
SourceGridHolder(view, adapter)
|
||||
} else {
|
||||
view.apply {
|
||||
card.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
height = coverHeight
|
||||
}
|
||||
card.layoutParams = ConstraintLayout.LayoutParams(
|
||||
MATCH_PARENT, coverHeight
|
||||
)
|
||||
gradient.layoutParams = FrameLayout.LayoutParams(
|
||||
MATCH_PARENT, coverHeight / 2, Gravity.BOTTOM
|
||||
)
|
||||
|
@ -18,7 +18,6 @@ import eu.kanade.tachiyomi.data.database.models.Track
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import exh.util.updateLayoutParams
|
||||
import kotlinx.android.synthetic.main.source_comfortable_grid_item.view.title
|
||||
import kotlinx.android.synthetic.main.source_grid_item.view.card
|
||||
import kotlinx.android.synthetic.main.source_grid_item.view.gradient
|
||||
@ -46,9 +45,9 @@ class LibraryItem(val manga: LibraryManga, private val libraryViewSetting: Prefe
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): LibraryHolder {
|
||||
val parent = adapter.recyclerView
|
||||
return if (parent is AutofitRecyclerView) {
|
||||
val coverHeight = parent.itemWidth / 3 * 4
|
||||
if (libraryViewSetting.get() == 0) {
|
||||
view.apply {
|
||||
val coverHeight = parent.itemWidth / 3 * 4
|
||||
card.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, coverHeight)
|
||||
gradient.layoutParams = FrameLayout.LayoutParams(
|
||||
MATCH_PARENT, coverHeight / 2, Gravity.BOTTOM
|
||||
@ -57,10 +56,9 @@ class LibraryItem(val manga: LibraryManga, private val libraryViewSetting: Prefe
|
||||
LibraryGridHolder(view, adapter)
|
||||
} else {
|
||||
view.apply {
|
||||
val coverHeight = parent.itemWidth / 3 * 4
|
||||
card.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
height = coverHeight
|
||||
}
|
||||
card.layoutParams = ConstraintLayout.LayoutParams(
|
||||
MATCH_PARENT, coverHeight
|
||||
)
|
||||
gradient.layoutParams = FrameLayout.LayoutParams(
|
||||
MATCH_PARENT, coverHeight / 2, Gravity.BOTTOM
|
||||
)
|
||||
|
@ -301,10 +301,10 @@ class LibraryPresenter(
|
||||
* value.
|
||||
*/
|
||||
private fun getLibraryMangasObservable(): Observable<LibraryMap> {
|
||||
val libraryAsList = preferences.libraryViewSetting()
|
||||
val libraryViewSetting = preferences.libraryViewSetting()
|
||||
return db.getLibraryMangas().asRxObservable()
|
||||
.map { list ->
|
||||
list.map { LibraryItem(it, libraryAsList) }.groupBy { it.manga.category }
|
||||
list.map { LibraryItem(it, libraryViewSetting) }.groupBy { it.manga.category }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user