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
596d1035
Commit
596d1035
authored
Feb 13, 2017
by
Tiago Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forgot this one
parent
772b55bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
31 deletions
+14
-31
InputHostnameContract.java
...et/android/fragment/add_server/InputHostnameContract.java
+3
-7
InputHostnamePresenter.java
...t/android/fragment/add_server/InputHostnamePresenter.java
+7
-24
BasePresenter.java
...c/main/java/chat/rocket/android/shared/BasePresenter.java
+4
-0
No files found.
app/src/main/java/chat/rocket/android/fragment/add_server/InputHostnameContract.java
View file @
596d1035
package
chat
.
rocket
.
android
.
fragment
.
add_server
;
package
chat
.
rocket
.
android
.
fragment
.
add_server
;
import
android.support.annotation.NonNull
;
import
chat.rocket.android.shared.BaseContract
;
public
interface
InputHostnameContract
{
public
interface
InputHostnameContract
{
interface
View
{
interface
View
extends
BaseContract
.
View
{
void
showLoader
();
void
showLoader
();
void
hideLoader
();
void
hideLoader
();
...
@@ -16,11 +16,7 @@ public interface InputHostnameContract {
...
@@ -16,11 +16,7 @@ public interface InputHostnameContract {
void
showHome
();
void
showHome
();
}
}
interface
Presenter
{
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
void
bindView
(
@NonNull
View
view
);
void
release
();
void
connectTo
(
String
hostname
);
void
connectTo
(
String
hostname
);
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/add_server/InputHostnamePresenter.java
View file @
596d1035
package
chat
.
rocket
.
android
.
fragment
.
add_server
;
package
chat
.
rocket
.
android
.
fragment
.
add_server
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.support.annotation.NonNull
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.rest.DefaultServerPolicyApi
;
import
chat.rocket.android.api.rest.DefaultServerPolicyApi
;
...
@@ -10,11 +9,13 @@ import chat.rocket.android.helper.OkHttpHelper;
...
@@ -10,11 +9,13 @@ import chat.rocket.android.helper.OkHttpHelper;
import
chat.rocket.android.helper.ServerPolicyApiValidationHelper
;
import
chat.rocket.android.helper.ServerPolicyApiValidationHelper
;
import
chat.rocket.android.helper.ServerPolicyHelper
;
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
rx.Subscription
;
import
rx.Subscription
;
import
rx.android.schedulers.AndroidSchedulers
;
import
rx.android.schedulers.AndroidSchedulers
;
import
rx.schedulers.Schedulers
;
import
rx.schedulers.Schedulers
;
public
class
InputHostnamePresenter
implements
InputHostnameContract
.
Presenter
{
public
class
InputHostnamePresenter
extends
BasePresenter
<
InputHostnameContract
.
View
>
implements
InputHostnameContract
.
Presenter
{
private
final
SharedPreferences
rocketChatCache
;
private
final
SharedPreferences
rocketChatCache
;
private
final
ConnectivityManagerApi
connectivityManager
;
private
final
ConnectivityManagerApi
connectivityManager
;
...
@@ -25,24 +26,6 @@ public class InputHostnamePresenter implements InputHostnameContract.Presenter {
...
@@ -25,24 +26,6 @@ public class InputHostnamePresenter implements InputHostnameContract.Presenter {
this
.
connectivityManager
=
connectivityManager
;
this
.
connectivityManager
=
connectivityManager
;
}
}
private
InputHostnameContract
.
View
view
;
private
Subscription
serverPolicySubscription
;
@Override
public
void
bindView
(
@NonNull
InputHostnameContract
.
View
view
)
{
this
.
view
=
view
;
}
@Override
public
void
release
()
{
if
(
serverPolicySubscription
!=
null
)
{
serverPolicySubscription
.
unsubscribe
();
}
view
=
null
;
}
@Override
@Override
public
void
connectTo
(
final
String
hostname
)
{
public
void
connectTo
(
final
String
hostname
)
{
view
.
showLoader
();
view
.
showLoader
();
...
@@ -57,11 +40,9 @@ public class InputHostnamePresenter implements InputHostnameContract.Presenter {
...
@@ -57,11 +40,9 @@ public class InputHostnamePresenter implements InputHostnameContract.Presenter {
final
ServerPolicyApiValidationHelper
validationHelper
=
final
ServerPolicyApiValidationHelper
validationHelper
=
new
ServerPolicyApiValidationHelper
(
serverPolicyApi
);
new
ServerPolicyApiValidationHelper
(
serverPolicyApi
);
if
(
serverPolicySubscription
!=
null
)
{
clearSubscripions
();
serverPolicySubscription
.
unsubscribe
();
}
serverPolicyS
ubscription
=
ServerPolicyHelper
.
isApiVersionValid
(
validationHelper
)
final
Subscription
s
ubscription
=
ServerPolicyHelper
.
isApiVersionValid
(
validationHelper
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doOnTerminate
(()
->
view
.
hideLoader
())
.
doOnTerminate
(()
->
view
.
hideLoader
())
...
@@ -76,6 +57,8 @@ public class InputHostnamePresenter implements InputHostnameContract.Presenter {
...
@@ -76,6 +57,8 @@ public class InputHostnamePresenter implements InputHostnameContract.Presenter {
throwable
->
{
throwable
->
{
view
.
showConnectionError
();
view
.
showConnectionError
();
});
});
addSubscription
(
subscription
);
}
}
private
void
onServerValid
(
final
String
hostname
,
boolean
usesSecureConnection
)
{
private
void
onServerValid
(
final
String
hostname
,
boolean
usesSecureConnection
)
{
...
...
app/src/main/java/chat/rocket/android/shared/BasePresenter.java
View file @
596d1035
...
@@ -25,4 +25,8 @@ public abstract class BasePresenter<T extends BaseContract.View>
...
@@ -25,4 +25,8 @@ public abstract class BasePresenter<T extends BaseContract.View>
protected
void
addSubscription
(
Subscription
subscription
)
{
protected
void
addSubscription
(
Subscription
subscription
)
{
compositeSubscription
.
add
(
subscription
);
compositeSubscription
.
add
(
subscription
);
}
}
protected
void
clearSubscripions
()
{
compositeSubscription
.
clear
();
}
}
}
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