mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-24 21:00:55 +03:00
Created different notification when Ultrasonic is only downloading files
Fixed null check
This commit is contained in:
parent
01aa1fe887
commit
be49145aa8
@ -33,6 +33,8 @@ class Downloader(
|
||||
private val localMediaPlayer: LocalMediaPlayer
|
||||
) : KoinComponent {
|
||||
val playlist: MutableList<DownloadFile> = ArrayList()
|
||||
var started: Boolean = false
|
||||
|
||||
private val downloadQueue: PriorityQueue<DownloadFile> = PriorityQueue<DownloadFile>()
|
||||
private val activelyDownloading: MutableList<DownloadFile> = ArrayList()
|
||||
|
||||
@ -63,6 +65,7 @@ class Downloader(
|
||||
}
|
||||
|
||||
fun start() {
|
||||
started = true
|
||||
if (executorService == null) {
|
||||
executorService = Executors.newSingleThreadScheduledExecutor()
|
||||
executorService!!.scheduleWithFixedDelay(
|
||||
@ -78,10 +81,12 @@ class Downloader(
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
started = false
|
||||
executorService?.shutdown()
|
||||
executorService = null
|
||||
wifiLock?.release()
|
||||
wifiLock = null
|
||||
MediaPlayerService.runningInstance?.notifyDownloaderStopped()
|
||||
Timber.i("Downloader stopped")
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,10 @@ class MediaPlayerService : Service() {
|
||||
}
|
||||
}
|
||||
|
||||
fun notifyDownloaderStopped() {
|
||||
stopIfIdle()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun seekTo(position: Int) {
|
||||
if (jukeboxMediaPlayer.isEnabled) {
|
||||
@ -582,15 +586,14 @@ class MediaPlayerService : Service() {
|
||||
// Clear old actions
|
||||
notificationBuilder!!.clearActions()
|
||||
|
||||
// Add actions
|
||||
val compactActions = addActions(context, notificationBuilder!!, playerState, song)
|
||||
|
||||
// Configure shortcut actions
|
||||
style.setShowActionsInCompactView(*compactActions)
|
||||
notificationBuilder!!.setStyle(style)
|
||||
|
||||
// Set song title, artist and cover if possible
|
||||
if (song != null) {
|
||||
// Add actions
|
||||
val compactActions = addActions(context, notificationBuilder!!, playerState, song)
|
||||
// Configure shortcut actions
|
||||
style.setShowActionsInCompactView(*compactActions)
|
||||
notificationBuilder!!.setStyle(style)
|
||||
|
||||
// Set song title, artist and cover
|
||||
val iconSize = (256 * context.resources.displayMetrics.density).toInt()
|
||||
val bitmap = BitmapUtils.getAlbumArtBitmapFromDisk(song, iconSize)
|
||||
notificationBuilder!!.setContentTitle(song.title)
|
||||
@ -598,6 +601,14 @@ class MediaPlayerService : Service() {
|
||||
notificationBuilder!!.setLargeIcon(bitmap)
|
||||
notificationBuilder!!.setSubText(song.album)
|
||||
}
|
||||
else if (downloader.started)
|
||||
{
|
||||
// No song is playing, but Ultrasonic is downloading files
|
||||
notificationBuilder!!.setContentTitle(
|
||||
getString(R.string.notification_downloading_title)
|
||||
)
|
||||
}
|
||||
|
||||
return notificationBuilder!!.build()
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ object FileUtil {
|
||||
Locale.ROOT,
|
||||
"%s/%s",
|
||||
musicDirectory.path,
|
||||
if (entry.isDirectory) f.path else f.parent!!
|
||||
if (entry.isDirectory) f.path else f.parent ?: ""
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
@ -400,6 +400,7 @@
|
||||
<string name="settings.debug.log_keep">Keep files</string>
|
||||
<string name="settings.debug.log_delete">Delete files</string>
|
||||
<string name="settings.debug.log_deleted">Deleted log files.</string>
|
||||
<string name="notification.downloading_title">Downloading media in the background…</string>
|
||||
|
||||
<string name="permissions.access_error">Ultrasonic can\'t access the music file cache. Cache location was reset to the default path.</string>
|
||||
<string name="permissions.message_box_title">Warning</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user