Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
2625c52c
Unverified
Commit
2625c52c
authored
Apr 03, 2019
by
Hussein El Feky
Committed by
GitHub
Apr 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added animation when expanding/collapsing login options
parent
acb0f6f3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
165 additions
and
96 deletions
+165
-96
LoginOptionsFragment.kt
...id/authentication/loginoptions/ui/LoginOptionsFragment.kt
+165
-96
No files found.
app/src/main/java/chat/rocket/android/authentication/loginoptions/ui/LoginOptionsFragment.kt
View file @
2625c52c
package
chat.rocket.android.authentication.loginoptions.ui
package
chat.rocket.android.authentication.loginoptions.ui
import
android.animation.Animator
import
android.animation.AnimatorListenerAdapter
import
android.animation.ValueAnimator
import
android.app.Activity
import
android.app.Activity
import
android.content.Intent
import
android.content.Intent
import
android.graphics.PorterDuff
import
android.graphics.PorterDuff
...
@@ -7,10 +10,13 @@ import android.os.Bundle
...
@@ -7,10 +10,13 @@ import android.os.Bundle
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.view.animation.AlphaAnimation
import
android.view.animation.Animation
import
android.widget.Button
import
android.widget.Button
import
android.widget.LinearLayout
import
android.widget.LinearLayout
import
androidx.appcompat.view.ContextThemeWrapper
import
androidx.appcompat.view.ContextThemeWrapper
import
androidx.core.view.isVisible
import
androidx.core.view.isVisible
import
androidx.core.view.marginTop
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.analytics.AnalyticsManager
import
chat.rocket.android.analytics.AnalyticsManager
...
@@ -532,17 +538,80 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
...
@@ -532,17 +538,80 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
}
}
private
fun
expandAccountsView
()
{
private
fun
expandAccountsView
()
{
(
0
..
accounts_container
.
childCount
)
val
collapsedHeight
=
accounts_container
.
height
.
mapNotNull
{
accounts_container
.
getChildAt
(
it
)
as
?
Button
}
var
expandedHeight
=
collapsedHeight
.
filter
{
it
.
isClickable
&&
!
it
.
isVisible
}
val
optionHeight
=
accounts_container
.
getChildAt
(
1
).
height
+
.
forEach
{
it
.
isVisible
=
true
}
accounts_container
.
getChildAt
(
1
).
marginTop
for
(
i
in
0
until
accounts_container
.
childCount
)
{
val
bt
=
accounts_container
.
getChildAt
(
i
)
as
Button
if
(
bt
.
isClickable
&&
!
bt
.
isVisible
)
{
expandedHeight
+=
optionHeight
}
}
val
animation
=
ValueAnimator
.
ofInt
(
collapsedHeight
,
expandedHeight
)
animation
.
addUpdateListener
{
val
params
=
accounts_container
.
layoutParams
params
.
height
=
animation
.
animatedValue
as
Int
accounts_container
.
layoutParams
=
params
}
animation
.
addListener
(
object
:
AnimatorListenerAdapter
()
{
override
fun
onAnimationStart
(
animator
:
Animator
)
{
for
(
i
in
0
until
accounts_container
.
childCount
)
{
val
bt
=
accounts_container
.
getChildAt
(
i
)
as
Button
if
(!
bt
.
isVisible
)
{
bt
.
isVisible
=
true
val
anim
=
AlphaAnimation
(
0.0f
,
1.0f
)
anim
.
duration
=
400
bt
.
startAnimation
(
anim
)
}
}
}
})
animation
.
setDuration
(
400
).
start
()
}
}
private
fun
collapseAccountsView
()
{
private
fun
collapseAccountsView
()
{
(
0
..
accounts_container
.
childCount
)
val
expandedHeight
=
accounts_container
.
height
.
mapNotNull
{
accounts_container
.
getChildAt
(
it
)
as
?
Button
}
var
collapsedHeight
=
expandedHeight
.
filter
{
it
.
isClickable
&&
it
.
isVisible
}
val
optionHeight
=
accounts_container
.
getChildAt
(
1
).
height
+
.
drop
(
3
)
accounts_container
.
getChildAt
(
1
).
marginTop
.
forEach
{
it
.
isVisible
=
false
}
for
(
i
in
3
until
accounts_container
.
childCount
)
{
val
bt
=
accounts_container
.
getChildAt
(
i
)
as
Button
if
(
bt
.
isClickable
&&
bt
.
isVisible
)
{
collapsedHeight
-=
optionHeight
}
}
val
animation
=
ValueAnimator
.
ofInt
(
expandedHeight
,
collapsedHeight
)
animation
.
addUpdateListener
{
val
params
=
accounts_container
.
layoutParams
params
.
height
=
animation
.
animatedValue
as
Int
accounts_container
.
layoutParams
=
params
}
animation
.
addListener
(
object
:
AnimatorListenerAdapter
()
{
override
fun
onAnimationStart
(
animator
:
Animator
)
{
for
(
i
in
3
until
accounts_container
.
childCount
)
{
val
bt
=
accounts_container
.
getChildAt
(
i
)
as
Button
if
(
bt
.
isVisible
)
{
val
anim
=
AlphaAnimation
(
1.0f
,
0.0f
)
anim
.
duration
=
400
anim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
override
fun
onAnimationStart
(
animation
:
Animation
)
{
}
override
fun
onAnimationEnd
(
animation
:
Animation
)
{
bt
.
isVisible
=
false
}
override
fun
onAnimationRepeat
(
animation
:
Animation
)
{
}
})
bt
.
startAnimation
(
anim
)
}
}
}
})
animation
.
setDuration
(
400
).
start
()
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment