Compare commits
17 Commits
49abc081b6
...
17f7d58aed
Author | SHA1 | Date | |
---|---|---|---|
17f7d58aed | |||
ad2dfcae1b | |||
ef0f326073 | |||
3aa6934f86 | |||
0cec538d18 | |||
5eb46dc4e9 | |||
a0d6159cf4 | |||
bea8f18db4 | |||
9712f2846f | |||
c361819664 | |||
0145349817 | |||
e71f8718d7 | |||
8f5cc6efa4 | |||
0fa133d89e | |||
f54bdf93d3 | |||
f7a29d66ca | |||
|
734b0b7112 |
@ -406,7 +406,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
|||||||
|
|
||||||
val drawerListener = object : DrawerLayout.DrawerListener {
|
val drawerListener = object : DrawerLayout.DrawerListener {
|
||||||
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
|
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
|
||||||
// We do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDrawerOpened(drawerView: View) {
|
override fun onDrawerOpened(drawerView: View) {
|
||||||
@ -418,7 +417,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDrawerStateChanged(newState: Int) {
|
override fun onDrawerStateChanged(newState: Int) {
|
||||||
// We do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -469,45 +467,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
|||||||
private fun handleDrawerItems() {
|
private fun handleDrawerItems() {
|
||||||
tagsBadge = emptyMap()
|
tagsBadge = emptyMap()
|
||||||
fun handleDrawerData(maybeDrawerData: DrawerData?, loadedFromCache: Boolean = false) {
|
fun handleDrawerData(maybeDrawerData: DrawerData?, loadedFromCache: Boolean = false) {
|
||||||
fun createDrawerItem(
|
|
||||||
it: SelfossModel.Tag
|
|
||||||
) {
|
|
||||||
val gd = GradientDrawable()
|
|
||||||
val gdColor = try {
|
|
||||||
Color.parseColor(it.color)
|
|
||||||
} catch (e: IllegalArgumentException) {
|
|
||||||
appColors.colorPrimary
|
|
||||||
}
|
|
||||||
|
|
||||||
gd.setColor(gdColor)
|
|
||||||
gd.shape = GradientDrawable.RECTANGLE
|
|
||||||
gd.setSize(30, 30)
|
|
||||||
gd.cornerRadius = 30F
|
|
||||||
|
|
||||||
val drawerItem = PrimaryDrawerItem()
|
|
||||||
.apply {
|
|
||||||
nameText = it.getTitleDecoded()
|
|
||||||
identifier = it.tag.longHash()
|
|
||||||
iconDrawable = gd
|
|
||||||
badgeStyle = BadgeStyle().apply {
|
|
||||||
textColor = ColorHolder.fromColor(Color.WHITE)
|
|
||||||
color = ColorHolder.fromColor(appColors.colorAccent)
|
|
||||||
}
|
|
||||||
onDrawerItemClickListener = { _, _, _ ->
|
|
||||||
repository.tagFilter = it
|
|
||||||
repository.sourceFilter = null
|
|
||||||
getElementsAccordingToTab()
|
|
||||||
fetchOnEmptyList()
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (it.unread > 0) {
|
|
||||||
drawerItem.badgeText = it.unread.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.mainDrawer.itemAdapter.add(drawerItem)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun handleTags(maybeTags: List<SelfossModel.Tag>?) {
|
fun handleTags(maybeTags: List<SelfossModel.Tag>?) {
|
||||||
if (maybeTags == null) {
|
if (maybeTags == null) {
|
||||||
if (loadedFromCache) {
|
if (loadedFromCache) {
|
||||||
@ -521,7 +480,38 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
|||||||
.filterNot { hiddenTags.contains(it.tag) }
|
.filterNot { hiddenTags.contains(it.tag) }
|
||||||
.sortedBy { it.unread == 0 }
|
.sortedBy { it.unread == 0 }
|
||||||
tagsBadge = filteredTags.map {
|
tagsBadge = filteredTags.map {
|
||||||
createDrawerItem(it)
|
val gd = GradientDrawable()
|
||||||
|
val gdColor = try {
|
||||||
|
Color.parseColor(it.color)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
appColors.colorPrimary
|
||||||
|
}
|
||||||
|
|
||||||
|
gd.setColor(gdColor)
|
||||||
|
gd.shape = GradientDrawable.RECTANGLE
|
||||||
|
gd.setSize(30, 30)
|
||||||
|
gd.cornerRadius = 30F
|
||||||
|
val drawerItem =
|
||||||
|
PrimaryDrawerItem()
|
||||||
|
.apply {
|
||||||
|
nameText = it.getTitleDecoded()
|
||||||
|
identifier = it.tag.longHash()
|
||||||
|
iconDrawable = gd
|
||||||
|
badgeStyle = BadgeStyle().apply {
|
||||||
|
textColor = ColorHolder.fromColor(Color.WHITE)
|
||||||
|
color = ColorHolder.fromColor(appColors.colorAccent) }
|
||||||
|
onDrawerItemClickListener = { _,_,_ ->
|
||||||
|
repository.tagFilter = it
|
||||||
|
repository.sourceFilter = null
|
||||||
|
getElementsAccordingToTab()
|
||||||
|
fetchOnEmptyList()
|
||||||
|
false
|
||||||
|
} }
|
||||||
|
if (it.unread > 0) {
|
||||||
|
drawerItem.badgeText = it.unread.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.mainDrawer.itemAdapter.add(drawerItem)
|
||||||
|
|
||||||
(it.tag.longHash() to it.unread)
|
(it.tag.longHash() to it.unread)
|
||||||
}.toMap()
|
}.toMap()
|
||||||
@ -542,7 +532,37 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
|||||||
val filteredHiddenTags: List<SelfossModel.Tag> =
|
val filteredHiddenTags: List<SelfossModel.Tag> =
|
||||||
maybeTags.filter { hiddenTags.contains(it.tag) }
|
maybeTags.filter { hiddenTags.contains(it.tag) }
|
||||||
tagsBadge = filteredHiddenTags.map {
|
tagsBadge = filteredHiddenTags.map {
|
||||||
createDrawerItem(it)
|
val gd = GradientDrawable()
|
||||||
|
val gdColor = try {
|
||||||
|
Color.parseColor(it.color)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
appColors.colorPrimary
|
||||||
|
}
|
||||||
|
|
||||||
|
gd.setColor(gdColor)
|
||||||
|
gd.shape = GradientDrawable.RECTANGLE
|
||||||
|
gd.setSize(30, 30)
|
||||||
|
gd.cornerRadius = 30F
|
||||||
|
val drawerItem =
|
||||||
|
PrimaryDrawerItem().apply {
|
||||||
|
nameText = it.getTitleDecoded()
|
||||||
|
identifier = it.tag.longHash()
|
||||||
|
iconDrawable = gd
|
||||||
|
badgeStyle = BadgeStyle().apply {
|
||||||
|
textColor = ColorHolder.fromColor(Color.WHITE)
|
||||||
|
color = ColorHolder.fromColor(appColors.colorAccent) }
|
||||||
|
onDrawerItemClickListener = { _,_,_ ->
|
||||||
|
repository.tagFilter = it
|
||||||
|
repository.sourceFilter = null
|
||||||
|
getElementsAccordingToTab()
|
||||||
|
fetchOnEmptyList()
|
||||||
|
false
|
||||||
|
} }
|
||||||
|
|
||||||
|
if (it.unread > 0) {
|
||||||
|
drawerItem.badgeText = it.unread.toString()
|
||||||
|
}
|
||||||
|
binding.mainDrawer.itemAdapter.add(drawerItem)
|
||||||
|
|
||||||
(it.tag.longHash() to it.unread)
|
(it.tag.longHash() to it.unread)
|
||||||
}.toMap()
|
}.toMap()
|
||||||
|
Loading…
Reference in New Issue
Block a user