mirror of
https://github.com/cmclark00/RetroMusicPlayer.git
synced 2025-05-17 23:55:21 +01:00
* Fix insertAlbumArt function (#1704) * Remove unused import * Replace printStackTrace with logging for album art insertion error handling
This commit is contained in:
parent
79f84965c4
commit
d22fdba9f7
1 changed files with 14 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
|||
package code.name.monkey.retromusic.util
|
||||
|
||||
import android.content.ContentUris
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.database.Cursor
|
||||
|
@ -9,7 +10,6 @@ import android.provider.BaseColumns
|
|||
import android.provider.MediaStore
|
||||
import android.util.Log
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.content.contentValuesOf
|
||||
import androidx.core.net.toUri
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
|
@ -325,17 +325,23 @@ object MusicUtil : KoinComponent {
|
|||
fun insertAlbumArt(
|
||||
context: Context,
|
||||
albumId: Long,
|
||||
path: String?,
|
||||
path: String?
|
||||
) {
|
||||
val contentResolver = context.contentResolver
|
||||
val artworkUri = "content://media/external/audio/albumart".toUri()
|
||||
contentResolver.delete(ContentUris.withAppendedId(artworkUri, albumId), null, null)
|
||||
val values = contentValuesOf(
|
||||
"album_id" to albumId,
|
||||
"_data" to path
|
||||
)
|
||||
|
||||
val values = ContentValues().apply {
|
||||
put("album_id", albumId)
|
||||
put("_data", path)
|
||||
}
|
||||
|
||||
try {
|
||||
contentResolver.insert(artworkUri, values)
|
||||
contentResolver.notifyChange(artworkUri, null)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.e("MusicUtil", "Failed to insert album art", e)
|
||||
}
|
||||
}
|
||||
|
||||
fun isArtistNameUnknown(artistName: String?): Boolean {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue