Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of #140: Topic play animation #486

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Minor bug fixes
  • Loading branch information
Rajat Talesra committed Nov 28, 2019
commit 9d560a28f4609e59270b5367ef0404eddadd44bb
25 changes: 12 additions & 13 deletions app/src/main/java/org/oppia/app/topic/play/StorySummaryAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.ViewGroup
import android.view.animation.Animation
import android.view.animation.Transformation
import android.widget.LinearLayout
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import org.oppia.app.databinding.TopicPlayStorySummaryBinding
import org.oppia.app.databinding.TopicPlayTitleBinding
Expand Down Expand Up @@ -91,7 +92,7 @@ class StorySummaryAdapter(
inner class StorySummaryViewHolder(private val binding: TopicPlayStorySummaryBinding) :
RecyclerView.ViewHolder(binding.root) {
internal fun bind(storySummaryViewModel: StorySummaryViewModel, position: Int) {
if (currentExpandedChapterListIndex != null && currentExpandedChapterListIndex==position) {
if (currentExpandedChapterListIndex != null && currentExpandedChapterListIndex == position) {
binding.isListExpanded = true

if (currentExpandedChapterListIndex == position) {
Expand All @@ -101,8 +102,7 @@ class StorySummaryAdapter(
binding.chapterListDropDownIcon.animate().rotation(0F).setDuration(400).start()
collapse(binding.chapterListContainer)
}
}
else {
} else {
binding.isListExpanded = false
}
binding.viewModel = storySummaryViewModel
Expand All @@ -125,23 +125,22 @@ class StorySummaryAdapter(
binding.chapterRecyclerView.adapter = ChapterSummaryAdapter(chapterList, chapterSummarySelector)

binding.root.setOnClickListener {
currentExpandedChapterListIndex =
if (currentExpandedChapterListIndex != null && currentExpandedChapterListIndex == position) {
null
} else {
position
}
expandedChapterListIndexListener.onExpandListIconClicked(currentExpandedChapterListIndex)

binding.isListExpanded = currentExpandedChapterListIndex == position
binding.isListExpanded = !binding.chapterListContainer.isVisible

if (currentExpandedChapterListIndex == position) {
if (!binding.chapterListContainer.isVisible) {
binding.chapterListDropDownIcon.animate().rotation(180F).setDuration(400).start()
expand(binding.chapterListContainer)
} else {
binding.chapterListDropDownIcon.animate().rotation(0F).setDuration(400).start()
collapse(binding.chapterListContainer)
}

if (binding.chapterListContainer.isVisible) {
currentExpandedChapterListIndex = position
} else {
currentExpandedChapterListIndex = null
}
expandedChapterListIndexListener.onExpandListIconClicked(currentExpandedChapterListIndex)
}
}

Expand Down