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
a8daa6c8
Commit
a8daa6c8
authored
Jun 19, 2018
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
baf84e1e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
0 deletions
+17
-0
ChatRoomsRepository.kt
...t/android/chatrooms/infrastructure/ChatRoomsRepository.kt
+4
-0
ChatRoomsViewModel.kt
.../rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
+9
-0
ChatRoomDao.kt
app/src/main/java/chat/rocket/android/db/ChatRoomDao.kt
+4
-0
No files found.
app/src/main/java/chat/rocket/android/chatrooms/infrastructure/ChatRoomsRepository.kt
View file @
a8daa6c8
...
@@ -15,6 +15,10 @@ class ChatRoomsRepository @Inject constructor(val dao: ChatRoomDao){
...
@@ -15,6 +15,10 @@ class ChatRoomsRepository @Inject constructor(val dao: ChatRoomDao){
}
}
}
}
fun
getChatRooms
(
query
:
String
):
List
<
ChatRoom
>
{
TODO
()
}
enum
class
Order
{
enum
class
Order
{
ACTIVITY
,
ACTIVITY
,
GROUPED_ACTIVITY
,
GROUPED_ACTIVITY
,
...
...
app/src/main/java/chat/rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
View file @
a8daa6c8
...
@@ -9,12 +9,14 @@ import chat.rocket.android.chatrooms.adapter.RoomUiModelMapper
...
@@ -9,12 +9,14 @@ import chat.rocket.android.chatrooms.adapter.RoomUiModelMapper
import
chat.rocket.android.chatrooms.domain.FetchChatRoomsInteractor
import
chat.rocket.android.chatrooms.domain.FetchChatRoomsInteractor
import
chat.rocket.android.chatrooms.infrastructure.ChatRoomsRepository
import
chat.rocket.android.chatrooms.infrastructure.ChatRoomsRepository
import
chat.rocket.android.chatrooms.infrastructure.isGrouped
import
chat.rocket.android.chatrooms.infrastructure.isGrouped
import
chat.rocket.android.db.model.ChatRoom
import
chat.rocket.android.server.infraestructure.ConnectionManager
import
chat.rocket.android.server.infraestructure.ConnectionManager
import
chat.rocket.android.util.livedata.transform
import
chat.rocket.android.util.livedata.transform
import
chat.rocket.core.internal.realtime.socket.model.State
import
chat.rocket.core.internal.realtime.socket.model.State
import
kotlinx.coroutines.experimental.launch
import
kotlinx.coroutines.experimental.launch
import
kotlinx.coroutines.experimental.newSingleThreadContext
import
kotlinx.coroutines.experimental.newSingleThreadContext
import
me.henrytao.livedataktx.distinct
import
me.henrytao.livedataktx.distinct
import
me.henrytao.livedataktx.filter
import
me.henrytao.livedataktx.map
import
me.henrytao.livedataktx.map
import
me.henrytao.livedataktx.nonNull
import
me.henrytao.livedataktx.nonNull
import
timber.log.Timber
import
timber.log.Timber
...
@@ -26,6 +28,7 @@ class ChatRoomsViewModel(
...
@@ -26,6 +28,7 @@ class ChatRoomsViewModel(
private
val
mapper
:
RoomUiModelMapper
private
val
mapper
:
RoomUiModelMapper
)
:
ViewModel
()
{
)
:
ViewModel
()
{
private
val
ordering
:
MutableLiveData
<
ChatRoomsRepository
.
Order
>
=
MutableLiveData
()
private
val
ordering
:
MutableLiveData
<
ChatRoomsRepository
.
Order
>
=
MutableLiveData
()
private
val
query
:
MutableLiveData
<
String
>
=
MutableLiveData
()
private
val
runContext
=
newSingleThreadContext
(
"chat-rooms-view-model"
)
private
val
runContext
=
newSingleThreadContext
(
"chat-rooms-view-model"
)
init
{
init
{
...
@@ -46,6 +49,12 @@ class ChatRoomsViewModel(
...
@@ -46,6 +49,12 @@ class ChatRoomsViewModel(
}
}
}
}
fun
spotlight
():
LiveData
<
List
<
ChatRoom
>>
{
return
query
.
filter
{
!
it
.
isNullOrEmpty
()
}.
distinct
().
nonNull
().
transform
{
repository
.
getChatRooms
(
it
!!
)
}
}
fun
getStatus
():
MutableLiveData
<
State
>
{
fun
getStatus
():
MutableLiveData
<
State
>
{
return
connectionManager
.
statusLiveData
.
nonNull
().
distinct
().
map
{
state
->
return
connectionManager
.
statusLiveData
.
nonNull
().
distinct
().
map
{
state
->
if
(
state
is
State
.
Connected
)
{
if
(
state
is
State
.
Connected
)
{
...
...
app/src/main/java/chat/rocket/android/db/ChatRoomDao.kt
View file @
a8daa6c8
...
@@ -20,6 +20,10 @@ abstract class ChatRoomDao : BaseDao<ChatRoomEntity> {
...
@@ -20,6 +20,10 @@ abstract class ChatRoomDao : BaseDao<ChatRoomEntity> {
"""
)
"""
)
abstract
fun
get
(
id
:
String
):
ChatRoom
?
abstract
fun
get
(
id
:
String
):
ChatRoom
?
@Transaction
@Query
(
"$BASE_QUERY"
)
abstract
fun
getAllSync
():
List
<
ChatRoom
>
@Transaction
@Transaction
@Query
(
"""
@Query
(
"""
$BASE_QUERY
$BASE_QUERY
...
...
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