Skip to content

Commit 5edbc55

Browse files
anhanh11001iamareebjamal
authored andcommitted
feat: Add expand/collapse animation for View/TextView (#2186)
Details: - Use external libraries for expandable text view and view container Fixes: #2182
1 parent 1bb6679 commit 5edbc55

File tree

7 files changed

+155
-150
lines changed

7 files changed

+155
-150
lines changed

app/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ dependencies {
224224
// Searchable Spinner
225225
implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
226226

227+
//ExpandableTextView
228+
implementation 'at.blogc:expandabletextview:1.0.5'
229+
230+
//ExpandableView
231+
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
232+
233+
227234

228235
testImplementation 'junit:junit:4.12'
229236
testImplementation 'org.threeten:threetenbp:1.4.0'

app/src/main/java/org/fossasia/openevent/general/event/EventDetailsFragment.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,9 @@ class EventDetailsFragment : Fragment() {
415415
// Organizer Section
416416
if (!event.ownerName.isNullOrEmpty()) {
417417
val organizerDescriptionListener = View.OnClickListener {
418-
if (rootView.seeMoreOrganizer.text == getString(R.string.see_more)) {
419-
rootView.seeMoreOrganizer.text = getString(R.string.see_less)
420-
rootView.eventOrganiserDescription.minLines = 0
421-
rootView.eventOrganiserDescription.maxLines = Int.MAX_VALUE
422-
} else {
423-
rootView.seeMoreOrganizer.text = getString(R.string.see_more)
424-
rootView.eventOrganiserDescription.setLines(3)
425-
}
418+
rootView.eventOrganiserDescription.toggle()
419+
rootView.seeMoreOrganizer.text = if (rootView.eventOrganiserDescription.isExpanded)
420+
getString(R.string.see_less) else getString(R.string.see_more)
426421
}
427422

428423
rootView.eventOrganiserDescription.post {

app/src/main/java/org/fossasia/openevent/general/sessions/SessionFragment.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,9 @@ class SessionFragment : Fragment() {
231231
false -> {
232232
rootView.sessionDetailAbstract.text = description.stripHtml()
233233
val sessionAbstractClickListener = View.OnClickListener {
234-
if (rootView.sessionDetailAbstractSeeMore.text == getString(R.string.see_more)) {
235-
rootView.sessionDetailAbstractSeeMore.text = getString(R.string.see_less)
236-
rootView.sessionDetailAbstract.minLines = 0
237-
rootView.sessionDetailAbstract.maxLines = Int.MAX_VALUE
238-
} else {
239-
rootView.sessionDetailAbstractSeeMore.text = getString(R.string.see_more)
240-
rootView.sessionDetailAbstract.setLines(LINE_COUNT_ABSTRACT + 1)
241-
}
234+
rootView.sessionDetailAbstract.toggle()
235+
rootView.sessionDetailAbstractSeeMore.text = if (rootView.sessionDetailAbstract.isExpanded)
236+
getString(R.string.see_less) else getString(R.string.see_more)
242237
}
243238

244239
rootView.sessionDetailAbstract.post {

app/src/main/java/org/fossasia/openevent/general/speakercall/SpeakersCallProposalFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class SpeakersCallProposalFragment : Fragment(), ComplexBackPressFragment {
138138
.observe(viewLifecycleOwner, Observer {
139139
rootView.speakerProgressBar.isVisible = it
140140
})
141-
rootView.speakerInfoContainer.isVisible = speakersCallProposalViewModel.isSpeakerInfoShown
141+
rootView.speakerInfoContainer.isExpanded = speakersCallProposalViewModel.isSpeakerInfoShown
142142

143143
rootView.titleLayout.setRequired()
144144
setupTrack()
@@ -159,7 +159,7 @@ class SpeakersCallProposalFragment : Fragment(), ComplexBackPressFragment {
159159

160160
rootView.expandSpeakerDetailButton.setOnClickListener {
161161
speakersCallProposalViewModel.isSpeakerInfoShown = !speakersCallProposalViewModel.isSpeakerInfoShown
162-
rootView.speakerInfoContainer.isVisible = speakersCallProposalViewModel.isSpeakerInfoShown
162+
rootView.speakerInfoContainer.toggle()
163163
}
164164

165165
rootView.submitProposalButton.setOnClickListener {

app/src/main/res/layout/content_event.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,16 +433,18 @@
433433
android:textColor="@color/light_grey"
434434
android:textSize="@dimen/event_details_headers" />
435435

436-
<TextView
436+
<at.blogc.android.views.ExpandableTextView
437437
android:id="@+id/eventOrganiserDescription"
438438
android:layout_width="match_parent"
439439
android:layout_height="wrap_content"
440440
app:strippedHtml="@{event.ownerDescription}"
441441
app:hideIfEmpty="@{event.ownerDescription}"
442442
android:layout_marginBottom="@dimen/layout_margin_small"
443+
android:background="?selectableItemBackground"
443444
android:ellipsize="end"
444445
android:lines="3"
445446
android:textColor="@color/light_grey"
447+
app:animation_duration="300"
446448
tools:text="Description" />
447449

448450
<TextView

app/src/main/res/layout/fragment_session.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,14 @@
164164
android:textColor="@color/dark_grey"
165165
android:textSize="@dimen/event_details_headers"
166166
android:layout_marginBottom="@dimen/layout_margin_medium"/>
167-
<TextView
167+
<at.blogc.android.views.ExpandableTextView
168168
android:id="@+id/sessionDetailAbstract"
169169
android:layout_width="match_parent"
170170
android:layout_height="wrap_content"
171171
android:ellipsize="end"
172172
android:lines="4"
173173
android:autoLink="web|email|phone"
174+
android:background="?selectableItemBackground"
174175
tools:text="@string/description_preview"/>
175176
<TextView
176177
android:id="@+id/sessionDetailAbstractSeeMore"

0 commit comments

Comments
 (0)