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

Fixes part of #1159 & #1161: Topic-Lessons high-fi animation #1465

Merged
merged 12 commits into from
Jul 28, 2020
Merged
Prev Previous commit
Next Next commit
-generalized the arrow animation
  • Loading branch information
MohamedMedhat1998 committed Jul 28, 2020
commit c657f7782faaca584b1b84b387ddca9a08c4d0a1
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,3 @@ fun setProfileImage(imageView: ImageView, profileAvatar: ProfileAvatar?) {
.into(imageView)
}
}

@BindingAdapter("app:expand_rotation_anim")
fun setExpandRotationAnimation(imageView: ImageView, isExpanded: Boolean) {
if (isExpanded) {
val valueAnimator = ValueAnimator.ofFloat(0f, 180f)
valueAnimator.duration = 300
valueAnimator.addUpdateListener {
imageView.rotation = it.animatedValue as Float
}
valueAnimator.start()
} else {
val valueAnimator = ValueAnimator.ofFloat(180f, 0f)
valueAnimator.duration = 300
valueAnimator.addUpdateListener {
imageView.rotation = it.animatedValue as Float
}
valueAnimator.start()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,29 @@ fun setFlashingAnimation(view: View, isFlashing: Boolean) {
view.alpha = 0f
}
}

@BindingAdapter(
"app:hasRotationAnimation",
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
"app:isRotationClockwise",
"app:rotationAngle",
requireAll = true
)
fun setRotationAnimation(view: View, hasAnimation: Boolean, isClockwise: Boolean, angle: Float) {
if (hasAnimation) {
if (isClockwise) {
val valueAnimator = ValueAnimator.ofFloat(0f, angle)
valueAnimator.duration = 300
valueAnimator.addUpdateListener {
view.rotation = it.animatedValue as Float
}
valueAnimator.start()
} else {
val valueAnimator = ValueAnimator.ofFloat(angle, 0f)
valueAnimator.duration = 300
valueAnimator.addUpdateListener {
view.rotation = it.animatedValue as Float
}
valueAnimator.start()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class TopicLessonsFragmentPresenter @Inject constructor(
)
binding.storySummaryRecyclerView.apply {
adapter = storySummaryAdapter
(itemAnimator as SimpleItemAnimator).changeDuration = 0
}
if (storyId.isNotEmpty())
binding.storySummaryRecyclerView.layoutManager!!.scrollToPosition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@
android:layout_gravity="center_horizontal|bottom"
android:contentDescription="@{@string/show_hide_chapter_list(viewModel.storySummary.storyName)}"
android:src="@drawable/ic_arrow_drop_down_black_24dp"
app:expand_rotation_anim="@{isListExpanded}" />
app:hasRotationAnimation="@{true}"
app:rotationAngle="@{180f}"
app:isRotationClockwise="@{isListExpanded}" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@
android:layout_gravity="center_horizontal|bottom"
android:contentDescription="@{@string/show_hide_chapter_list(viewModel.storySummary.storyName)}"
android:src="@drawable/ic_arrow_drop_down_black_24dp"
app:expand_rotation_anim="@{isListExpanded}" />
app:hasRotationAnimation="@{true}"
app:rotationAngle="@{180f}"
app:isRotationClockwise="@{isListExpanded}" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@
android:layout_gravity="center_horizontal|bottom"
android:contentDescription="@{@string/show_hide_chapter_list(viewModel.storySummary.storyName)}"
android:src="@drawable/ic_arrow_drop_down_black_24dp"
app:expand_rotation_anim="@{isListExpanded}" />
app:hasRotationAnimation="@{true}"
app:rotationAngle="@{180f}"
app:isRotationClockwise="@{isListExpanded}" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/topic_lessons_story_summary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@
android:layout_gravity="center_horizontal|bottom"
android:contentDescription="@{@string/show_hide_chapter_list(viewModel.storySummary.storyName)}"
android:src="@drawable/ic_arrow_drop_down_black_24dp"
app:expand_rotation_anim="@{isListExpanded}" />
app:hasRotationAnimation="@{true}"
app:rotationAngle="@{180f}"
app:isRotationClockwise="@{isListExpanded}" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
Expand Down