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
c8fe7a88
Commit
c8fe7a88
authored
Dec 20, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update ServerFragment.kt
parent
d40c727a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
16 deletions
+39
-16
ServerFragment.kt
...rocket/android/authentication/server/ui/ServerFragment.kt
+39
-16
No files found.
app/src/main/java/chat/rocket/android/authentication/server/ui/ServerFragment.kt
View file @
c8fe7a88
...
@@ -5,44 +5,67 @@ import android.support.v4.app.Fragment
...
@@ -5,44 +5,67 @@ import android.support.v4.app.Fragment
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.WindowManager
import
android.view.ViewTreeObserver
import
android.widget.Toast
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.authentication.server.presentation.ServerPresenter
import
chat.rocket.android.authentication.server.presentation.ServerPresenter
import
chat.rocket.android.authentication.server.presentation.ServerView
import
chat.rocket.android.authentication.server.presentation.ServerView
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.util.hintContent
import
chat.rocket.android.util.ifEmpty
import
chat.rocket.android.util.ifEmpty
import
chat.rocket.android.util.setVisibility
import
chat.rocket.android.util.textContent
import
dagger.android.support.AndroidSupportInjection
import
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.fragment_authentication_server.*
import
kotlinx.android.synthetic.main.fragment_authentication_server.*
import
javax.inject.Inject
import
javax.inject.Inject
class
ServerFragment
:
Fragment
(),
ServerView
{
class
ServerFragment
:
Fragment
(),
ServerView
{
@Inject
lateinit
var
presenter
:
ServerPresenter
private
val
layoutListener
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
text_server_url
.
isCursorVisible
=
KeyboardHelper
.
isSoftKeyboardShown
(
relative_layout
.
rootView
)
}
@Inject
companion
object
{
lateinit
var
presenter
:
ServerPresenter
fun
newInstance
()
=
ServerFragment
()
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
}
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
=
inflater
.
inflate
(
R
.
layout
.
fragment_authentication_server
,
container
,
false
)
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
=
inflater
.
inflate
(
R
.
layout
.
fragment_authentication_server
,
container
,
false
)
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
super
.
onViewCreated
(
view
,
savedInstanceState
)
relative_layout
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
layoutListener
)
activity
?.
applicationContext
?.
apply
{
button_connect
.
setOnClickListener
{
val
url
=
text_server_url
.
textContent
.
ifEmpty
(
text_server_url
.
hintContent
)
presenter
.
login
(
this
,
text_server_protocol
.
textContent
+
url
)
}
}
}
text_server_url
.
setSelection
(
text_server_url
.
length
())
override
fun
onDestroyView
()
{
super
.
onDestroyView
()
relative_layout
.
viewTreeObserver
.
removeOnGlobalLayoutListener
(
layoutListener
)
}
activity
?.
window
?.
setSoftInputMode
(
WindowManager
.
LayoutParams
.
SOFT_INPUT_STATE_VISIBLE
)
override
fun
showLoading
()
{
text_server_url
.
isEnabled
=
false
button_connect
.
isEnabled
=
false
view_loading
.
setVisibility
(
true
)
}
button_connect
.
setOnClickListener
{
override
fun
hideLoading
()
{
val
url
=
text_server_url
.
text
.
toString
().
ifEmpty
(
text_server_url
.
hint
.
toString
()
)
view_loading
.
setVisibility
(
false
)
presenter
.
login
(
server_protocol_label
.
text
.
toString
()
+
url
)
button_connect
.
isEnabled
=
true
}
text_server_url
.
isEnabled
=
true
}
}
companion
object
{
override
fun
showMessage
(
message
:
String
)
{
fun
newInstance
()
=
ServerFragment
()
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_LONG
).
show
()
}
}
}
}
\ No newline at end of file
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