Updated category headers

closes #307
This commit is contained in:
Jay 2020-05-04 15:59:10 -04:00
parent 17f0754405
commit ba2d5e4a6d
2 changed files with 3 additions and 7 deletions

View File

@ -159,15 +159,14 @@ class LibraryHeaderItem(
val isAscending = category.isAscending() val isAscending = category.isAscending()
val sortingMode = category.sortingMode() val sortingMode = category.sortingMode()
val sortDrawable = if (category.isHidden) R.drawable.ic_expand_more_24dp val sortDrawable = when {
else when {
sortingMode == LibrarySort.DRAG_AND_DROP || sortingMode == null -> R.drawable.ic_sort_white_24dp sortingMode == LibrarySort.DRAG_AND_DROP || sortingMode == null -> R.drawable.ic_sort_white_24dp
if (sortingMode == LibrarySort.DATE_ADDED || sortingMode == LibrarySort.LATEST_CHAPTER || sortingMode == LibrarySort.LAST_READ) !isAscending else isAscending -> R.drawable.ic_arrow_down_white_24dp if (sortingMode == LibrarySort.DATE_ADDED || sortingMode == LibrarySort.LATEST_CHAPTER || sortingMode == LibrarySort.LAST_READ) !isAscending else isAscending -> R.drawable.ic_arrow_down_white_24dp
else -> R.drawable.ic_arrow_up_white_24dp else -> R.drawable.ic_arrow_up_white_24dp
} }
sortText.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, sortDrawable, 0) sortText.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, sortDrawable, 0)
sortText.setText(if (category.isHidden) R.string.collasped else category.sortRes()) sortText.setText(category.sortRes())
expandImage.setImageResource( expandImage.setImageResource(
if (category.isHidden) R.drawable.ic_expand_more_24dp if (category.isHidden) R.drawable.ic_expand_more_24dp
else R.drawable.ic_expand_less_24dp) else R.drawable.ic_expand_less_24dp)
@ -210,10 +209,6 @@ class LibraryHeaderItem(
private fun showCatSortOptions() { private fun showCatSortOptions() {
val category = val category =
(adapter.getItem(adapterPosition) as? LibraryHeaderItem)?.category ?: return (adapter.getItem(adapterPosition) as? LibraryHeaderItem)?.category ?: return
if (category.isHidden) {
adapter.libraryListener.toggleCategoryVisibility(adapterPosition)
return
}
// Create a PopupMenu, giving it the clicked view for an anchor // Create a PopupMenu, giving it the clicked view for an anchor
val popup = PopupMenu(itemView.context, sortText) val popup = PopupMenu(itemView.context, sortText)

View File

@ -35,6 +35,7 @@
<ImageView <ImageView
android:id="@+id/collapse_arrow" android:id="@+id/collapse_arrow"
android:layout_marginStart="8dp"
android:layout_width="14dp" android:layout_width="14dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/select_all" android:contentDescription="@string/select_all"