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
3eaba537
Unverified
Commit
3eaba537
authored
Apr 29, 2019
by
Upendra Reddy
Committed by
GitHub
Apr 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into issue-profile-render
parents
a377458f
14cc4292
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
12 deletions
+102
-12
ChatRoomsRepository.kt
...t/android/chatrooms/infrastructure/ChatRoomsRepository.kt
+13
-1
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+4
-4
ChatRoomsViewModel.kt
.../rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
+31
-7
ChatRoomDao.kt
app/src/main/java/chat/rocket/android/db/ChatRoomDao.kt
+54
-0
No files found.
app/src/main/java/chat/rocket/android/chatrooms/infrastructure/ChatRoomsRepository.kt
View file @
3eaba537
...
...
@@ -15,6 +15,10 @@ class ChatRoomsRepository @Inject constructor(private val dao: ChatRoomDao) {
Order
.
GROUPED_ACTIVITY
->
dao
.
getAllGrouped
()
Order
.
NAME
->
dao
.
getAllAlphabetically
()
Order
.
GROUPED_NAME
->
dao
.
getAllAlphabeticallyGrouped
()
Order
.
UNREAD_ON_TOP_ACTIVITY
->
dao
.
getAllUnread
();
Order
.
UNREAD_ON_TOP_NAME
->
dao
.
getAllAlphabeticallyUnread
();
Order
.
UNREAD_ON_TOP_GROUPED_ACTIVITY
->
dao
.
getAllGroupedUnread
();
Order
.
UNREAD_ON_TOP_GROUPED_NAME
->
dao
.
getAllAlphabeticallyGroupedUnread
();
}
}
...
...
@@ -28,8 +32,16 @@ class ChatRoomsRepository @Inject constructor(private val dao: ChatRoomDao) {
GROUPED_ACTIVITY
,
NAME
,
GROUPED_NAME
,
UNREAD_ON_TOP_ACTIVITY
,
UNREAD_ON_TOP_NAME
,
UNREAD_ON_TOP_GROUPED_ACTIVITY
,
UNREAD_ON_TOP_GROUPED_NAME
}
}
fun
ChatRoomsRepository
.
Order
.
isGrouped
():
Boolean
=
this
==
ChatRoomsRepository
.
Order
.
GROUPED_ACTIVITY
||
this
==
ChatRoomsRepository
.
Order
.
GROUPED_NAME
fun
ChatRoomsRepository
.
Order
.
isUnreadOnTop
():
Boolean
=
this
==
ChatRoomsRepository
.
Order
.
UNREAD_ON_TOP_ACTIVITY
||
this
==
ChatRoomsRepository
.
Order
.
UNREAD_ON_TOP_NAME
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
3eaba537
...
...
@@ -301,10 +301,10 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
this
.
isGroupByFavorites
=
isGroupByFavorites
if
(
isSortByName
)
{
viewModel
.
setQuery
(
Query
.
ByName
(
isGroupByType
))
viewModel
.
setQuery
(
Query
.
ByName
(
isGroupByType
,
isUnreadOnTop
))
changeSortByTitle
(
getString
(
R
.
string
.
msg_sort_by_name
))
}
else
{
viewModel
.
setQuery
(
Query
.
ByActivity
(
isGroupByType
))
viewModel
.
setQuery
(
Query
.
ByActivity
(
isGroupByType
,
isUnreadOnTop
))
changeSortByTitle
(
getString
(
R
.
string
.
msg_sort_by_activity
))
}
}
...
...
@@ -324,9 +324,9 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
private
fun
showAllChats
()
{
if
(
isSortByName
)
{
viewModel
.
setQuery
(
Query
.
ByName
(
isGroupByType
))
viewModel
.
setQuery
(
Query
.
ByName
(
isGroupByType
,
isUnreadOnTop
))
}
else
{
viewModel
.
setQuery
(
Query
.
ByActivity
(
isGroupByType
))
viewModel
.
setQuery
(
Query
.
ByActivity
(
isGroupByType
,
isUnreadOnTop
))
}
}
...
...
app/src/main/java/chat/rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
View file @
3eaba537
...
...
@@ -140,8 +140,10 @@ sealed class LoadingState {
}
sealed
class
Query
{
data class
ByActivity
(
val
grouped
:
Boolean
=
false
)
:
Query
()
data class
ByName
(
val
grouped
:
Boolean
=
false
)
:
Query
()
data class
ByActivity
(
val
grouped
:
Boolean
=
false
,
val
unreadOnTop
:
Boolean
=
false
)
:
Query
()
data class
ByName
(
val
grouped
:
Boolean
=
false
,
val
unreadOnTop
:
Boolean
=
false
)
:
Query
()
data class
Search
(
val
query
:
String
)
:
Query
()
}
...
...
@@ -155,19 +157,41 @@ fun Query.isGrouped(): Boolean {
}
}
fun
Query
.
isUnreadOnTop
():
Boolean
{
return
when
(
this
)
{
is
Query
.
Search
->
false
is
Query
.
ByName
->
unreadOnTop
is
Query
.
ByActivity
->
unreadOnTop
}
}
fun
Query
.
asSortingOrder
():
ChatRoomsRepository
.
Order
{
return
when
(
this
)
{
is
Query
.
ByName
->
{
if
(
grouped
)
{
if
(
grouped
&&
!
unreadOnTop
)
{
ChatRoomsRepository
.
Order
.
GROUPED_NAME
}
else
{
}
else
if
(
unreadOnTop
&&
!
grouped
){
ChatRoomsRepository
.
Order
.
UNREAD_ON_TOP_NAME
}
else
if
(
unreadOnTop
&&
grouped
){
ChatRoomsRepository
.
Order
.
UNREAD_ON_TOP_GROUPED_NAME
}
else
{
ChatRoomsRepository
.
Order
.
NAME
}
}
is
Query
.
ByActivity
->
{
if
(
grouped
)
{
if
(
grouped
&&
!
unreadOnTop
)
{
ChatRoomsRepository
.
Order
.
GROUPED_ACTIVITY
}
else
{
}
else
if
(
unreadOnTop
&&
!
grouped
){
ChatRoomsRepository
.
Order
.
UNREAD_ON_TOP_ACTIVITY
}
else
if
(
unreadOnTop
&&
grouped
){
ChatRoomsRepository
.
Order
.
UNREAD_ON_TOP_GROUPED_ACTIVITY
}
else
{
ChatRoomsRepository
.
Order
.
ACTIVITY
}
}
...
...
app/src/main/java/chat/rocket/android/db/ChatRoomDao.kt
View file @
3eaba537
...
...
@@ -65,6 +65,54 @@ abstract class ChatRoomDao : BaseDao<ChatRoomEntity> {
"""
)
abstract
fun
getAllGrouped
():
LiveData
<
List
<
ChatRoom
>>
@Transaction
@Query
(
"""
$BASE_QUERY
$FILTER_NOT_OPENED
ORDER BY
$UNREAD,
CASE
WHEN lastMessageTimeStamp IS NOT NULL THEN lastMessageTimeStamp
ELSE updatedAt
END DESC
"""
)
abstract
fun
getAllUnread
():
LiveData
<
List
<
ChatRoom
>>
@Transaction
@Query
(
"""
$BASE_QUERY
$FILTER_NOT_OPENED
ORDER BY
$UNREAD,
name COLLATE NOCASE
"""
)
abstract
fun
getAllAlphabeticallyUnread
():
LiveData
<
List
<
ChatRoom
>>
@Transaction
@Query
(
"""
$BASE_QUERY
$FILTER_NOT_OPENED
ORDER BY
$TYPE_ORDER,
$UNREAD,
name COLLATE NOCASE
"""
)
abstract
fun
getAllAlphabeticallyGroupedUnread
():
LiveData
<
List
<
ChatRoom
>>
@Transaction
@Query
(
"""
$BASE_QUERY
$FILTER_NOT_OPENED
ORDER BY
$TYPE_ORDER,
$UNREAD,
CASE
WHEN lastMessageTimeStamp IS NOT NULL THEN lastMessageTimeStamp
ELSE updatedAt
END DESC
"""
)
abstract
fun
getAllGroupedUnread
():
LiveData
<
List
<
ChatRoom
>>
@Transaction
@Query
(
"""
$BASE_QUERY
...
...
@@ -139,5 +187,11 @@ abstract class ChatRoomDao : BaseDao<ChatRoomEntity> {
ELSE 5
END
"""
const
val
UNREAD
=
"""
CASE
WHEN alert OR unread > 0 THEN 1
ELSE 2
END
"""
}
}
\ No newline at end of file
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