|
@@ -2,18 +2,16 @@ package fr.forum_thalie.tsumugi.ui.news
|
2
|
2
|
|
3
|
3
|
import android.annotation.SuppressLint
|
4
|
4
|
import android.app.Activity
|
5
|
|
-import android.app.PendingIntent.getActivity
|
6
|
5
|
import android.content.Context
|
7
|
|
-import android.content.Intent
|
8
|
6
|
import android.graphics.Bitmap
|
9
|
7
|
import android.graphics.BitmapFactory
|
10
|
8
|
import android.graphics.Point
|
11
|
9
|
import android.graphics.drawable.BitmapDrawable
|
12
|
10
|
import android.graphics.drawable.Drawable
|
13
|
11
|
import android.graphics.drawable.LevelListDrawable
|
14
|
|
-import android.net.Uri
|
15
|
12
|
import android.os.AsyncTask
|
16
|
13
|
import android.text.Html.ImageGetter
|
|
14
|
+import android.text.method.LinkMovementMethod
|
17
|
15
|
import android.view.LayoutInflater
|
18
|
16
|
import android.view.ViewGroup
|
19
|
17
|
import android.widget.TextView
|
|
@@ -121,19 +119,16 @@ class NewsAdapter(private val dataSet: ArrayList<News>, private val c: Context
|
121
|
119
|
val author = holder.itemView.findViewById<TextView>(R.id.news_author)
|
122
|
120
|
val header = holder.itemView.findViewById<TextView>(R.id.news_header)
|
123
|
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
|
127
|
header.text = HtmlCompat.fromHtml(dataSet[position].header, HtmlCompat.FROM_HTML_MODE_LEGACY).replace(Regex("\n"), " ")
|
131
|
128
|
author.text = "| ${dataSet[position].author}"
|
132
|
129
|
val sdf = SimpleDateFormat("dd MMM yyyy", Locale.getDefault())
|
133
|
130
|
date.text = sdf.format(dataSet[position].date)
|
134
|
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
|
133
|
val spanned = HtmlCompat.fromHtml(
|
139
|
134
|
dataSet[position].text,
|
|
@@ -149,8 +144,7 @@ class NewsAdapter(private val dataSet: ArrayList<News>, private val c: Context
|
149
|
144
|
}, null
|
150
|
145
|
)
|
151
|
146
|
text.text = spanned
|
152
|
|
-
|
153
|
|
-
|
|
147
|
+ text.movementMethod = LinkMovementMethod.getInstance()
|
154
|
148
|
}
|
155
|
149
|
|
156
|
150
|
// Return the size of your dataset (invoked by the layout manager)
|