.....
This commit is contained in:
parent
9f6c424e04
commit
cfe4686cef
@ -573,13 +573,14 @@ class TokiFragment : Fragment(), PagedTextViewInterface {
|
|||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
|
val nullCursor = PointerIcon.getSystemIcon(requireContext(), PointerIcon.TYPE_NULL)
|
||||||
|
binding.root.setPointerIcon(nullCursor)
|
||||||
|
loadLastInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
val nullCursor = PointerIcon.getSystemIcon(requireContext(), PointerIcon.TYPE_NULL)
|
|
||||||
binding.root.setPointerIcon(nullCursor)
|
|
||||||
loadLastInfo()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLastinfo() : LastInfo? {
|
fun getLastinfo() : LastInfo? {
|
||||||
|
|||||||
@ -79,8 +79,8 @@ class PagedTextLayout : ConstraintLayout , PagedTextGenerateInterface {
|
|||||||
mainTextView!!.width - (mainTextView!!.paddingLeft + mainTextView!!.paddingRight)
|
mainTextView!!.width - (mainTextView!!.paddingLeft + mainTextView!!.paddingRight)
|
||||||
val contentHeight =
|
val contentHeight =
|
||||||
mainTextView!!.height - (mainTextView!!.paddingTop + mainTextView!!.paddingBottom)
|
mainTextView!!.height - (mainTextView!!.paddingTop + mainTextView!!.paddingBottom)
|
||||||
val pages = paginateAsync(text, contentWidth, contentHeight)
|
val pages = paginateAsync(cleanText(text), contentWidth, contentHeight)
|
||||||
pageList.addAll(pages)
|
pageList.addAll(pages.map { it.trim() })
|
||||||
Blog.LOGE("pages >>> ${pages.size}")
|
Blog.LOGE("pages >>> ${pages.size}")
|
||||||
setPageBy(0)
|
setPageBy(0)
|
||||||
}
|
}
|
||||||
@ -90,6 +90,17 @@ class PagedTextLayout : ConstraintLayout , PagedTextGenerateInterface {
|
|||||||
}
|
}
|
||||||
summaryText = summary
|
summaryText = summary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun cleanText(text: String): String {
|
||||||
|
return text
|
||||||
|
// 1. 전체 텍스트의 앞/뒤 공백 제거
|
||||||
|
.trim()
|
||||||
|
// 2. 중간에 포함된 '빈 줄' 제거
|
||||||
|
// (\n\s*)+\n : 줄바꿈(\n) 뒤에 공백(\s*)이 오고 다시 줄바꿈이 반복되는 패턴을 찾습니다.
|
||||||
|
// 이것을 단일 줄바꿈(\n)으로 교체하여 빈 라인을 없애고 문단만 나눕니다.
|
||||||
|
.replace(Regex("(\\n\\n\\s*)+\\n"), "\n")
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun paginateAsync(text: CharSequence, width: Int, height: Int): List<CharSequence> = withContext(Dispatchers.Default) {
|
suspend fun paginateAsync(text: CharSequence, width: Int, height: Int): List<CharSequence> = withContext(Dispatchers.Default) {
|
||||||
val resultPages = ArrayList<CharSequence>()
|
val resultPages = ArrayList<CharSequence>()
|
||||||
val paint = mainTextView?.paint ?: TextPaint()
|
val paint = mainTextView?.paint ?: TextPaint()
|
||||||
@ -98,6 +109,7 @@ class PagedTextLayout : ConstraintLayout , PagedTextGenerateInterface {
|
|||||||
val letterSpacing = mainTextView?.letterSpacing ?: 1.0f
|
val letterSpacing = mainTextView?.letterSpacing ?: 1.0f
|
||||||
val includePad = false
|
val includePad = false
|
||||||
Blog.LOGE("text ${text.length}, width $width, height $height")
|
Blog.LOGE("text ${text.length}, width $width, height $height")
|
||||||
|
|
||||||
// 1. 전체 텍스트에 대한 StaticLayout 생성 (API 버전에 따른 분기 처리 권장)
|
// 1. 전체 텍스트에 대한 StaticLayout 생성 (API 버전에 따른 분기 처리 권장)
|
||||||
val layout = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
val layout = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
StaticLayout.Builder.obtain(text, 0, text.length, paint, width)
|
StaticLayout.Builder.obtain(text, 0, text.length, paint, width)
|
||||||
|
|||||||
@ -3,11 +3,9 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_margin="5dp"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_margin="5dp"
|
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user