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
02f7c65b
Commit
02f7c65b
authored
Sep 01, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update SidebarMainPresenter.java
parent
99604ed3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
17 deletions
+29
-17
SidebarMainPresenter.java
...rocket/android/fragment/sidebar/SidebarMainPresenter.java
+29
-17
No files found.
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainPresenter.java
View file @
02f7c65b
...
@@ -3,8 +3,6 @@ package chat.rocket.android.fragment.sidebar;
...
@@ -3,8 +3,6 @@ package chat.rocket.android.fragment.sidebar;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
android.support.v4.util.Pair
;
import
android.support.v4.util.Pair
;
import
com.hadisatrio.optional.Optional
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -35,7 +33,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -35,7 +33,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
private
final
AbsoluteUrlHelper
absoluteUrlHelper
;
private
final
AbsoluteUrlHelper
absoluteUrlHelper
;
private
final
MethodCallHelper
methodCallHelper
;
private
final
MethodCallHelper
methodCallHelper
;
private
RealmSpotlightRepository
realmSpotlightRepository
;
private
RealmSpotlightRepository
realmSpotlightRepository
;
private
RoomSidebar
roomSidebar
;
private
List
<
RoomSidebar
>
roomSidebarList
;
public
SidebarMainPresenter
(
String
hostname
,
public
SidebarMainPresenter
(
String
hostname
,
RoomInteractor
roomInteractor
,
RoomInteractor
roomInteractor
,
...
@@ -146,12 +144,14 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -146,12 +144,14 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
}
}
private
void
processRooms
(
List
<
Room
>
roomList
)
{
private
void
processRooms
(
List
<
Room
>
roomList
)
{
ArrayList
<
RoomSidebar
>
roomSidebarList
=
new
ArrayList
<>();
roomSidebarList
=
new
ArrayList
<>();
List
<
String
>
userToObserverList
=
new
ArrayList
<>();
for
(
Room
room
:
roomList
)
{
for
(
Room
room
:
roomList
)
{
String
roomName
=
room
.
getName
();
String
roomName
=
room
.
getName
();
String
roomType
=
room
.
getType
();
String
roomType
=
room
.
getType
();
roomSidebar
=
new
RoomSidebar
();
RoomSidebar
roomSidebar
=
new
RoomSidebar
();
roomSidebar
.
setId
(
room
.
getId
());
roomSidebar
.
setId
(
room
.
getId
());
roomSidebar
.
setRoomId
(
room
.
getRoomId
());
roomSidebar
.
setRoomId
(
room
.
getRoomId
());
...
@@ -164,26 +164,38 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -164,26 +164,38 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
roomSidebar
.
setLastSeen
(
room
.
getLastSeen
());
roomSidebar
.
setLastSeen
(
room
.
getLastSeen
());
if
(
roomType
.
equals
(
Room
.
TYPE_DIRECT_MESSAGE
))
{
if
(
roomType
.
equals
(
Room
.
TYPE_DIRECT_MESSAGE
))
{
getUserStatus
(
roomName
);
userToObserverList
.
add
(
roomName
);
}
}
roomSidebarList
.
add
(
roomSidebar
);
roomSidebarList
.
add
(
roomSidebar
);
}
}
if
(
userToObserverList
.
isEmpty
())
{
view
.
showRoomSidebarList
(
roomSidebarList
);
view
.
showRoomSidebarList
(
roomSidebarList
);
}
else
{
getUsersStatus
();
}
}
}
private
void
getUserStatus
(
String
username
)
{
private
void
getUsersStatus
()
{
final
Disposable
subscription
=
userRepository
.
getByUsername
(
username
)
// TODO Filter when Android Studion uses the java8 features (removeIf).
// .filter(userList -> userList.removeIf(user -> !userToObserverList.contains(user.getUsername())))
final
Disposable
subscription
=
userRepository
.
getAll
()
.
distinctUntilChanged
()
.
distinctUntilChanged
()
.
filter
(
Optional:
:
isPresent
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
map
(
Optional:
:
get
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
map
(
User:
:
getStatus
)
.
subscribe
(
this
::
processUsers
,
Logger:
:
report
);
.
subscribe
(
this
::
setUserStatus
);
addSubscription
(
subscription
);
addSubscription
(
subscription
);
}
}
private
void
setUserStatus
(
String
status
)
{
private
void
processUsers
(
List
<
User
>
userList
)
{
roomSidebar
.
setUserStatus
(
status
);
for
(
User
user:
userList
)
{
for
(
RoomSidebar
roomSidebar:
roomSidebarList
)
{
if
(
roomSidebar
.
getRoomName
().
equals
(
user
.
getUsername
()))
{
roomSidebar
.
setUserStatus
(
user
.
getStatus
());
}
}
}
view
.
showRoomSidebarList
(
roomSidebarList
);
}
}
private
void
updateCurrentUserStatus
(
String
status
)
{
private
void
updateCurrentUserStatus
(
String
status
)
{
...
...
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