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
b57ff402
Commit
b57ff402
authored
Feb 27, 2018
by
samer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed approach & removed repeated code
parent
045d7549
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
33 deletions
+25
-33
LoginFragment.kt
...t/rocket/android/authentication/login/ui/LoginFragment.kt
+25
-33
No files found.
app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt
View file @
b57ff402
...
...
@@ -31,18 +31,9 @@ class LoginFragment : Fragment(), LoginView {
@Inject
lateinit
var
appContext
:
Context
// TODO we really need it? Check alternatives...
private
val
layoutListener
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
if
(
KeyboardHelper
.
isSoftKeyboardShown
(
scroll_view
.
rootView
))
{
showSignUpView
(
false
)
showOauthView
(
false
)
showLoginButton
(
true
)
}
else
{
if
(
isEditTextEmpty
())
{
showSignUpView
(
true
)
showOauthView
(
true
)
showLoginButton
(
false
)
}
}
areLoginOptionsNeeded
()
}
private
var
isGlobalLayoutListenerSetUp
=
false
companion
object
{
...
...
@@ -77,18 +68,7 @@ class LoginFragment : Fragment(), LoginView {
override
fun
onViewStateRestored
(
savedInstanceState
:
Bundle
?)
{
super
.
onViewStateRestored
(
savedInstanceState
)
isSocialMediaNeeded
()
}
private
fun
showThreeSocialMethods
()
{
var
count
=
0
for
(
i
in
0
..
social_accounts_container
.
childCount
)
{
val
view
=
social_accounts_container
.
getChildAt
(
i
)
as
?
ImageButton
?:
continue
if
(
view
.
isEnabled
&&
count
<
3
)
{
view
.
visibility
=
View
.
VISIBLE
count
++
}
}
areLoginOptionsNeeded
()
}
override
fun
onDestroyView
()
{
...
...
@@ -185,6 +165,17 @@ class LoginFragment : Fragment(), LoginView {
override
fun
showNoInternetConnection
()
=
showMessage
(
getString
(
R
.
string
.
msg_no_internet_connection
))
private
fun
areLoginOptionsNeeded
()
{
if
(!
isEditTextEmpty
()
||
KeyboardHelper
.
isSoftKeyboardShown
(
scroll_view
.
rootView
))
{
showSignUpView
(
false
)
showOauthView
(
false
)
showLoginButton
(
true
)
}
else
{
showSignUpView
(
true
)
showOauthView
(
true
)
showLoginButton
(
false
)
}
}
private
fun
tintEditTextDrawableStart
()
{
activity
?.
apply
{
...
...
@@ -224,16 +215,6 @@ class LoginFragment : Fragment(), LoginView {
// Returns true if *all* EditTexts are empty.
private
fun
isEditTextEmpty
():
Boolean
=
text_username_or_email
.
textContent
.
isBlank
()
&&
text_password
.
textContent
.
isEmpty
()
private
fun
isSocialMediaNeeded
()
{
if
(!
isEditTextEmpty
())
{
showSignUpView
(
false
)
showOauthView
(
false
)
}
else
{
showSignUpView
(
true
)
showOauthView
(
true
)
}
}
private
fun
showRemainingSocialAccountsView
()
{
social_accounts_container
.
postDelayed
({
for
(
i
in
0
..
social_accounts_container
.
childCount
)
{
...
...
@@ -243,6 +224,17 @@ class LoginFragment : Fragment(), LoginView {
},
1000
)
}
private
fun
showThreeSocialMethods
()
{
var
count
=
0
for
(
i
in
0
..
social_accounts_container
.
childCount
)
{
val
view
=
social_accounts_container
.
getChildAt
(
i
)
as
?
ImageButton
?:
continue
if
(
view
.
isEnabled
&&
count
<
3
)
{
view
.
visibility
=
View
.
VISIBLE
count
++
}
}
}
private
fun
scrollToBottom
()
{
scroll_view
.
postDelayed
({
scroll_view
.
fullScroll
(
ScrollView
.
FOCUS_DOWN
)
...
...
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