Reduce number of issues reported by detekt

Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
Dariusz Olszewski 2022-04-26 23:00:24 +02:00 committed by Andy Scherzinger
parent a234c178a8
commit b96bba47b5
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B

View File

@ -182,7 +182,9 @@ object NotificationUtils {
}
fun cancelAllNotificationsForAccount(context: Context?, conversationUser: UserEntity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && conversationUser.id != -1L && context != null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || conversationUser.id == -1L || context == null) {
return
}
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
@ -198,12 +200,11 @@ object NotificationUtils {
}
}
}
}
fun cancelExistingNotificationWithId(context: Context?, conversationUser: UserEntity, notificationId: Long?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && conversationUser.id != -1L &&
context != null
) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || conversationUser.id == -1L || context == null) {
return
}
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
@ -222,16 +223,15 @@ object NotificationUtils {
}
}
}
}
fun findNotificationForRoom(
context: Context?,
conversationUser: UserEntity,
roomTokenOrId: String
): StatusBarNotification? {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && conversationUser.id != -1L &&
context != null
) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || conversationUser.id == -1L || context == null) {
return null
}
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
@ -249,7 +249,6 @@ object NotificationUtils {
}
}
}
}
return null
}
@ -259,11 +258,9 @@ object NotificationUtils {
conversationUser: UserEntity,
roomTokenOrId: String
) {
if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
conversationUser.id != -1L &&
context != null
) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || conversationUser.id == -1L || context == null) {
return
}
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
@ -281,7 +278,6 @@ object NotificationUtils {
}
}
}
}
private fun getRingtoneUri(
context: Context,
@ -297,15 +293,15 @@ object NotificationUtils {
// Notification channel will not be available when starting the application for the first time.
// Ringtone uris are required to register the notification channels -> get uri from preferences.
}
if (TextUtils.isEmpty(ringtonePreferencesString)) {
return Uri.parse(defaultRingtoneUri)
return if (TextUtils.isEmpty(ringtonePreferencesString)) {
Uri.parse(defaultRingtoneUri)
} else {
try {
val ringtoneSettings =
LoganSquare.parse(ringtonePreferencesString, RingtoneSettings::class.java)
return ringtoneSettings.ringtoneUri
ringtoneSettings.ringtoneUri
} catch (exception: IOException) {
return Uri.parse(defaultRingtoneUri)
Uri.parse(defaultRingtoneUri)
}
}
}