Skip to content

Commit 54f1d92

Browse files
committed
Merge branch 'dev'
2 parents f1bf532 + 6f84157 commit 54f1d92

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

example/src/main/java/com/banner/example/MainActivity.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ package com.banner.example
22

33
import android.os.Bundle
44
import androidx.appcompat.app.AppCompatActivity
5+
import kotlinx.android.synthetic.main.activity_main.*
56

67
class MainActivity : AppCompatActivity() {
78

89
override fun onCreate(savedInstanceState: Bundle?) {
910
super.onCreate(savedInstanceState)
1011
setContentView(R.layout.activity_main)
12+
13+
tv_tester.text = "Hello World \n" +
14+
"Lwin\n" +
15+
"Aye"
1116
}
1217
}

example/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
tools:context=".MainActivity">
88

99
<com.banner.expander.ExpanderTextView
10+
android:id="@+id/tv_tester"
1011
android:layout_width="wrap_content"
1112
android:layout_height="wrap_content"
1213
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.!"

expander/src/main/java/com/banner/expander/ExpanderTextView.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,17 @@ class ExpanderTextView(context: Context, attributeSet: AttributeSet) :
6767
})
6868
}
6969

70+
// Start of a string = ^ ,
71+
// End of a string = $ ,
72+
// regex combination = | ,
73+
// Linebreak = \r\n|[\n\x0B\x0C\r\u0085\u2028\u2029]
74+
7075
override fun setText(text: CharSequence?, type: BufferType?) {
71-
this.originalText = text!!
76+
this.originalText = text?.replace(
77+
Regex("\n"),
78+
""
79+
) as CharSequence
80+
Log.d(TAG, "original text $originalText")
7281
this.bufferType = type!!
7382
setText()
7483
}
@@ -97,7 +106,7 @@ class ExpanderTextView(context: Context, attributeSet: AttributeSet) :
97106
private fun prepareTrimText(): CharSequence {
98107
if (lineIndexEnd != INVALID_LINE_INDEX) {
99108
val trimTextIndex = lineIndexEnd - (ELLIPSIZE.length + DEFAULT_CONTINUE_TEXT.length)
100-
109+
Log.d(TAG, "size is ${originalText.length} and text is $originalText")
101110
val trimText = SpannableStringBuilder(originalText, 0, trimTextIndex)
102111
.append(ELLIPSIZE)
103112
.append(DEFAULT_CONTINUE_TEXT)

0 commit comments

Comments
 (0)