Created
March 26, 2020 19:58
-
-
Save cbedoy/c5336d4ebcc12f063d5c8ecfc8c3b2e8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| fun TextView.setCollapseExpand(collapsibleView: View, onCollapse: () -> Unit, onExpand: () -> Unit) { | |
| setCompoundDrawablesWithIntrinsicBounds(null, null, DrawableConstants.ic_expand_section.createDrawable(), null) | |
| setOnClickListener { | |
| when (collapsibleView.visibility) { | |
| View.GONE -> { | |
| collapsibleView.visibility = View.VISIBLE | |
| setCompoundDrawablesWithIntrinsicBounds(null, null, DrawableConstants.ic_collapse_section.createDrawable(), null) | |
| onExpand() | |
| } | |
| View.VISIBLE -> { | |
| collapsibleView.visibility = View.GONE | |
| setCompoundDrawablesWithIntrinsicBounds(null, null, DrawableConstants.ic_expand_section.createDrawable(), null) | |
| onCollapse() | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment