added clickable links
parent
d4f6064e69
commit
900f9175b0
|
|
@ -36,7 +36,6 @@ import fr.forum_thalie.tsumugi.alarm.RadioAlarm
|
||||||
import fr.forum_thalie.tsumugi.alarm.RadioSleeper
|
import fr.forum_thalie.tsumugi.alarm.RadioSleeper
|
||||||
import fr.forum_thalie.tsumugi.playerstore.PlayerStore
|
import fr.forum_thalie.tsumugi.playerstore.PlayerStore
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
|
||||||
import kotlin.math.exp
|
import kotlin.math.exp
|
||||||
import kotlin.math.ln
|
import kotlin.math.ln
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
@ -362,16 +361,6 @@ class RadioService : MediaBrowserServiceCompat() {
|
||||||
Log.e(tag, radioTag + "onMetadata: Title ----> ${entry.title}")
|
Log.e(tag, radioTag + "onMetadata: Title ----> ${entry.title}")
|
||||||
// Note : Kotlin supports UTF-8 by default.
|
// Note : Kotlin supports UTF-8 by default.
|
||||||
numberOfSongs++
|
numberOfSongs++
|
||||||
val s = entry.title!!
|
|
||||||
val a = ArrayList<Int>()
|
|
||||||
|
|
||||||
for (j in s.indices)
|
|
||||||
{
|
|
||||||
a.add(s[j].toInt())
|
|
||||||
|
|
||||||
}
|
|
||||||
Log.e(tag, a.toString())
|
|
||||||
Log.e(tag, "raw: ${it}")
|
|
||||||
val data = entry.title!!
|
val data = entry.title!!
|
||||||
PlayerStore.instance.currentSong.setTitleArtist(data)
|
PlayerStore.instance.currentSong.setTitleArtist(data)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,16 @@ package fr.forum_thalie.tsumugi.ui.news
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.PendingIntent.getActivity
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.graphics.Point
|
import android.graphics.Point
|
||||||
import android.graphics.drawable.BitmapDrawable
|
import android.graphics.drawable.BitmapDrawable
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.graphics.drawable.LevelListDrawable
|
import android.graphics.drawable.LevelListDrawable
|
||||||
import android.net.Uri
|
|
||||||
import android.os.AsyncTask
|
import android.os.AsyncTask
|
||||||
import android.text.Html.ImageGetter
|
import android.text.Html.ImageGetter
|
||||||
|
import android.text.method.LinkMovementMethod
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
|
@ -121,19 +119,16 @@ class NewsAdapter(private val dataSet: ArrayList<News>, private val c: Context
|
||||||
val author = holder.itemView.findViewById<TextView>(R.id.news_author)
|
val author = holder.itemView.findViewById<TextView>(R.id.news_author)
|
||||||
val header = holder.itemView.findViewById<TextView>(R.id.news_header)
|
val header = holder.itemView.findViewById<TextView>(R.id.news_header)
|
||||||
val date = holder.itemView.findViewById<TextView>(R.id.news_date)
|
val date = holder.itemView.findViewById<TextView>(R.id.news_date)
|
||||||
title.text = dataSet[position].title
|
|
||||||
title.setOnClickListener {
|
val titleLink = "<a href=\"${dataSet[position].link}\">${dataSet[position].title}</>"
|
||||||
val i = Intent(Intent.ACTION_VIEW)
|
title.text = HtmlCompat.fromHtml(titleLink, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||||
i.data = Uri.parse(dataSet[position].link)
|
title.movementMethod = LinkMovementMethod.getInstance()
|
||||||
c.startActivity(i)
|
|
||||||
}
|
|
||||||
header.text = HtmlCompat.fromHtml(dataSet[position].header, HtmlCompat.FROM_HTML_MODE_LEGACY).replace(Regex("\n"), " ")
|
header.text = HtmlCompat.fromHtml(dataSet[position].header, HtmlCompat.FROM_HTML_MODE_LEGACY).replace(Regex("\n"), " ")
|
||||||
author.text = "| ${dataSet[position].author}"
|
author.text = "| ${dataSet[position].author}"
|
||||||
val sdf = SimpleDateFormat("dd MMM yyyy", Locale.getDefault())
|
val sdf = SimpleDateFormat("dd MMM yyyy", Locale.getDefault())
|
||||||
date.text = sdf.format(dataSet[position].date)
|
date.text = sdf.format(dataSet[position].date)
|
||||||
TextViewCompat.setAutoSizeTextTypeWithDefaults(author, TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM)
|
TextViewCompat.setAutoSizeTextTypeWithDefaults(author, TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM)
|
||||||
//val html = HtmlCompat.fromHtml(dataSet[position].text, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
|
||||||
|
|
||||||
|
|
||||||
val spanned = HtmlCompat.fromHtml(
|
val spanned = HtmlCompat.fromHtml(
|
||||||
dataSet[position].text,
|
dataSet[position].text,
|
||||||
|
|
@ -149,8 +144,7 @@ class NewsAdapter(private val dataSet: ArrayList<News>, private val c: Context
|
||||||
}, null
|
}, null
|
||||||
)
|
)
|
||||||
text.text = spanned
|
text.text = spanned
|
||||||
|
text.movementMethod = LinkMovementMethod.getInstance()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the size of your dataset (invoked by the layout manager)
|
// Return the size of your dataset (invoked by the layout manager)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue