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
546b6b5c
Commit
546b6b5c
authored
Aug 11, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update InputHostnamePresenter.java
parent
b7b1d123
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
16 deletions
+9
-16
InputHostnamePresenter.java
...t/android/fragment/add_server/InputHostnamePresenter.java
+9
-16
No files found.
app/src/main/java/chat/rocket/android/fragment/add_server/InputHostnamePresenter.java
View file @
546b6b5c
package
chat
.
rocket
.
android
.
fragment
.
add_server
;
package
chat
.
rocket
.
android
.
fragment
.
add_server
;
import
chat.rocket.android.BackgroundLooper
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.schedulers.Schedulers
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.rest.DefaultServerPolicyApi
;
import
chat.rocket.android.api.rest.DefaultServerPolicyApi
;
...
@@ -13,14 +13,11 @@ import chat.rocket.android.helper.ServerPolicyHelper;
...
@@ -13,14 +13,11 @@ import chat.rocket.android.helper.ServerPolicyHelper;
import
chat.rocket.android.service.ConnectivityManagerApi
;
import
chat.rocket.android.service.ConnectivityManagerApi
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.android.shared.BasePresenter
;
public
class
InputHostnamePresenter
extends
BasePresenter
<
InputHostnameContract
.
View
>
public
class
InputHostnamePresenter
extends
BasePresenter
<
InputHostnameContract
.
View
>
implements
InputHostnameContract
.
Presenter
{
implements
InputHostnameContract
.
Presenter
{
private
final
RocketChatCache
rocketChatCache
;
private
final
RocketChatCache
rocketChatCache
;
private
final
ConnectivityManagerApi
connectivityManager
;
private
final
ConnectivityManagerApi
connectivityManager
;
public
InputHostnamePresenter
(
RocketChatCache
rocketChatCache
,
public
InputHostnamePresenter
(
RocketChatCache
rocketChatCache
,
ConnectivityManagerApi
connectivityManager
)
{
ConnectivityManagerApi
connectivityManager
)
{
this
.
rocketChatCache
=
rocketChatCache
;
this
.
rocketChatCache
=
rocketChatCache
;
this
.
connectivityManager
=
connectivityManager
;
this
.
connectivityManager
=
connectivityManager
;
}
}
...
@@ -28,21 +25,17 @@ public class InputHostnamePresenter extends BasePresenter<InputHostnameContract.
...
@@ -28,21 +25,17 @@ public class InputHostnamePresenter extends BasePresenter<InputHostnameContract.
@Override
@Override
public
void
connectTo
(
final
String
hostname
)
{
public
void
connectTo
(
final
String
hostname
)
{
view
.
showLoader
();
view
.
showLoader
();
connectToEnforced
(
ServerPolicyHelper
.
enforceHostname
(
hostname
));
connectToEnforced
(
ServerPolicyHelper
.
enforceHostname
(
hostname
));
}
}
public
void
connectToEnforced
(
final
String
hostname
)
{
public
void
connectToEnforced
(
final
String
hostname
)
{
final
ServerPolicyApi
serverPolicyApi
=
final
ServerPolicyApi
serverPolicyApi
=
new
DefaultServerPolicyApi
(
OkHttpHelper
.
getClientForUploadFile
(),
hostname
);
new
DefaultServerPolicyApi
(
OkHttpHelper
.
getClientForUploadFile
(),
hostname
);
final
ServerPolicyApiValidationHelper
validationHelper
=
new
ServerPolicyApiValidationHelper
(
serverPolicyApi
);
final
ServerPolicyApiValidationHelper
validationHelper
=
new
ServerPolicyApiValidationHelper
(
serverPolicyApi
);
clearSubscriptions
();
clearSubscriptions
();
final
Disposable
subscription
=
ServerPolicyHelper
.
isApiVersionValid
(
validationHelper
)
final
Disposable
subscription
=
ServerPolicyHelper
.
isApiVersionValid
(
validationHelper
)
.
subscribeOn
(
Schedulers
.
io
(
))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()
))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doOnTerminate
(()
->
view
.
hideLoader
())
.
doOnTerminate
(()
->
view
.
hideLoader
())
.
subscribe
(
.
subscribe
(
...
@@ -54,16 +47,16 @@ public class InputHostnamePresenter extends BasePresenter<InputHostnameContract.
...
@@ -54,16 +47,16 @@ public class InputHostnamePresenter extends BasePresenter<InputHostnameContract.
}
}
},
},
throwable
->
view
.
showConnectionError
());
throwable
->
view
.
showConnectionError
());
addSubscription
(
subscription
);
addSubscription
(
subscription
);
}
}
private
void
onServerValid
(
final
String
hostname
,
boolean
usesSecureConnection
)
{
private
void
onServerValid
(
String
hostname
,
boolean
usesSecureConnection
)
{
rocketChatCache
.
setSelectedServerHostname
(
hostname
);
rocketChatCache
.
setSelectedServerHostname
(
hostname
);
hostname
=
hostname
.
replace
(
"/"
,
"."
);
connectivityManager
.
addOrUpdateServer
(
hostname
,
hostname
,
!
usesSecureConnection
);
connectivityManager
.
addOrUpdateServer
(
hostname
,
hostname
,
!
usesSecureConnection
);
connectivityManager
.
keepAliveServer
();
connectivityManager
.
keepAliveServer
();
view
.
showHome
();
view
.
showHome
();
}
}
}
}
\ 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