|
@@ -8,11 +8,12 @@ import android.widget.TextView
|
8
|
8
|
import android.view.LayoutInflater
|
9
|
9
|
import android.view.ViewGroup
|
10
|
10
|
import androidx.constraintlayout.widget.ConstraintLayout
|
11
|
|
-import androidx.core.content.ContextCompat.startActivity
|
12
|
11
|
import androidx.core.text.HtmlCompat
|
13
|
12
|
import androidx.core.widget.TextViewCompat
|
14
|
13
|
import androidx.recyclerview.widget.RecyclerView
|
15
|
14
|
import fr.forum_thalie.tsumugi.R
|
|
15
|
+import java.text.SimpleDateFormat
|
|
16
|
+import java.util.*
|
16
|
17
|
import kotlin.collections.ArrayList
|
17
|
18
|
|
18
|
19
|
class NewsAdapter(private val dataSet: ArrayList<News>, private val c: Context
|
|
@@ -48,6 +49,7 @@ class NewsAdapter(private val dataSet: ArrayList<News>, private val c: Context
|
48
|
49
|
val text = holder.itemView.findViewById<TextView>(R.id.news_text)
|
49
|
50
|
val author = holder.itemView.findViewById<TextView>(R.id.news_author)
|
50
|
51
|
val header = holder.itemView.findViewById<TextView>(R.id.news_header)
|
|
52
|
+ val date = holder.itemView.findViewById<TextView>(R.id.news_date)
|
51
|
53
|
title.text = dataSet[position].title
|
52
|
54
|
title.setOnClickListener {
|
53
|
55
|
val i = Intent(Intent.ACTION_VIEW)
|
|
@@ -57,6 +59,8 @@ class NewsAdapter(private val dataSet: ArrayList<News>, private val c: Context
|
57
|
59
|
text.text = HtmlCompat.fromHtml(dataSet[position].text, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
58
|
60
|
header.text = HtmlCompat.fromHtml(dataSet[position].header, HtmlCompat.FROM_HTML_MODE_LEGACY).replace(Regex("\n"), " ")
|
59
|
61
|
author.text = "| ${dataSet[position].author}"
|
|
62
|
+ val sdf = SimpleDateFormat("dd MMM yyyy", Locale.getDefault())
|
|
63
|
+ date.text = sdf.format(dataSet[position].date)
|
60
|
64
|
TextViewCompat.setAutoSizeTextTypeWithDefaults(author, TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM)
|
61
|
65
|
}
|
62
|
66
|
|