Ver código fonte

added Html decoding for UTF-8 chars decoded with ISO8859-1 by Airtime

yattoz 5 anos atrás
pai
commit
0b37a838e9

+ 4 - 3
app/src/main/java/fr/forum_thalie/tsumugi/playerstore/Song.kt Ver arquivo

@@ -1,5 +1,6 @@
1 1
 package fr.forum_thalie.tsumugi.playerstore
2 2
 
3
+import androidx.core.text.HtmlCompat
3 4
 import androidx.lifecycle.MutableLiveData
4 5
 import fr.forum_thalie.tsumugi.noConnectionValue
5 6
 
@@ -24,8 +25,9 @@ class Song(artistTitle: String = "", _id : Int = 0) {
24 25
         return "id=$id | ${artist.value} - ${title.value} | type=${type.value} | times ${startTime.value} - ${stopTime.value}\n"
25 26
     }
26 27
 
27
-    fun setTitleArtist(data: String)
28
+    fun setTitleArtist(dataHtml: String)
28 29
     {
30
+        val data = HtmlCompat.fromHtml(dataHtml, HtmlCompat.FROM_HTML_MODE_LEGACY).toString()
29 31
         val hyphenPos = data.indexOf(" - ")
30 32
         try {
31 33
             if (hyphenPos < 0)
@@ -50,8 +52,7 @@ class Song(artistTitle: String = "", _id : Int = 0) {
50 52
     }
51 53
 
52 54
     fun copy(song: Song) {
53
-        this.title.value = song.title.value
54
-        this.artist.value = song.artist.value
55
+        this.setTitleArtist(song.artist.value + " - " + song.title.value)
55 56
         this.startTime.value = song.startTime.value
56 57
         this.stopTime.value = song.stopTime.value
57 58
         this.type.value = song.type.value