fix(community): 전체 아이템 말줄임과 폰트를 정렬한다
This commit is contained in:
@@ -6,6 +6,7 @@ import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.TextUtils
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.style.ClickableSpan
|
||||
import android.view.LayoutInflater
|
||||
@@ -46,6 +47,10 @@ class CreatorCommunityAllAdapter(
|
||||
(Long, Int, onSuccess: (GetCommunityPostListResponse) -> Unit) -> Unit
|
||||
) : RecyclerView.Adapter<CreatorCommunityAllAdapter.ViewHolder>() {
|
||||
|
||||
companion object {
|
||||
private const val CONTENT_PREVIEW_MAX_LENGTH = 120
|
||||
}
|
||||
|
||||
val items = mutableListOf<GetCommunityPostListResponse>()
|
||||
|
||||
inner class ViewHolder(
|
||||
@@ -257,26 +262,42 @@ class CreatorCommunityAllAdapter(
|
||||
index: Int
|
||||
) {
|
||||
textView.visibility = View.VISIBLE
|
||||
textView.text = text
|
||||
|
||||
val spannable = SpannableString(text)
|
||||
val pattern = Pattern.compile("https?://\\S+")
|
||||
val matcher = pattern.matcher(spannable)
|
||||
if (isExpand) {
|
||||
val spannable = SpannableString(text)
|
||||
val pattern = Pattern.compile("https?://\\S+")
|
||||
val matcher = pattern.matcher(spannable)
|
||||
|
||||
while (matcher.find()) {
|
||||
val start = matcher.start()
|
||||
val end = matcher.end()
|
||||
val clickableSpan = object : ClickableSpan() {
|
||||
override fun onClick(widget: View) {
|
||||
val url = spannable.subSequence(start, end).toString()
|
||||
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
|
||||
while (matcher.find()) {
|
||||
val start = matcher.start()
|
||||
val end = matcher.end()
|
||||
val clickableSpan = object : ClickableSpan() {
|
||||
override fun onClick(widget: View) {
|
||||
val url = spannable.subSequence(start, end).toString()
|
||||
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
|
||||
}
|
||||
}
|
||||
spannable.setSpan(clickableSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
spannable.setSpan(clickableSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
|
||||
textView.text = spannable
|
||||
textView.movementMethod = LinkMovementMethod.getInstance()
|
||||
textView.maxLines = Int.MAX_VALUE
|
||||
textView.ellipsize = null
|
||||
textView.linksClickable = true
|
||||
textView.movementMethod = LinkMovementMethod.getInstance()
|
||||
textView.text = spannable
|
||||
} else {
|
||||
val collapsedText = if (text.length > CONTENT_PREVIEW_MAX_LENGTH) {
|
||||
"${text.take(CONTENT_PREVIEW_MAX_LENGTH)}..."
|
||||
} else {
|
||||
text
|
||||
}
|
||||
|
||||
textView.maxLines = 3
|
||||
textView.ellipsize = TextUtils.TruncateAt.END
|
||||
textView.linksClickable = false
|
||||
textView.movementMethod = null
|
||||
textView.text = collapsedText
|
||||
}
|
||||
|
||||
textView.setOnClickListener {
|
||||
items[index] = items[index].copy(
|
||||
@@ -284,12 +305,6 @@ class CreatorCommunityAllAdapter(
|
||||
)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
textView.maxLines = if (isExpand) {
|
||||
Int.MAX_VALUE
|
||||
} else {
|
||||
3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_round_corner_5_3_222222"
|
||||
android:background="@drawable/bg_round_corner_16_263238"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="8dp"
|
||||
android:paddingVertical="11dp">
|
||||
@@ -34,9 +34,9 @@
|
||||
android:id="@+id/tv_nickname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/medium"
|
||||
android:fontFamily="@font/bold"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="13.3sp"
|
||||
android:textSize="18sp"
|
||||
tools:text="민하나" />
|
||||
|
||||
<TextView
|
||||
@@ -44,9 +44,9 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:fontFamily="@font/light"
|
||||
android:fontFamily="@font/regular"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="13.3sp"
|
||||
android:textSize="14sp"
|
||||
tools:text="3시간전" />
|
||||
</LinearLayout>
|
||||
|
||||
@@ -64,15 +64,15 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="13.3dp"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@font/medium"
|
||||
android:fontFamily="@font/regular"
|
||||
android:lineSpacingExtra="8dp"
|
||||
android:maxLines="3"
|
||||
android:textColor="@color/color_bbbbbb"
|
||||
android:textSize="13.3sp"
|
||||
android:textSize="18sp"
|
||||
android:visibility="gone"
|
||||
tools:text="너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user