Compare commits
2 Commits
dec620a409
...
1392e2a571
Author | SHA1 | Date | |
---|---|---|---|
|
1392e2a571 | ||
|
e9cb3d2f37 |
@ -408,6 +408,7 @@ 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) {
|
||||||
@ -419,6 +420,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDrawerStateChanged(newState: Int) {
|
override fun onDrawerStateChanged(newState: Int) {
|
||||||
|
// We do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -469,6 +471,45 @@ 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) {
|
||||||
@ -482,38 +523,7 @@ 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 {
|
||||||
val gd = GradientDrawable()
|
createDrawerItem(it)
|
||||||
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()
|
||||||
@ -534,37 +544,7 @@ 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 {
|
||||||
val gd = GradientDrawable()
|
createDrawerItem(it)
|
||||||
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