mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-15 19:20:37 +01:00
Detekt fixes
This commit is contained in:
parent
1313fb6c0c
commit
5dc9fda7a4
@ -70,7 +70,7 @@ style:
|
||||
excludeImportStatements: false
|
||||
MagicNumber:
|
||||
# 100 common in percentage, 1000 in milliseconds
|
||||
ignoreNumbers: ['-1', '0', '1', '2', '5', '10', '100', '256', '512', '1000', '1024']
|
||||
ignoreNumbers: ['-1', '0', '1', '2', '5', '10', '100', '256', '512', '1000', '1024', '4096']
|
||||
ignoreEnums: true
|
||||
ignorePropertyDeclaration: true
|
||||
UnnecessaryAbstractClass:
|
||||
|
@ -1017,6 +1017,7 @@ class PlayerFragment :
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
@Synchronized
|
||||
private fun onSliderProgressChanged() {
|
||||
|
||||
|
@ -43,6 +43,7 @@ import timber.log.Timber
|
||||
* priority) the `dataSpec`, [.setRequestProperty] and the default parameters used to
|
||||
* construct the instance.
|
||||
*/
|
||||
@Suppress("MagicNumber")
|
||||
@UnstableApi
|
||||
open class APIDataSource private constructor(
|
||||
subsonicAPIClient: SubsonicAPIClient
|
||||
@ -124,6 +125,7 @@ open class APIDataSource private constructor(
|
||||
requestProperties.clear()
|
||||
}
|
||||
|
||||
@Suppress("LongMethod", "NestedBlockDepth")
|
||||
@Throws(HttpDataSourceException::class)
|
||||
override fun open(dataSpec: DataSpec): Long {
|
||||
this.dataSpec = dataSpec
|
||||
@ -171,7 +173,7 @@ open class APIDataSource private constructor(
|
||||
}
|
||||
val errorResponseBody: ByteArray = try {
|
||||
Util.toByteArray(Assertions.checkNotNull(responseByteStream))
|
||||
} catch (e: IOException) {
|
||||
} catch (ignore: IOException) {
|
||||
Util.EMPTY_BYTE_ARRAY
|
||||
}
|
||||
val headers = response.headers().toMultimap()
|
||||
@ -241,6 +243,7 @@ open class APIDataSource private constructor(
|
||||
* occurs while reading from the source, or if the data ended before skipping the specified
|
||||
* number of bytes.
|
||||
*/
|
||||
@Suppress("ThrowsCount")
|
||||
@Throws(HttpDataSourceException::class)
|
||||
private fun skipFully(bytesToSkip: Long, dataSpec: DataSpec) {
|
||||
var bytesToSkip = bytesToSkip
|
||||
|
@ -93,11 +93,6 @@ class LegacyPlaylistManager : KoinComponent {
|
||||
val playlist: List<DownloadFile>
|
||||
get() = _playlist
|
||||
|
||||
// FIXME: Returns wrong count if item is twice in queue
|
||||
@get:Synchronized
|
||||
val currentPlayingIndex: Int
|
||||
get() = _playlist.indexOf(currentPlaying)
|
||||
|
||||
@get:Synchronized
|
||||
val playlistDuration: Long
|
||||
get() {
|
||||
|
@ -22,7 +22,6 @@ import androidx.media3.common.MediaMetadata
|
||||
import androidx.media3.common.MediaMetadata.FOLDER_TYPE_MIXED
|
||||
import androidx.media3.common.MediaMetadata.FOLDER_TYPE_NONE
|
||||
import androidx.media3.common.MediaMetadata.FOLDER_TYPE_PLAYLISTS
|
||||
import androidx.media3.common.util.Util
|
||||
import com.google.common.collect.ImmutableList
|
||||
import org.json.JSONObject
|
||||
|
||||
@ -89,12 +88,6 @@ object MediaItemTree {
|
||||
.build()
|
||||
}
|
||||
|
||||
@androidx.media3.common.util.UnstableApi
|
||||
private fun loadJSONFromAsset(assets: AssetManager): String {
|
||||
val buffer = assets.open("catalog.json").use { Util.toByteArray(it) }
|
||||
return String(buffer, Charsets.UTF_8)
|
||||
}
|
||||
|
||||
fun initialize(assets: AssetManager) {
|
||||
if (isInitialized) return
|
||||
isInitialized = true
|
||||
|
@ -12,6 +12,7 @@ import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
@ -38,6 +39,7 @@ internal class MediaNotificationProvider(context: Context) :
|
||||
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
)
|
||||
|
||||
@Suppress("LongMethod")
|
||||
override fun createNotification(
|
||||
mediaController: MediaController,
|
||||
actionFactory: ActionFactory,
|
||||
@ -133,7 +135,7 @@ internal class MediaNotificationProvider(context: Context) :
|
||||
}
|
||||
|
||||
private fun ensureNotificationChannel() {
|
||||
if (Util.SDK_INT < 26 ||
|
||||
if (Util.SDK_INT < Build.VERSION_CODES.O ||
|
||||
notificationManager.getNotificationChannel(NOTIFICATION_CHANNEL_ID) != null
|
||||
) {
|
||||
return
|
||||
|
@ -84,36 +84,6 @@ class DownloadService : Service() {
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
private fun setupOnSongCompletedHandler() {
|
||||
// localMediaPlayer.onSongCompleted = { currentPlaying: DownloadFile? ->
|
||||
// val index = downloader.currentPlayingIndex
|
||||
//
|
||||
// if (currentPlaying != null) {
|
||||
// val song = currentPlaying.track
|
||||
// if (song.bookmarkPosition > 0 && Settings.shouldClearBookmark) {
|
||||
// val musicService = getMusicService()
|
||||
// try {
|
||||
// musicService.deleteBookmark(song.id)
|
||||
// } catch (ignored: Exception) {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (index != -1) {
|
||||
//
|
||||
// if (index + 1 < 0 || index + 1 >= downloader.getPlaylist().size) {
|
||||
// if (Settings.shouldClearPlaylist) {
|
||||
// clear(true)
|
||||
// jukeboxMediaPlayer.updatePlaylist()
|
||||
// }
|
||||
// resetPlayback()
|
||||
// } else {
|
||||
// play(index + 1)
|
||||
// }
|
||||
// }
|
||||
// null
|
||||
// }
|
||||
}
|
||||
|
||||
private fun createNotificationChannel() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
|
||||
|
@ -131,6 +131,7 @@ class Downloader(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod", "ComplexCondition")
|
||||
@Synchronized
|
||||
fun checkDownloadsInternal() {
|
||||
if (!Util.isExternalStoragePresent() || !storageMonitor.isExternalStorageAvailable) {
|
||||
@ -355,6 +356,7 @@ class Downloader(
|
||||
private inner class DownloadTask(private val downloadFile: DownloadFile) : CancellableTask() {
|
||||
val musicService = MusicServiceFactory.getMusicService()
|
||||
|
||||
@Suppress("LongMethod", "ComplexMethod", "NestedBlockDepth")
|
||||
override fun execute() {
|
||||
|
||||
downloadFile.downloadPrepared = false
|
||||
|
@ -100,6 +100,7 @@ class MediaPlayerController(
|
||||
}
|
||||
|
||||
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
|
||||
onTrackCompleted(mediaItem)
|
||||
legacyPlaylistManager.updateCurrentPlaying(mediaItem)
|
||||
publishPlaybackState()
|
||||
}
|
||||
@ -166,6 +167,27 @@ class MediaPlayerController(
|
||||
Timber.d("Processed player state change")
|
||||
}
|
||||
|
||||
private fun onTrackCompleted(mediaItem: MediaItem?) {
|
||||
// This method is called before we update the currentPlaying,
|
||||
// so in fact currentPlaying will refer to the track that has just finished.
|
||||
if (legacyPlaylistManager.currentPlaying != null) {
|
||||
val song = legacyPlaylistManager.currentPlaying!!.track
|
||||
if (song.bookmarkPosition > 0 && Settings.shouldClearBookmark) {
|
||||
val musicService = getMusicService()
|
||||
try {
|
||||
musicService.deleteBookmark(song.id)
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Playback has ended...
|
||||
if (mediaItem == null && Settings.shouldClearPlaylist) {
|
||||
clear(true)
|
||||
jukeboxMediaPlayer.updatePlaylist()
|
||||
}
|
||||
}
|
||||
|
||||
private fun publishPlaybackState() {
|
||||
RxBus.playerStatePublisher.onNext(
|
||||
RxBus.StateWithTrack(
|
||||
@ -465,7 +487,7 @@ class MediaPlayerController(
|
||||
|
||||
playbackStateSerializer.serialize(
|
||||
legacyPlaylistManager.playlist,
|
||||
legacyPlaylistManager.currentPlayingIndex,
|
||||
currentMediaItemIndex,
|
||||
playerPosition
|
||||
)
|
||||
|
||||
|
@ -101,7 +101,7 @@ class MediaPlayerLifecycleSupport : KoinComponent {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
@Suppress("MagicNumber", "ComplexMethod")
|
||||
private fun handleKeyEvent(event: KeyEvent) {
|
||||
|
||||
if (event.action != KeyEvent.ACTION_DOWN || event.repeatCount > 0) return
|
||||
@ -140,6 +140,7 @@ class MediaPlayerLifecycleSupport : KoinComponent {
|
||||
/**
|
||||
* This function processes the intent that could come from other applications.
|
||||
*/
|
||||
@Suppress("ComplexMethod")
|
||||
private fun handleUltrasonicIntent(action: String) {
|
||||
|
||||
val isRunning = created
|
||||
|
Loading…
x
Reference in New Issue
Block a user