Compare commits
No commits in common. "1392e2a571550e136419bad00a2f8dce225cb075" and "dec620a40947d699914804fbc218605a0a6dddd3" have entirely different histories.
1392e2a571
...
dec620a409
@ -408,7 +408,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
||||
|
||||
val drawerListener = object : DrawerLayout.DrawerListener {
|
||||
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
|
||||
// We do nothing
|
||||
}
|
||||
|
||||
override fun onDrawerOpened(drawerView: View) {
|
||||
@ -420,7 +419,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
||||
}
|
||||
|
||||
override fun onDrawerStateChanged(newState: Int) {
|
||||
// We do nothing
|
||||
}
|
||||
|
||||
}
|
||||
@ -471,45 +469,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
||||
private fun handleDrawerItems() {
|
||||
tagsBadge = emptyMap()
|
||||
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>?) {
|
||||
if (maybeTags == null) {
|
||||
if (loadedFromCache) {
|
||||
@ -523,7 +482,38 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
||||
.filterNot { hiddenTags.contains(it.tag) }
|
||||
.sortedBy { it.unread == 0 }
|
||||
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)
|
||||
}.toMap()
|
||||
@ -544,7 +534,37 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
||||
val filteredHiddenTags: List<SelfossModel.Tag> =
|
||||
maybeTags.filter { hiddenTags.contains(it.tag) }
|
||||
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)
|
||||
}.toMap()
|
||||
|
Loading…
Reference in New Issue
Block a user