Simpler code

This commit is contained in:
Benoit Marty 2019-07-12 14:50:33 +02:00
parent 222201cc64
commit 0289d2ee87
1 changed files with 5 additions and 10 deletions

View File

@ -60,7 +60,7 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
//The first time the notification drawer is refreshed, we force re-render of all notifications //The first time the notification drawer is refreshed, we force re-render of all notifications
private var firstTime = true private var firstTime = true


private var eventList = loadEventInfo() private val eventList = loadEventInfo()


private val avatarSize = context.resources.getDimensionPixelSize(R.dimen.profile_avatar_size) private val avatarSize = context.resources.getDimensionPixelSize(R.dimen.profile_avatar_size)


@ -123,10 +123,7 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
if (roomId != null) { if (roomId != null) {
synchronized(eventList) { synchronized(eventList) {
eventList.removeAll { e -> eventList.removeAll { e ->
if (e is NotifiableMessageEvent) { e is NotifiableMessageEvent && e.roomId == roomId
return@removeAll e.roomId == roomId
}
return@removeAll false
} }
} }
NotificationUtils.cancelNotificationMessage(context, roomId, ROOM_MESSAGES_NOTIFICATION_ID) NotificationUtils.cancelNotificationMessage(context, roomId, ROOM_MESSAGES_NOTIFICATION_ID)
@ -152,7 +149,8 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
fun homeActivityDidResume(matrixID: String?) { fun homeActivityDidResume(matrixID: String?) {
synchronized(eventList) { synchronized(eventList) {
eventList.removeAll { e -> eventList.removeAll { e ->
return@removeAll e !is NotifiableMessageEvent //messages are cleared when entering room // messages are cleared when entering room
e !is NotifiableMessageEvent
} }
} }
} }
@ -160,10 +158,7 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
fun clearMemberShipNotificationForRoom(roomId: String) { fun clearMemberShipNotificationForRoom(roomId: String) {
synchronized(eventList) { synchronized(eventList) {
eventList.removeAll { e -> eventList.removeAll { e ->
if (e is InviteNotifiableEvent) { e is InviteNotifiableEvent && e.roomId == roomId
return@removeAll e.roomId == roomId
}
return@removeAll false
} }
} }
} }