diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/BookmarksFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/BookmarksFragment.kt index a37e65f05..8ed2b3298 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/BookmarksFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/BookmarksFragment.kt @@ -29,7 +29,6 @@ import org.koitharu.kotatsu.core.ui.util.ReversibleAction import org.koitharu.kotatsu.core.ui.util.reverseAsync import org.koitharu.kotatsu.core.util.ext.observe import org.koitharu.kotatsu.core.util.ext.observeEvent -import org.koitharu.kotatsu.core.util.ext.scaleUpActivityOptionsOf import org.koitharu.kotatsu.databinding.FragmentListSimpleBinding import org.koitharu.kotatsu.details.ui.DetailsActivity import org.koitharu.kotatsu.list.ui.MangaListSpanResolver @@ -84,7 +83,7 @@ class BookmarksFragment : with(binding.recyclerView) { setHasFixedSize(true) val spanResolver = MangaListSpanResolver(resources) - addItemDecoration(TypedListSpacingDecoration(context)) + addItemDecoration(TypedListSpacingDecoration(context, false)) adapter = bookmarksAdapter addOnLayoutChangeListener(spanResolver) spanResolver.setGridSize(settings.gridSize / 100f, this) @@ -159,10 +158,11 @@ class BookmarksFragment : } override fun onWindowInsetsChanged(insets: Insets) { - requireViewBinding().recyclerView.updatePadding( - bottom = insets.bottom, + val rv = requireViewBinding().recyclerView + rv.updatePadding( + bottom = insets.bottom + rv.paddingTop, ) - requireViewBinding().recyclerView.fastScroller.updateLayoutParams { + rv.fastScroller.updateLayoutParams { bottomMargin = insets.bottom } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/sheet/BookmarksSheet.kt b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/sheet/BookmarksSheet.kt index e11c0103b..1d229a251 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/sheet/BookmarksSheet.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/sheet/BookmarksSheet.kt @@ -75,7 +75,7 @@ class BookmarksSheet : ) viewBinding?.headerBar?.setTitle(R.string.bookmarks) with(binding.recyclerView) { - addItemDecoration(TypedListSpacingDecoration(context)) + addItemDecoration(TypedListSpacingDecoration(context, false)) adapter = bookmarksAdapter addOnLayoutChangeListener(spanResolver) spanResolver?.setGridSize(settings.gridSize / 100f, this) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadsActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadsActivity.kt index ca024aeae..c7387dda6 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadsActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadsActivity.kt @@ -7,7 +7,6 @@ import android.view.Menu import android.view.MenuItem import android.view.View import androidx.activity.viewModels -import androidx.annotation.Px import androidx.appcompat.view.ActionMode import androidx.core.graphics.Insets import androidx.core.view.updatePadding @@ -37,16 +36,12 @@ class DownloadsActivity : BaseActivity(), private val viewModel by viewModels() private lateinit var selectionController: ListSelectionController - @Px - private var listSpacing = 0 - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(ActivityDownloadsBinding.inflate(layoutInflater)) - listSpacing = resources.getDimensionPixelOffset(R.dimen.list_spacing) supportActionBar?.setDisplayHomeAsUpEnabled(true) val downloadsAdapter = DownloadsAdapter(this, coil, this) - val decoration = TypedListSpacingDecoration(this) + val decoration = TypedListSpacingDecoration(this, false) selectionController = ListSelectionController( activity = this, decoration = DownloadsSelectionDecoration(this), @@ -71,9 +66,10 @@ class DownloadsActivity : BaseActivity(), } override fun onWindowInsetsChanged(insets: Insets) { - viewBinding.recyclerView.updatePadding( - left = insets.left + listSpacing, - right = insets.right + listSpacing, + val rv = viewBinding.recyclerView + rv.updatePadding( + left = insets.left + rv.paddingTop, + right = insets.right + rv.paddingTop, bottom = insets.bottom, ) viewBinding.toolbar.updatePadding( diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreFragment.kt index 94864079d..01e48676e 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreFragment.kt @@ -74,7 +74,7 @@ class ExploreFragment : adapter = exploreAdapter setHasFixedSize(true) SpanSizeResolver(this, resources.getDimensionPixelSize(R.dimen.explore_grid_width)).attach() - addItemDecoration(TypedListSpacingDecoration(context)) + addItemDecoration(TypedListSpacingDecoration(context, false)) } addMenuProvider(ExploreMenuProvider(binding.root.context, viewModel)) viewModel.content.observe(viewLifecycleOwner) { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/favourites/ui/categories/FavouriteCategoriesActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/favourites/ui/categories/FavouriteCategoriesActivity.kt index 9f24171ad..1c719cf5a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/favourites/ui/categories/FavouriteCategoriesActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/favourites/ui/categories/FavouriteCategoriesActivity.kt @@ -24,6 +24,7 @@ import org.koitharu.kotatsu.databinding.ActivityCategoriesBinding import org.koitharu.kotatsu.favourites.ui.categories.adapter.CategoriesAdapter import org.koitharu.kotatsu.favourites.ui.categories.edit.FavouritesCategoryEditActivity import org.koitharu.kotatsu.list.ui.adapter.ListStateHolderListener +import org.koitharu.kotatsu.list.ui.adapter.TypedListSpacingDecoration import org.koitharu.kotatsu.list.ui.model.ListModel import org.koitharu.kotatsu.parsers.model.SortOrder import javax.inject.Inject @@ -58,6 +59,7 @@ class FavouriteCategoriesActivity : selectionController.attachToRecyclerView(viewBinding.recyclerView) viewBinding.recyclerView.setHasFixedSize(true) viewBinding.recyclerView.adapter = adapter + viewBinding.recyclerView.addItemDecoration(TypedListSpacingDecoration(this, false)) viewBinding.fabAdd.setOnClickListener(this) reorderHelper = ItemTouchHelper(ReorderHelperCallback()).apply { @@ -106,7 +108,7 @@ class FavouriteCategoriesActivity : right = insets.right, ) viewBinding.recyclerView.updatePadding( - bottom = insets.bottom, + bottom = insets.bottom + viewBinding.recyclerView.paddingTop, ) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/favourites/ui/categories/adapter/CategoriesAdapter.kt b/app/src/main/kotlin/org/koitharu/kotatsu/favourites/ui/categories/adapter/CategoriesAdapter.kt index 7e0412abc..df5767f7b 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/favourites/ui/categories/adapter/CategoriesAdapter.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/favourites/ui/categories/adapter/CategoriesAdapter.kt @@ -4,6 +4,7 @@ import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import org.koitharu.kotatsu.core.ui.BaseListAdapter import org.koitharu.kotatsu.favourites.ui.categories.FavouriteCategoriesListListener +import org.koitharu.kotatsu.list.ui.adapter.ListItemType import org.koitharu.kotatsu.list.ui.adapter.ListStateHolderListener import org.koitharu.kotatsu.list.ui.adapter.emptyStateListAD import org.koitharu.kotatsu.list.ui.adapter.loadingStateAD @@ -17,8 +18,8 @@ class CategoriesAdapter( ) : BaseListAdapter() { init { - delegatesManager.addDelegate(categoryAD(coil, lifecycleOwner, onItemClickListener)) - .addDelegate(emptyStateListAD(coil, lifecycleOwner, listListener)) - .addDelegate(loadingStateAD()) + addDelegate(ListItemType.CATEGORY_LARGE ,categoryAD(coil, lifecycleOwner, onItemClickListener)) + addDelegate(ListItemType.STATE_EMPTY ,emptyStateListAD(coil, lifecycleOwner, listListener)) + addDelegate(ListItemType.STATE_LOADING ,loadingStateAD()) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/filter/ui/FilterSheetFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/filter/ui/FilterSheetFragment.kt index 04e727258..03d4d3eb7 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/filter/ui/FilterSheetFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/filter/ui/FilterSheetFragment.kt @@ -33,7 +33,7 @@ class FilterSheetFragment : val adapter = FilterAdapter(filter, this) binding.recyclerView.adapter = adapter filter.filterItems.observe(viewLifecycleOwner, adapter) - binding.recyclerView.addItemDecoration(TypedListSpacingDecoration(binding.root.context)) + binding.recyclerView.addItemDecoration(TypedListSpacingDecoration(binding.root.context, false)) if (dialog == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { binding.recyclerView.scrollIndicators = 0 diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/MangaListFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/MangaListFragment.kt index e48d25fc5..4a2a304e3 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/MangaListFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/MangaListFragment.kt @@ -108,7 +108,7 @@ abstract class MangaListFragment : setHasFixedSize(true) adapter = listAdapter checkNotNull(selectionController).attachToRecyclerView(binding.recyclerView) - addItemDecoration(TypedListSpacingDecoration(context)) + addItemDecoration(TypedListSpacingDecoration(context, false)) addOnScrollListener(paginationListener!!) fastScroller.setFastScrollListener(this@MangaListFragment) } @@ -247,21 +247,16 @@ abstract class MangaListFragment : when (mode) { ListMode.LIST -> { layoutManager = FitHeightLinearLayoutManager(context) - updatePadding(left = 0, right = 0) } ListMode.DETAILED_LIST -> { layoutManager = FitHeightLinearLayoutManager(context) - val spacing = resources.getDimensionPixelOffset(R.dimen.list_spacing) - updatePadding(left = spacing, right = spacing) } ListMode.GRID -> { layoutManager = FitHeightGridLayoutManager(context, checkNotNull(spanResolver).spanCount).also { it.spanSizeLookup = spanSizeLookup } - val spacing = resources.getDimensionPixelOffset(R.dimen.grid_spacing) - updatePadding(left = spacing, right = spacing) addOnLayoutChangeListener(spanResolver) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/ListItemType.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/ListItemType.kt index b12eb169f..79b9b4d93 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/ListItemType.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/ListItemType.kt @@ -23,4 +23,6 @@ enum class ListItemType { PAGE_THUMB, FEED, DOWNLOAD, + CATEGORY_LARGE, + MANGA_SCROBBLING, } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/TypedListSpacingDecoration.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/TypedListSpacingDecoration.kt index dd06e62ef..eb0509865 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/TypedListSpacingDecoration.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/TypedListSpacingDecoration.kt @@ -9,11 +9,12 @@ import org.koitharu.kotatsu.R class TypedListSpacingDecoration( context: Context, + private val addHorizontalPadding: Boolean, ) : ItemDecoration() { - private val spacingList = context.resources.getDimensionPixelOffset(R.dimen.list_spacing) - private val spacingGrid = context.resources.getDimensionPixelOffset(R.dimen.grid_spacing) - private val spacingGridTop = context.resources.getDimensionPixelOffset(R.dimen.grid_spacing_top) + private val spacingSmall = context.resources.getDimensionPixelOffset(R.dimen.list_spacing_small) + private val spacingNormal = context.resources.getDimensionPixelOffset(R.dimen.list_spacing_normal) + private val spacingLarge = context.resources.getDimensionPixelOffset(R.dimen.list_spacing_large) override fun getItemOffsets( outRect: Rect, @@ -28,33 +29,45 @@ class TypedListSpacingDecoration( ListItemType.FILTER_SORT, ListItemType.FILTER_TAG -> outRect.set(0) - ListItemType.HEADER -> outRect.set(spacingList, 0, spacingList, 0) - + ListItemType.HEADER, + ListItemType.FEED, ListItemType.EXPLORE_SOURCE_LIST, - ListItemType.MANGA_LIST -> outRect.set(spacingList, 0, spacingList, 0) + ListItemType.MANGA_SCROBBLING, + ListItemType.MANGA_LIST -> outRect.set(0) ListItemType.DOWNLOAD, - ListItemType.MANGA_LIST_DETAILED -> outRect.set(spacingList) + ListItemType.HINT_EMPTY, + ListItemType.MANGA_LIST_DETAILED -> outRect.set(spacingNormal) ListItemType.PAGE_THUMB, - ListItemType.MANGA_GRID -> outRect.set(spacingGrid) + ListItemType.MANGA_GRID -> outRect.set(spacingNormal) + + ListItemType.EXPLORE_BUTTONS -> outRect.set(spacingNormal) ListItemType.FOOTER_LOADING, ListItemType.FOOTER_ERROR, ListItemType.STATE_LOADING, ListItemType.STATE_ERROR, ListItemType.STATE_EMPTY, - ListItemType.EXPLORE_BUTTONS, ListItemType.EXPLORE_SOURCE_GRID, ListItemType.EXPLORE_SUGGESTION, ListItemType.MANGA_NESTED_GROUP, + ListItemType.CATEGORY_LARGE, null -> outRect.set(0) ListItemType.TIP -> outRect.set(0) // TODO - ListItemType.HINT_EMPTY, - ListItemType.FEED -> outRect.set(spacingList, 0, spacingList, 0) + } + if (addHorizontalPadding && !itemType.isEdgeToEdge()) { + outRect.set( + outRect.left + spacingNormal, + outRect.top, + outRect.right + spacingNormal, + outRect.bottom, + ) } } private fun Rect.set(spacing: Int) = set(spacing, spacing, spacing, spacing) + + private fun ListItemType?.isEdgeToEdge() = this == ListItemType.MANGA_NESTED_GROUP } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/thumbnails/PagesThumbnailsSheet.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/thumbnails/PagesThumbnailsSheet.kt index 2a555539f..8c31c4c25 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/thumbnails/PagesThumbnailsSheet.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/thumbnails/PagesThumbnailsSheet.kt @@ -23,7 +23,6 @@ import org.koitharu.kotatsu.core.util.RecyclerViewScrollCallback import org.koitharu.kotatsu.core.util.ext.observe import org.koitharu.kotatsu.core.util.ext.observeEvent import org.koitharu.kotatsu.core.util.ext.plus -import org.koitharu.kotatsu.core.util.ext.scaleUpActivityOptionsOf import org.koitharu.kotatsu.core.util.ext.showDistinct import org.koitharu.kotatsu.core.util.ext.withArgs import org.koitharu.kotatsu.databinding.SheetPagesBinding @@ -75,7 +74,7 @@ class PagesThumbnailsSheet : clickListener = this@PagesThumbnailsSheet, ) with(binding.recyclerView) { - addItemDecoration(TypedListSpacingDecoration(context)) + addItemDecoration(TypedListSpacingDecoration(context, false)) adapter = thumbnailsAdapter addOnLayoutChangeListener(spanResolver) spanResolver?.setGridSize(settings.gridSize / 100f, this) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/ScrobblerConfigActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/ScrobblerConfigActivity.kt index 7b8d28d1b..e6d252e12 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/ScrobblerConfigActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/ScrobblerConfigActivity.kt @@ -38,9 +38,6 @@ class ScrobblerConfigActivity : BaseActivity(), private val viewModel: ScrobblerConfigViewModel by viewModels() - private var paddingVertical = 0 - private var paddingHorizontal = 0 - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(ActivityScrobblerConfigBinding.inflate(layoutInflater)) @@ -51,10 +48,7 @@ class ScrobblerConfigActivity : BaseActivity(), with(viewBinding.recyclerView) { adapter = listAdapter setHasFixedSize(true) - val spacing = resources.getDimensionPixelOffset(R.dimen.list_spacing) - paddingHorizontal = spacing - paddingVertical = resources.getDimensionPixelOffset(R.dimen.grid_spacing_outer) - val decoration = TypedListSpacingDecoration(context) + val decoration = TypedListSpacingDecoration(context, false) addItemDecoration(decoration) } viewBinding.imageViewAvatar.setOnClickListener(this) @@ -79,10 +73,11 @@ class ScrobblerConfigActivity : BaseActivity(), } override fun onWindowInsetsChanged(insets: Insets) { - viewBinding.recyclerView.updatePadding( - left = insets.left + paddingHorizontal, - right = insets.right + paddingHorizontal, - bottom = insets.bottom + paddingVertical, + val rv = viewBinding.recyclerView + rv.updatePadding( + left = insets.left + rv.paddingTop, + right = insets.right + rv.paddingTop, + bottom = insets.bottom + rv.paddingTop, ) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingHeaderAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingHeaderAD.kt index cb233abf0..6a3b088a7 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingHeaderAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingHeaderAD.kt @@ -1,16 +1,20 @@ package org.koitharu.kotatsu.scrobbling.common.ui.config.adapter -import android.widget.TextView -import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegate +import androidx.core.view.isInvisible +import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding import org.koitharu.kotatsu.R +import org.koitharu.kotatsu.databinding.ItemHeaderButtonBinding import org.koitharu.kotatsu.list.ui.model.ListModel import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblingStatus -fun scrobblingHeaderAD() = adapterDelegate(R.layout.item_header) { +fun scrobblingHeaderAD() = adapterDelegateViewBinding( + { inflater, parent -> ItemHeaderButtonBinding.inflate(inflater, parent, false) }, +) { + + binding.buttonMore.isInvisible = true + val strings = context.resources.getStringArray(R.array.scrobbling_statuses) bind { - (itemView as TextView).text = context.resources - .getStringArray(R.array.scrobbling_statuses) - .getOrNull(item.ordinal) + binding.textViewTitle.text = strings.getOrNull(item.ordinal) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingMangaAdapter.kt b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingMangaAdapter.kt index 9efa98bb5..b43004a6d 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingMangaAdapter.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingMangaAdapter.kt @@ -4,6 +4,7 @@ import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import org.koitharu.kotatsu.core.ui.BaseListAdapter import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener +import org.koitharu.kotatsu.list.ui.adapter.ListItemType import org.koitharu.kotatsu.list.ui.adapter.emptyStateListAD import org.koitharu.kotatsu.list.ui.model.ListModel import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblingInfo @@ -15,8 +16,8 @@ class ScrobblingMangaAdapter( ) : BaseListAdapter() { init { - delegatesManager.addDelegate(scrobblingMangaAD(clickListener, coil, lifecycleOwner)) - .addDelegate(scrobblingHeaderAD()) - .addDelegate(emptyStateListAD(coil, lifecycleOwner, null)) + addDelegate(ListItemType.HEADER, scrobblingHeaderAD()) + addDelegate(ListItemType.STATE_EMPTY, emptyStateListAD(coil, lifecycleOwner, null)) + addDelegate(ListItemType.MANGA_SCROBBLING, scrobblingMangaAD(clickListener, coil, lifecycleOwner)) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/ScrobblingSelectorSheet.kt b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/ScrobblingSelectorSheet.kt index c729e8600..72b434fba 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/ScrobblingSelectorSheet.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/ScrobblingSelectorSheet.kt @@ -26,6 +26,7 @@ import org.koitharu.kotatsu.core.util.ext.observeEvent import org.koitharu.kotatsu.core.util.ext.withArgs import org.koitharu.kotatsu.databinding.SheetScrobblingSelectorBinding import org.koitharu.kotatsu.list.ui.adapter.ListStateHolderListener +import org.koitharu.kotatsu.list.ui.adapter.TypedListSpacingDecoration import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblerManga import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblerService @@ -63,6 +64,7 @@ class ScrobblingSelectorSheet : with(binding.recyclerView) { adapter = listAdapter addItemDecoration(decoration) + addItemDecoration(TypedListSpacingDecoration(context, false)) addOnScrollListener(PaginationScrollListener(4, this@ScrobblingSelectorSheet)) } binding.buttonDone.setOnClickListener(this) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/adapter/ScrobblerSelectorAdapter.kt b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/adapter/ScrobblerSelectorAdapter.kt index b730e0790..f8d230fd0 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/adapter/ScrobblerSelectorAdapter.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/adapter/ScrobblerSelectorAdapter.kt @@ -4,6 +4,7 @@ import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import org.koitharu.kotatsu.core.ui.BaseListAdapter import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener +import org.koitharu.kotatsu.list.ui.adapter.ListItemType import org.koitharu.kotatsu.list.ui.adapter.ListStateHolderListener import org.koitharu.kotatsu.list.ui.adapter.loadingFooterAD import org.koitharu.kotatsu.list.ui.adapter.loadingStateAD @@ -18,9 +19,9 @@ class ScrobblerSelectorAdapter( ) : BaseListAdapter() { init { - delegatesManager.addDelegate(loadingStateAD()) - .addDelegate(scrobblingMangaAD(lifecycleOwner, coil, clickListener)) - .addDelegate(loadingFooterAD()) - .addDelegate(scrobblerHintAD(stateHolderListener)) + addDelegate(ListItemType.STATE_LOADING, loadingStateAD()) + addDelegate(ListItemType.MANGA_SCROBBLING, scrobblingMangaAD(lifecycleOwner, coil, clickListener)) + addDelegate(ListItemType.FOOTER_LOADING, loadingFooterAD()) + addDelegate(ListItemType.HINT_EMPTY, scrobblerHintAD(stateHolderListener)) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/multi/MultiSearchActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/multi/MultiSearchActivity.kt index 8d2514df3..cb1087221 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/multi/MultiSearchActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/multi/MultiSearchActivity.kt @@ -23,13 +23,13 @@ import org.koitharu.kotatsu.core.util.ShareHelper import org.koitharu.kotatsu.core.util.ext.invalidateNestedItemDecorations import org.koitharu.kotatsu.core.util.ext.observe import org.koitharu.kotatsu.core.util.ext.observeEvent -import org.koitharu.kotatsu.core.util.ext.scaleUpActivityOptionsOf import org.koitharu.kotatsu.databinding.ActivitySearchMultiBinding import org.koitharu.kotatsu.details.ui.DetailsActivity import org.koitharu.kotatsu.download.ui.worker.DownloadStartedObserver import org.koitharu.kotatsu.favourites.ui.categories.select.FavouriteSheet import org.koitharu.kotatsu.list.ui.MangaSelectionDecoration import org.koitharu.kotatsu.list.ui.adapter.MangaListListener +import org.koitharu.kotatsu.list.ui.adapter.TypedListSpacingDecoration import org.koitharu.kotatsu.list.ui.model.ListHeader import org.koitharu.kotatsu.list.ui.size.DynamicItemSizeResolver import org.koitharu.kotatsu.parsers.model.Manga @@ -83,6 +83,7 @@ class MultiSearchActivity : ) viewBinding.recyclerView.adapter = adapter viewBinding.recyclerView.setHasFixedSize(true) + viewBinding.recyclerView.addItemDecoration(TypedListSpacingDecoration(this, true)) supportActionBar?.run { setDisplayHomeAsUpEnabled(true) @@ -100,7 +101,7 @@ class MultiSearchActivity : right = insets.right, ) viewBinding.recyclerView.updatePadding( - bottom = insets.bottom, + bottom = insets.bottom + viewBinding.recyclerView.paddingTop, ) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/multi/adapter/MultiSearchAdapter.kt b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/multi/adapter/MultiSearchAdapter.kt index dd86aa7c0..607c525ee 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/multi/adapter/MultiSearchAdapter.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/multi/adapter/MultiSearchAdapter.kt @@ -6,6 +6,7 @@ import coil.ImageLoader import org.koitharu.kotatsu.core.ui.BaseListAdapter import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener import org.koitharu.kotatsu.list.ui.MangaSelectionDecoration +import org.koitharu.kotatsu.list.ui.adapter.ListItemType import org.koitharu.kotatsu.list.ui.adapter.MangaListListener import org.koitharu.kotatsu.list.ui.adapter.emptyStateListAD import org.koitharu.kotatsu.list.ui.adapter.errorStateListAD @@ -26,21 +27,21 @@ class MultiSearchAdapter( init { val pool = RecycledViewPool() - delegatesManager - .addDelegate( - searchResultsAD( - sharedPool = pool, - lifecycleOwner = lifecycleOwner, - coil = coil, - sizeResolver = sizeResolver, - selectionDecoration = selectionDecoration, - listener = listener, - itemClickListener = itemClickListener, - ), - ) - .addDelegate(loadingStateAD()) - .addDelegate(loadingFooterAD()) - .addDelegate(emptyStateListAD(coil, lifecycleOwner, listener)) - .addDelegate(errorStateListAD(listener)) + addDelegate( + ListItemType.MANGA_NESTED_GROUP, + searchResultsAD( + sharedPool = pool, + lifecycleOwner = lifecycleOwner, + coil = coil, + sizeResolver = sizeResolver, + selectionDecoration = selectionDecoration, + listener = listener, + itemClickListener = itemClickListener, + ), + ) + addDelegate(ListItemType.STATE_LOADING, loadingStateAD()) + addDelegate(ListItemType.FOOTER_LOADING, loadingFooterAD()) + addDelegate(ListItemType.STATE_EMPTY, emptyStateListAD(coil, lifecycleOwner, listener)) + addDelegate(ListItemType.STATE_ERROR, errorStateListAD(listener)) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/ui/feed/FeedFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/ui/feed/FeedFragment.kt index faa8594c4..d399058a0 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/ui/feed/FeedFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/ui/feed/FeedFragment.kt @@ -58,7 +58,7 @@ class FeedFragment : adapter = feedAdapter setHasFixedSize(true) addOnScrollListener(PaginationScrollListener(4, this@FeedFragment)) - addItemDecoration(TypedListSpacingDecoration(context)) + addItemDecoration(TypedListSpacingDecoration(context, true)) } binding.swipeRefreshLayout.setOnRefreshListener(this) addMenuProvider( @@ -82,8 +82,9 @@ class FeedFragment : } override fun onWindowInsetsChanged(insets: Insets) { - requireViewBinding().recyclerView.updatePadding( - bottom = insets.bottom, + val rv = requireViewBinding().recyclerView + rv.updatePadding( + bottom = insets.bottom + rv.paddingTop, ) } diff --git a/app/src/main/res/drawable/list_selector.xml b/app/src/main/res/drawable/list_selector.xml index b1763b045..4299c0e1e 100644 --- a/app/src/main/res/drawable/list_selector.xml +++ b/app/src/main/res/drawable/list_selector.xml @@ -5,32 +5,32 @@ + android:top="2dp"> + android:top="2dp"> + android:left="2dp" + android:right="2dp" + android:top="2dp"> @@ -38,4 +38,15 @@ - \ No newline at end of file + + + + + + + diff --git a/app/src/main/res/layout/activity_categories.xml b/app/src/main/res/layout/activity_categories.xml index a16d2432d..015099611 100644 --- a/app/src/main/res/layout/activity_categories.xml +++ b/app/src/main/res/layout/activity_categories.xml @@ -48,7 +48,7 @@ android:layout_height="match_parent" android:clipToPadding="false" android:orientation="vertical" - android:paddingVertical="@dimen/list_spacing" + android:padding="@dimen/list_spacing_normal" android:scrollbars="vertical" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" diff --git a/app/src/main/res/layout/activity_downloads.xml b/app/src/main/res/layout/activity_downloads.xml index 4c1397a85..5db1a3dd2 100644 --- a/app/src/main/res/layout/activity_downloads.xml +++ b/app/src/main/res/layout/activity_downloads.xml @@ -35,7 +35,7 @@ android:layout_height="match_parent" android:clipToPadding="false" android:orientation="vertical" - android:paddingHorizontal="@dimen/list_spacing" + android:padding="@dimen/list_spacing_normal" android:scrollbars="vertical" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" diff --git a/app/src/main/res/layout/activity_scrobbler_config.xml b/app/src/main/res/layout/activity_scrobbler_config.xml index 1bdc1a44d..8817afdec 100644 --- a/app/src/main/res/layout/activity_scrobbler_config.xml +++ b/app/src/main/res/layout/activity_scrobbler_config.xml @@ -52,10 +52,7 @@ android:layout_height="match_parent" android:clipToPadding="false" android:orientation="vertical" - android:paddingLeft="@dimen/list_spacing" - android:paddingTop="@dimen/grid_spacing_outer" - android:paddingRight="@dimen/list_spacing" - android:paddingBottom="@dimen/grid_spacing_outer" + android:padding="@dimen/list_spacing_normal" android:scrollbars="vertical" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" diff --git a/app/src/main/res/layout/activity_shelf_settings.xml b/app/src/main/res/layout/activity_shelf_settings.xml deleted file mode 100644 index a4c9781a8..000000000 --- a/app/src/main/res/layout/activity_shelf_settings.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - -