Skip to content

Commit

Permalink
[#139] fix : 바텀시트 대본 미리보기 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
serioushyeon committed Oct 30, 2024
1 parent fabef01 commit 01a2a42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LoadScriptBottomSheetAdapter(
val item = items[actualPosition]

holder.title.text = item.title
holder.content.text = item.content
holder.content.text = getFirst20CharsIgnoringSpaces(item.content)
holder.timeStamp.text = item.timeStamp
holder.tagNote.visibility = View.VISIBLE

Expand All @@ -66,6 +66,22 @@ class LoadScriptBottomSheetAdapter(
listener.onItemClicked(position - 1)
}

//공백을 세지 않고 20자로 제한하는 함수
fun getFirst20CharsIgnoringSpaces(input: String): String {
val result = StringBuilder()
var count = 0

for (char in input) {
if (!char.isWhitespace()) {
count++
}
result.append(char)
if (count == 20) break
}

return result.toString()
}

override fun getItemCount(): Int = items.size + 1

override fun getItemViewType(position: Int): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class LoadScriptBottomSheetFragment : BottomSheetDialogFragment(), BottomSheetLi
val items = mutableListOf<BottomSheetData>()

for (i in it.indices) {
items.add(BottomSheetData(it[i].title))
items.add(BottomSheetData(it[i].title, it[1].content))
scriptId.add(it[i].id)
}

Expand Down

0 comments on commit 01a2a42

Please sign in to comment.