Filters not reset on resume.

This commit is contained in:
Amine 2017-06-07 07:35:55 +02:00
parent 2df5e52de0
commit 3482092cb2

View File

@ -103,6 +103,8 @@ class HomeActivity : AppCompatActivity() {
private var fullHeightCards: Boolean = false private var fullHeightCards: Boolean = false
private var toolbar: Toolbar? = null private var toolbar: Toolbar? = null
private var drawer: Drawer? = null private var drawer: Drawer? = null
private var maybeTagFilter: Tag? = null
private var maybeSourceFilter: Sources? = null
data class DrawerData(val tags: List<Tag>?, val sources: List<Sources>?) data class DrawerData(val tags: List<Tag>?, val sources: List<Sources>?)
@ -215,7 +217,8 @@ class HomeActivity : AppCompatActivity() {
.withColorRes(R.color.colorAccent) .withColorRes(R.color.colorAccent)
) )
.withOnDrawerItemClickListener { _, _, _ -> .withOnDrawerItemClickListener { _, _, _ ->
getElementsAccordingToTab(maybeTagFilter = tag) maybeTagFilter = tag
getElementsAccordingToTab()
false false
} }
) )
@ -237,7 +240,8 @@ class HomeActivity : AppCompatActivity() {
.withIdentifier(tag.id.toLong()) .withIdentifier(tag.id.toLong())
.withIcon(tag.getIcon(this@HomeActivity)) .withIcon(tag.getIcon(this@HomeActivity))
.withOnDrawerItemClickListener { _, _, _ -> .withOnDrawerItemClickListener { _, _, _ ->
getElementsAccordingToTab(maybeSourceFilter = tag) maybeSourceFilter = tag
getElementsAccordingToTab()
false false
} }
) )
@ -253,6 +257,8 @@ class HomeActivity : AppCompatActivity() {
.withIdentifier(DRAWER_ID_FILTERS) .withIdentifier(DRAWER_ID_FILTERS)
.withBadge(getString(R.string.drawer_action_clear)) .withBadge(getString(R.string.drawer_action_clear))
.withOnDrawerItemClickListener { _, _, _ -> .withOnDrawerItemClickListener { _, _, _ ->
maybeSourceFilter = null
maybeTagFilter = null
getElementsAccordingToTab() getElementsAccordingToTab()
false false
} }
@ -462,7 +468,7 @@ class HomeActivity : AppCompatActivity() {
} }
} }
private fun getElementsAccordingToTab(maybeTagFilter: Tag? = null, maybeSourceFilter: Sources? = null) { private fun getElementsAccordingToTab() {
when (elementsShown) { when (elementsShown) {
UNREAD_SHOWN -> getUnRead(maybeTagFilter, maybeSourceFilter) UNREAD_SHOWN -> getUnRead(maybeTagFilter, maybeSourceFilter)