Commit 264b6a2e authored by Hussein El Feky's avatar Hussein El Feky

Fixed incorrect login options showing up

parent 22a68f39
...@@ -537,16 +537,13 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView { ...@@ -537,16 +537,13 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
} }
private fun expandAccountsView() { private fun expandAccountsView() {
val collapsedHeight = accounts_container.height val buttons = (0..accounts_container.childCount)
var expandedHeight = collapsedHeight .mapNotNull { accounts_container.getChildAt(it) as? Button }
.filter { it.isClickable && !it.isVisible }
val optionHeight = accounts_container.getChildAt(1).height + val optionHeight = accounts_container.getChildAt(1).height +
accounts_container.getChildAt(1).marginTop accounts_container.getChildAt(1).marginTop
for (i in 0 until accounts_container.childCount) { val collapsedHeight = accounts_container.height
val bt = accounts_container.getChildAt(i) as Button val expandedHeight = collapsedHeight + optionHeight * buttons.size
if (bt.isClickable && !bt.isVisible) {
expandedHeight += optionHeight
}
}
val animation = ValueAnimator.ofInt(collapsedHeight, expandedHeight) val animation = ValueAnimator.ofInt(collapsedHeight, expandedHeight)
animation.addUpdateListener { animation.addUpdateListener {
val params = accounts_container.layoutParams val params = accounts_container.layoutParams
...@@ -555,14 +552,11 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView { ...@@ -555,14 +552,11 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
} }
animation.addListener(object : AnimatorListenerAdapter() { animation.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(animator: Animator) { override fun onAnimationStart(animator: Animator) {
for (i in 0 until accounts_container.childCount) { buttons.forEach {
val bt = accounts_container.getChildAt(i) as Button it.isVisible = true
if (!bt.isVisible) { val anim = AlphaAnimation(0.0f, 1.0f)
bt.isVisible = true anim.duration = 400
val anim = AlphaAnimation(0.0f, 1.0f) it.startAnimation(anim)
anim.duration = 400
bt.startAnimation(anim)
}
} }
} }
}) })
...@@ -570,16 +564,14 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView { ...@@ -570,16 +564,14 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
} }
private fun collapseAccountsView() { private fun collapseAccountsView() {
val expandedHeight = accounts_container.height val buttons = (0..accounts_container.childCount)
var collapsedHeight = expandedHeight .mapNotNull { accounts_container.getChildAt(it) as? Button }
.filter { it.isClickable && it.isVisible }
.drop(3)
val optionHeight = accounts_container.getChildAt(1).height + val optionHeight = accounts_container.getChildAt(1).height +
accounts_container.getChildAt(1).marginTop accounts_container.getChildAt(1).marginTop
for (i in 3 until accounts_container.childCount) { val expandedHeight = accounts_container.height
val bt = accounts_container.getChildAt(i) as Button val collapsedHeight = expandedHeight - optionHeight * buttons.size
if (bt.isClickable && bt.isVisible) {
collapsedHeight -= optionHeight
}
}
val animation = ValueAnimator.ofInt(expandedHeight, collapsedHeight) val animation = ValueAnimator.ofInt(expandedHeight, collapsedHeight)
animation.addUpdateListener { animation.addUpdateListener {
val params = accounts_container.layoutParams val params = accounts_container.layoutParams
...@@ -588,26 +580,23 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView { ...@@ -588,26 +580,23 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
} }
animation.addListener(object : AnimatorListenerAdapter() { animation.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(animator: Animator) { override fun onAnimationStart(animator: Animator) {
for (i in 3 until accounts_container.childCount) { buttons.forEach {
val bt = accounts_container.getChildAt(i) as Button val anim = AlphaAnimation(1.0f, 0.0f)
if (bt.isVisible) { anim.duration = 400
val anim = AlphaAnimation(1.0f, 0.0f) anim.setAnimationListener(object : Animation.AnimationListener {
anim.duration = 400 override fun onAnimationStart(animation: Animation) {
anim.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) { }
} override fun onAnimationEnd(animation: Animation) {
it.isVisible = false
override fun onAnimationEnd(animation: Animation) { }
bt.isVisible = false
} override fun onAnimationRepeat(animation: Animation) {
override fun onAnimationRepeat(animation: Animation) { }
})
} it.startAnimation(anim)
})
bt.startAnimation(anim)
}
} }
} }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment