Browse Source

added clickable links

yattoz 4 years ago
parent
commit
900f9175b0

+ 0 - 11
app/src/main/java/fr/forum_thalie/tsumugi/RadioService.kt View File

36
 import fr.forum_thalie.tsumugi.alarm.RadioSleeper
36
 import fr.forum_thalie.tsumugi.alarm.RadioSleeper
37
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
37
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
38
 import java.util.*
38
 import java.util.*
39
-import kotlin.collections.ArrayList
40
 import kotlin.math.exp
39
 import kotlin.math.exp
41
 import kotlin.math.ln
40
 import kotlin.math.ln
42
 import kotlin.system.exitProcess
41
 import kotlin.system.exitProcess
362
                     Log.e(tag, radioTag + "onMetadata: Title ----> ${entry.title}")
361
                     Log.e(tag, radioTag + "onMetadata: Title ----> ${entry.title}")
363
                     // Note : Kotlin supports UTF-8 by default.
362
                     // Note : Kotlin supports UTF-8 by default.
364
                     numberOfSongs++
363
                     numberOfSongs++
365
-                    val s = entry.title!!
366
-                    val a = ArrayList<Int>()
367
-
368
-                    for (j in s.indices)
369
-                    {
370
-                        a.add(s[j].toInt())
371
-
372
-                    }
373
-                    Log.e(tag, a.toString())
374
-                    Log.e(tag, "raw: ${it}")
375
                     val data = entry.title!!
364
                     val data = entry.title!!
376
                     PlayerStore.instance.currentSong.setTitleArtist(data)
365
                     PlayerStore.instance.currentSong.setTitleArtist(data)
377
                 }
366
                 }

+ 7 - 13
app/src/main/java/fr/forum_thalie/tsumugi/ui/news/NewsAdapter.kt View File

2
 
2
 
3
 import android.annotation.SuppressLint
3
 import android.annotation.SuppressLint
4
 import android.app.Activity
4
 import android.app.Activity
5
-import android.app.PendingIntent.getActivity
6
 import android.content.Context
5
 import android.content.Context
7
-import android.content.Intent
8
 import android.graphics.Bitmap
6
 import android.graphics.Bitmap
9
 import android.graphics.BitmapFactory
7
 import android.graphics.BitmapFactory
10
 import android.graphics.Point
8
 import android.graphics.Point
11
 import android.graphics.drawable.BitmapDrawable
9
 import android.graphics.drawable.BitmapDrawable
12
 import android.graphics.drawable.Drawable
10
 import android.graphics.drawable.Drawable
13
 import android.graphics.drawable.LevelListDrawable
11
 import android.graphics.drawable.LevelListDrawable
14
-import android.net.Uri
15
 import android.os.AsyncTask
12
 import android.os.AsyncTask
16
 import android.text.Html.ImageGetter
13
 import android.text.Html.ImageGetter
14
+import android.text.method.LinkMovementMethod
17
 import android.view.LayoutInflater
15
 import android.view.LayoutInflater
18
 import android.view.ViewGroup
16
 import android.view.ViewGroup
19
 import android.widget.TextView
17
 import android.widget.TextView
121
         val author = holder.itemView.findViewById<TextView>(R.id.news_author)
119
         val author = holder.itemView.findViewById<TextView>(R.id.news_author)
122
         val header = holder.itemView.findViewById<TextView>(R.id.news_header)
120
         val header = holder.itemView.findViewById<TextView>(R.id.news_header)
123
         val date = holder.itemView.findViewById<TextView>(R.id.news_date)
121
         val date = holder.itemView.findViewById<TextView>(R.id.news_date)
124
-        title.text = dataSet[position].title
125
-        title.setOnClickListener {
126
-            val i = Intent(Intent.ACTION_VIEW)
127
-            i.data = Uri.parse(dataSet[position].link)
128
-            c.startActivity(i)
129
-        }
122
+
123
+        val titleLink = "<a href=\"${dataSet[position].link}\">${dataSet[position].title}</>"
124
+        title.text = HtmlCompat.fromHtml(titleLink, HtmlCompat.FROM_HTML_MODE_LEGACY)
125
+        title.movementMethod = LinkMovementMethod.getInstance()
126
+
130
         header.text = HtmlCompat.fromHtml(dataSet[position].header, HtmlCompat.FROM_HTML_MODE_LEGACY).replace(Regex("\n"), " ")
127
         header.text = HtmlCompat.fromHtml(dataSet[position].header, HtmlCompat.FROM_HTML_MODE_LEGACY).replace(Regex("\n"), " ")
131
         author.text = "| ${dataSet[position].author}"
128
         author.text = "| ${dataSet[position].author}"
132
         val sdf = SimpleDateFormat("dd MMM yyyy", Locale.getDefault())
129
         val sdf = SimpleDateFormat("dd MMM yyyy", Locale.getDefault())
133
         date.text = sdf.format(dataSet[position].date)
130
         date.text = sdf.format(dataSet[position].date)
134
         TextViewCompat.setAutoSizeTextTypeWithDefaults(author, TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM)
131
         TextViewCompat.setAutoSizeTextTypeWithDefaults(author, TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM)
135
-        //val html = HtmlCompat.fromHtml(dataSet[position].text, HtmlCompat.FROM_HTML_MODE_LEGACY)
136
-
137
 
132
 
138
         val spanned = HtmlCompat.fromHtml(
133
         val spanned = HtmlCompat.fromHtml(
139
             dataSet[position].text,
134
             dataSet[position].text,
149
             }, null
144
             }, null
150
         )
145
         )
151
         text.text = spanned
146
         text.text = spanned
152
-
153
-
147
+        text.movementMethod = LinkMovementMethod.getInstance()
154
     }
148
     }
155
 
149
 
156
     // Return the size of your dataset (invoked by the layout manager)
150
     // Return the size of your dataset (invoked by the layout manager)