Library filter UI change (#1211)

* similar library filter to catalog filter

* removed some commented out code

* code review changes

* fixed accidentally removing title
This commit is contained in:
Carlos 2018-02-16 09:23:15 -05:00 committed by Bram van de Kerkhof
parent c1845aec83
commit 6c1453eb54
7 changed files with 17 additions and 25 deletions

View File

@ -33,9 +33,9 @@ class SortItem(val name: String, val group: SortGroup) : AbstractSectionableItem
val i = filter.values.indexOf(name) val i = filter.values.indexOf(name)
fun getIcon() = when (filter.state) { fun getIcon() = when (filter.state) {
Filter.Sort.Selection(i, false) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_arrow_down_32dp, null) Filter.Sort.Selection(i, false) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_arrow_down_white_32dp, null)
?.apply { setTint(view.context.getResourceColor(R.attr.colorAccent)) } ?.apply { setTint(view.context.getResourceColor(R.attr.colorAccent)) }
Filter.Sort.Selection(i, true) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_arrow_up_32dp, null) Filter.Sort.Selection(i, true) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_arrow_up_white_32dp, null)
?.apply { setTint(view.context.getResourceColor(R.attr.colorAccent)) } ?.apply { setTint(view.context.getResourceColor(R.attr.colorAccent)) }
else -> ContextCompat.getDrawable(view.context, R.drawable.empty_drawable_32dp) else -> ContextCompat.getDrawable(view.context, R.drawable.empty_drawable_32dp)
} }

View File

@ -35,7 +35,6 @@ import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.ui.migration.MigrationController import eu.kanade.tachiyomi.ui.migration.MigrationController
import eu.kanade.tachiyomi.util.inflate import eu.kanade.tachiyomi.util.inflate
import eu.kanade.tachiyomi.util.toast import eu.kanade.tachiyomi.util.toast
import eu.kanade.tachiyomi.widget.DrawerSwipeCloseListener
import kotlinx.android.synthetic.main.library_controller.* import kotlinx.android.synthetic.main.library_controller.*
import kotlinx.android.synthetic.main.main_activity.* import kotlinx.android.synthetic.main.main_activity.*
import rx.Subscription import rx.Subscription
@ -177,11 +176,8 @@ class LibraryController(
override fun createSecondaryDrawer(drawer: DrawerLayout): ViewGroup { override fun createSecondaryDrawer(drawer: DrawerLayout): ViewGroup {
val view = drawer.inflate(R.layout.library_drawer) as LibraryNavigationView val view = drawer.inflate(R.layout.library_drawer) as LibraryNavigationView
drawerListener = DrawerSwipeCloseListener(drawer, view).also {
drawer.addDrawerListener(it)
}
navView = view navView = view
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END) drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.END)
navView?.onGroupClicked = { group -> navView?.onGroupClicked = { group ->
when (group) { when (group) {
@ -196,8 +192,6 @@ class LibraryController(
} }
override fun cleanupSecondaryDrawer(drawer: DrawerLayout) { override fun cleanupSecondaryDrawer(drawer: DrawerLayout) {
drawerListener?.let { drawer.removeDrawerListener(it) }
drawerListener = null
navView = null navView = null
} }

View File

@ -62,7 +62,6 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
onGroupClicked(item.group) onGroupClicked(item.group)
} }
} }
} }
/** /**
@ -99,7 +98,6 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
adapter.notifyItemChanged(item) adapter.notifyItemChanged(item)
} }
} }
/** /**
@ -215,7 +213,5 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
item.group.items.forEach { adapter.notifyItemChanged(it) } item.group.items.forEach { adapter.notifyItemChanged(it) }
} }
} }
} }

View File

@ -9,7 +9,6 @@ import android.support.v7.widget.RecyclerView
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.getResourceColor import eu.kanade.tachiyomi.util.getResourceColor
@ -100,8 +99,8 @@ open class ExtendedNavigationView @JvmOverloads constructor(
override fun getStateDrawable(context: Context): Drawable? { override fun getStateDrawable(context: Context): Drawable? {
return when (state) { return when (state) {
SORT_ASC -> tintVector(context, R.drawable.ic_keyboard_arrow_up_black_32dp) SORT_ASC -> tintVector(context, R.drawable.ic_arrow_up_white_32dp)
SORT_DESC -> tintVector(context, R.drawable.ic_keyboard_arrow_down_black_32dp) SORT_DESC -> tintVector(context, R.drawable.ic_arrow_down_white_32dp)
SORT_NONE -> ContextCompat.getDrawable(context, R.drawable.empty_drawable_32dp) SORT_NONE -> ContextCompat.getDrawable(context, R.drawable.empty_drawable_32dp)
else -> null else -> null
} }
@ -206,9 +205,8 @@ open class ExtendedNavigationView @JvmOverloads constructor(
override fun onBindViewHolder(holder: Holder, position: Int) { override fun onBindViewHolder(holder: Holder, position: Int) {
when (holder) { when (holder) {
is HeaderHolder -> { is HeaderHolder -> {
val view = holder.itemView as TextView
val item = items[position] as Item.Header val item = items[position] as Item.Header
view.setText(item.resTitle) holder.title.setText(item.resTitle)
} }
is SeparatorHolder -> { is SeparatorHolder -> {
val view = holder.itemView val view = holder.itemView

View File

@ -89,7 +89,11 @@ open class SimpleNavigationView @JvmOverloads constructor(
* Header view holder. * Header view holder.
*/ */
class HeaderHolder(parent: ViewGroup) class HeaderHolder(parent: ViewGroup)
: Holder(parent.inflate(R.layout.design_navigation_item_subheader)) : Holder(parent.inflate(TR.layout.navigation_view_group)){
val title: TextView = itemView.findViewById(TR.id.title)
}
/** /**
* Clickable view holder. * Clickable view holder.