-
-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5128 from Bnyro/master
refactor: create a custom view for expendable text views
- Loading branch information
Showing
5 changed files
with
29 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/github/libretube/ui/views/ExpandableTextView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.github.libretube.ui.views | ||
|
||
import android.content.Context | ||
import android.text.TextUtils | ||
import android.util.AttributeSet | ||
import androidx.appcompat.widget.AppCompatTextView | ||
import com.github.libretube.R | ||
|
||
class ExpandableTextView(context: Context, attributeSet: AttributeSet? = null) : | ||
AppCompatTextView(context, attributeSet) { | ||
|
||
init { | ||
maxLines = DEFAULT_MAX_LINES | ||
ellipsize = TextUtils.TruncateAt.END | ||
setBackgroundResource(R.drawable.rounded_ripple) | ||
|
||
setOnClickListener { | ||
maxLines = if (maxLines == DEFAULT_MAX_LINES) Int.MAX_VALUE else DEFAULT_MAX_LINES | ||
} | ||
} | ||
|
||
companion object { | ||
private const val DEFAULT_MAX_LINES = 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters