From f4a6b45a5aad4909fb35c4ace277841202773ff3 Mon Sep 17 00:00:00 2001 From: vfsfitvnm Date: Sun, 12 Jun 2022 12:27:35 +0200 Subject: [PATCH] Remove unnecessary lazy delegations --- .../it/vfsfitvnm/vimusic/services/PlayerService.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/services/PlayerService.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/services/PlayerService.kt index ce262a7..37991bb 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/services/PlayerService.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/services/PlayerService.kt @@ -64,15 +64,11 @@ class PlayerService : MediaSessionService(), MediaSession.MediaItemFiller, private const val NotificationChannelId = "default_channel_id" } - private val cache: SimpleCache by lazy(LazyThreadSafetyMode.NONE) { - SimpleCache(cacheDir, NoOpCacheEvictor(), StandaloneDatabaseProvider(this)) - } + private lateinit var cache: SimpleCache private lateinit var mediaSession: MediaSession - private val notificationManager by lazy(LazyThreadSafetyMode.NONE) { - getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - } + private lateinit var notificationManager: NotificationManager private var lastArtworkUri: Uri? = null private var lastBitmap: Bitmap? = null @@ -87,6 +83,8 @@ class PlayerService : MediaSessionService(), MediaSession.MediaItemFiller, createNotificationChannel() setMediaNotificationProvider(this) + cache = SimpleCache(cacheDir, NoOpCacheEvictor(), StandaloneDatabaseProvider(this)) + val player = ExoPlayer.Builder(this) .setHandleAudioBecomingNoisy(true) .setWakeMode(C.WAKE_MODE_LOCAL) @@ -351,6 +349,7 @@ class PlayerService : MediaSessionService(), MediaSession.MediaItemFiller, ) = Unit private fun createNotificationChannel() { + notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager if (Util.SDK_INT >= 26 && notificationManager.getNotificationChannel(NotificationChannelId) == null) { notificationManager.createNotificationChannel( NotificationChannel(