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
0af8de4c
Commit
0af8de4c
authored
Aug 30, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update SidebarMainPresenter.java
parent
da668d26
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
165 additions
and
147 deletions
+165
-147
SidebarMainPresenter.java
...rocket/android/fragment/sidebar/SidebarMainPresenter.java
+165
-147
No files found.
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainPresenter.java
View file @
0af8de4c
...
@@ -3,12 +3,10 @@ package chat.rocket.android.fragment.sidebar;
...
@@ -3,12 +3,10 @@ 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
chat.rocket.core.models.Spotlight
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
com.hadisatrio.optional.Optional
;
import
com.hadisatrio.optional.Optional
;
import
io.reactivex.Flowable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
java.util.ArrayList
;
import
io.reactivex.disposables.Disposable
;
import
java.util.List
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.RocketChatCache
;
...
@@ -20,19 +18,24 @@ import chat.rocket.android.helper.TextUtils;
...
@@ -20,19 +18,24 @@ import chat.rocket.android.helper.TextUtils;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.models.Room
;
import
chat.rocket.core.models.Room
;
import
chat.rocket.core.models.RoomSidebar
;
import
chat.rocket.core.models.Spotlight
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.repositories.UserRepository
;
import
chat.rocket.core.repositories.UserRepository
;
import
java.util.List
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
io.reactivex.Flowable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
public
class
SidebarMainPresenter
extends
BasePresenter
<
SidebarMainContract
.
View
>
implements
SidebarMainContract
.
Presenter
{
public
class
SidebarMainPresenter
extends
BasePresenter
<
SidebarMainContract
.
View
>
implements
SidebarMainContract
.
Presenter
{
private
final
String
hostname
;
private
final
String
hostname
;
private
String
userId
;
private
final
RoomInteractor
roomInteractor
;
private
final
RoomInteractor
roomInteractor
;
private
final
UserRepository
userRepository
;
private
final
UserRepository
userRepository
;
private
final
RocketChatCache
rocketChatCache
;
private
final
RocketChatCache
rocketChatCache
;
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
;
public
SidebarMainPresenter
(
String
hostname
,
public
SidebarMainPresenter
(
String
hostname
,
RoomInteractor
roomInteractor
,
RoomInteractor
roomInteractor
,
...
@@ -70,20 +73,14 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -70,20 +73,14 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
)
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
.
subscribe
(
pair
->
view
.
show
(
pair
.
first
.
orNull
()),
Logger:
:
report
);
pair
->
{
userId
=
pair
.
first
.
orNull
().
getId
();
view
.
show
(
pair
.
first
.
orNull
());
},
Logger:
:
report
);
addSubscription
(
subscription
);
addSubscription
(
subscription
);
}
}
@Override
@Override
public
void
onRoomSelected
(
Room
room
)
{
public
void
onRoomSelected
(
RoomSidebar
roomSidebar
)
{
rocketChatCache
.
setSelectedRoomId
(
room
.
getRoomId
());
rocketChatCache
.
setSelectedRoomId
(
roomSidebar
.
getRoomId
());
}
}
@Override
@Override
...
@@ -149,23 +146,44 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -149,23 +146,44 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
}
}
private
void
processRooms
(
List
<
Room
>
roomList
)
{
private
void
processRooms
(
List
<
Room
>
roomList
)
{
view
.
showRoomList
(
roomList
);
ArrayList
<
RoomSidebar
>
roomSidebarList
=
new
ArrayList
<>();
for
(
Room
room:
roomList
)
{
for
(
Room
room
:
roomList
)
{
if
(
room
.
isDirectMessage
())
{
String
roomName
=
room
.
getName
();
subscribeToDirectMessages
(
room
.
getName
());
String
roomType
=
room
.
getType
();
roomSidebar
=
new
RoomSidebar
();
roomSidebar
.
setId
(
room
.
getId
());
roomSidebar
.
setRoomId
(
room
.
getRoomId
());
roomSidebar
.
setRoomName
(
roomName
);
roomSidebar
.
setType
(
roomType
);
roomSidebar
.
setAlert
(
room
.
isAlert
());
roomSidebar
.
setFavorite
(
room
.
isFavorite
());
roomSidebar
.
setUnread
(
room
.
getUnread
());
roomSidebar
.
setUpdateAt
(
room
.
getUpdatedAt
());
roomSidebar
.
setLastSeen
(
room
.
getLastSeen
());
if
(
roomType
.
equals
(
Room
.
TYPE_DIRECT_MESSAGE
))
{
getUserStatus
(
roomName
);
}
}
roomSidebarList
.
add
(
roomSidebar
);
}
}
view
.
showRoomSidebarList
(
roomSidebarList
);
}
}
private
void
subscribeToDirectMessage
s
(
String
username
)
{
private
void
getUserStatu
s
(
String
username
)
{
final
Disposable
disposable
=
userRepository
.
getByUsername
(
username
)
final
Disposable
subscription
=
userRepository
.
getByUsername
(
username
)
.
distinctUntilChanged
()
.
distinctUntilChanged
()
.
filter
(
Optional:
:
isPresent
)
.
filter
(
Optional:
:
isPresent
)
.
map
(
Optional:
:
get
)
.
map
(
Optional:
:
get
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
map
(
User:
:
getStatus
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
this
::
setUserStatus
);
.
subscribe
(
view:
:
showUserStatus
,
Logger:
:
report
);
addSubscription
(
subscription
);
addSubscription
(
disposable
);
}
private
void
setUserStatus
(
String
status
)
{
roomSidebar
.
setUserStatus
(
status
);
}
}
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