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
1928d269
Commit
1928d269
authored
Feb 22, 2017
by
Tiago Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MainActivity cleaned up
parent
7abf6706
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
48 deletions
+52
-48
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+10
-47
MainContract.java
.../main/java/chat/rocket/android/activity/MainContract.java
+2
-0
MainPresenter.java
...main/java/chat/rocket/android/activity/MainPresenter.java
+40
-1
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
1928d269
...
...
@@ -14,11 +14,9 @@ import chat.rocket.android.api.MethodCallHelper;
import
chat.rocket.android.fragment.chatroom.HomeFragment
;
import
chat.rocket.android.fragment.chatroom.RoomFragment
;
import
chat.rocket.android.fragment.sidebar.SidebarMainFragment
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.core.interactors.CanCreateRoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.SessionInteractor
;
import
chat.rocket.core.models.User
;
import
chat.rocket.android.service.ConnectivityManager
;
import
chat.rocket.android.widget.RoomToolbar
;
import
chat.rocket.persistence.realm.repositories.RealmRoomRepository
;
...
...
@@ -47,29 +45,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
statusTicker
=
new
StatusTicker
();
setupSidebar
();
if
(
roomId
==
null
)
{
showFragment
(
new
HomeFragment
());
}
if
(
shouldLaunchAddServerActivity
())
{
LaunchUtil
.
showAddServerActivity
(
this
);
}
}
@Override
protected
void
onStart
()
{
super
.
onStart
();
setUserOnlineIfServerAvailable
();
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
if
(
presenter
!=
null
)
{
presenter
.
bindView
(
this
);
}
}
@Override
...
...
@@ -81,27 +56,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
super
.
onPause
();
}
@Override
protected
void
onStop
()
{
setUserAwayIfServerAvailable
();
super
.
onStop
();
}
private
void
setUserOnlineIfServerAvailable
()
{
if
(
hostname
!=
null
)
{
new
MethodCallHelper
(
this
,
hostname
).
setUserPresence
(
User
.
STATUS_ONLINE
)
.
continueWith
(
new
LogIfError
());
}
}
private
void
setUserAwayIfServerAvailable
()
{
if
(
hostname
!=
null
)
{
new
MethodCallHelper
(
this
,
hostname
).
setUserPresence
(
User
.
STATUS_AWAY
)
.
continueWith
(
new
LogIfError
());
}
}
private
void
setupSidebar
()
{
SlidingPaneLayout
pane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sliding_pane
);
if
(
pane
==
null
)
{
...
...
@@ -184,10 +138,14 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
presenter
=
new
MainPresenter
(
roomInteractor
,
createRoomInteractor
,
sessionInteractor
sessionInteractor
,
new
MethodCallHelper
(
this
,
hostname
),
ConnectivityManager
.
getInstance
(
getApplicationContext
())
);
updateSidebarMainFragment
();
presenter
.
bindView
(
this
);
}
private
void
updateSidebarMainFragment
()
{
...
...
@@ -226,6 +184,11 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
}
}
@Override
public
void
showAddServerScreen
()
{
LaunchUtil
.
showAddServerActivity
(
this
);
}
@Override
public
void
showLoginScreen
()
{
LaunchUtil
.
showLoginActivity
(
this
,
hostname
);
...
...
app/src/main/java/chat/rocket/android/activity/MainContract.java
View file @
1928d269
...
...
@@ -12,6 +12,8 @@ public interface MainContract {
void
showUnreadCount
(
long
roomsCount
,
int
mentionsCount
);
void
showAddServerScreen
();
void
showLoginScreen
();
void
showConnectionError
();
...
...
app/src/main/java/chat/rocket/android/activity/MainPresenter.java
View file @
1928d269
...
...
@@ -8,11 +8,15 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import
io.reactivex.disposables.Disposable
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.service.ConnectivityManagerApi
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.core.interactors.CanCreateRoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.SessionInteractor
;
import
chat.rocket.core.models.Session
;
import
chat.rocket.core.models.User
;
public
class
MainPresenter
extends
BasePresenter
<
MainContract
.
View
>
implements
MainContract
.
Presenter
{
...
...
@@ -20,21 +24,42 @@ public class MainPresenter extends BasePresenter<MainContract.View>
private
final
CanCreateRoomInteractor
canCreateRoomInteractor
;
private
final
RoomInteractor
roomInteractor
;
private
final
SessionInteractor
sessionInteractor
;
private
final
MethodCallHelper
methodCallHelper
;
private
final
ConnectivityManagerApi
connectivityManagerApi
;
public
MainPresenter
(
RoomInteractor
roomInteractor
,
CanCreateRoomInteractor
canCreateRoomInteractor
,
SessionInteractor
sessionInteractor
)
{
SessionInteractor
sessionInteractor
,
MethodCallHelper
methodCallHelper
,
ConnectivityManagerApi
connectivityManagerApi
)
{
this
.
roomInteractor
=
roomInteractor
;
this
.
canCreateRoomInteractor
=
canCreateRoomInteractor
;
this
.
sessionInteractor
=
sessionInteractor
;
this
.
methodCallHelper
=
methodCallHelper
;
this
.
connectivityManagerApi
=
connectivityManagerApi
;
}
@Override
public
void
bindView
(
@NonNull
MainContract
.
View
view
)
{
super
.
bindView
(
view
);
view
.
showHome
();
if
(
shouldLaunchAddServerActivity
())
{
view
.
showAddServerScreen
();
return
;
}
subscribeToUnreadCount
();
subscribeToSession
();
setUserOnline
();
}
@Override
public
void
release
()
{
setUserAway
();
super
.
release
();
}
@Override
...
...
@@ -101,4 +126,18 @@ public class MainPresenter extends BasePresenter<MainContract.View>
addSubscription
(
subscription
);
}
private
void
setUserOnline
()
{
methodCallHelper
.
setUserPresence
(
User
.
STATUS_ONLINE
)
.
continueWith
(
new
LogIfError
());
}
private
void
setUserAway
()
{
methodCallHelper
.
setUserPresence
(
User
.
STATUS_AWAY
)
.
continueWith
(
new
LogIfError
());
}
private
boolean
shouldLaunchAddServerActivity
()
{
return
connectivityManagerApi
.
getServerList
().
isEmpty
();
}
}
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