Set notifications count to badge in drawer

This commit is contained in:
Carl Vuorinen 2019-03-17 21:47:24 +02:00
parent e232a9b016
commit 15a352982b
2 changed files with 10 additions and 0 deletions

View file

@ -374,6 +374,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
displayDeathDialogIfNeeded()
YesterdailyDialog.showDialogIfNeeded(this, user?.id, userRepository, taskRepository)
drawerFragment?.setNotificationsCount(this.user?.notifications?.count() ?: 0)
drawerFragment?.setMessagesCount(this.user?.inbox?.newMessages ?: 0)
drawerFragment?.setSettingsCount(if (this.user?.flags?.isVerifiedUsername != true) 1 else 0 )

View file

@ -306,6 +306,15 @@ class NavigationDrawerFragment : DialogFragment() {
outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition)
}
fun setNotificationsCount(unreadNotifications: Int) {
if (unreadNotifications == 0) {
notificationsBadge.visibility = View.GONE
} else {
notificationsBadge.visibility = View.VISIBLE
notificationsBadge.text = unreadNotifications.toString()
}
}
fun setMessagesCount(unreadMessages: Int) {
if (unreadMessages == 0) {
messagesBadge.visibility = View.GONE