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
ecb2a54c
Commit
ecb2a54c
authored
Apr 20, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update layout and ChatRoomsPresenter.kt
parent
5232e7eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
26 deletions
+33
-26
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+23
-18
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+5
-5
item_chat.xml
app/src/main/res/layout/item_chat.xml
+5
-3
No files found.
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
ecb2a54c
...
...
@@ -111,9 +111,13 @@ class ChatRoomsPresenter @Inject constructor(
val
chatRoomsCombined
=
mutableListOf
<
ChatRoom
>()
chatRoomsCombined
.
addAll
(
usersToChatRooms
(
users
))
chatRoomsCombined
.
addAll
(
roomsToChatRooms
(
rooms
))
view
.
updateChatRooms
(
getChatRoomsWithPreviews
(
chatRoomsCombined
.
toList
()))
val
chatRoomsWithPreview
=
getChatRoomsWithPreviews
(
chatRoomsCombined
)
val
chatRoomsWithStatus
=
getChatRoomWithStatus
(
chatRoomsWithPreview
)
view
.
updateChatRooms
(
chatRoomsWithStatus
)
}
else
{
view
.
updateChatRooms
(
getChatRoomsWithPreviews
(
roomList
))
val
chatRoomsWithPreview
=
getChatRoomsWithPreviews
(
roomList
)
val
chatRoomsWithStatus
=
getChatRoomWithStatus
(
chatRoomsWithPreview
)
view
.
updateChatRooms
(
chatRoomsWithStatus
)
}
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
...
...
@@ -121,6 +125,19 @@ class ChatRoomsPresenter @Inject constructor(
}
}
// In the first time it will not come with the users status, but after called by the
// [reloadRooms] function may be with.
private
suspend
fun
getUserChatRooms
():
List
<
ChatRoom
>
{
val
chatRooms
=
retryIO
(
"chatRooms"
)
{
manager
.
chatRooms
().
update
}
val
chatRoomsWithPreview
=
getChatRoomsWithPreviews
(
chatRooms
)
val
chatRoomsWithUserStatus
=
getChatRoomWithStatus
(
chatRoomsWithPreview
)
val
sortedRooms
=
sortRooms
(
chatRoomsWithUserStatus
)
Timber
.
d
(
"Loaded rooms: ${sortedRooms.size}"
)
saveChatRoomsInteractor
.
save
(
currentServer
,
sortedRooms
)
return
sortedRooms
}
private
fun
usersToChatRooms
(
users
:
List
<
User
>):
List
<
ChatRoom
>
{
return
users
.
map
{
ChatRoom
(
...
...
@@ -134,7 +151,6 @@ class ChatRoomsPresenter @Inject constructor(
null
},
name
=
it
.
name
?:
""
,
status
=
null
,
fullName
=
it
.
name
,
readonly
=
false
,
updatedAt
=
null
,
...
...
@@ -168,7 +184,6 @@ class ChatRoomsPresenter @Inject constructor(
null
},
name
=
it
.
name
?:
""
,
status
=
null
,
fullName
=
it
.
fullName
,
readonly
=
it
.
readonly
,
updatedAt
=
it
.
updatedAt
,
...
...
@@ -189,17 +204,7 @@ class ChatRoomsPresenter @Inject constructor(
}
}
private
suspend
fun
getUserChatRooms
():
List
<
ChatRoom
>
{
val
chatRooms
=
retryIO
(
"chatRooms"
)
{
manager
.
chatRooms
().
update
}
val
sortedRooms
=
sortRooms
(
chatRooms
)
Timber
.
d
(
"Loaded rooms: ${sortedRooms.size}"
)
saveChatRoomsInteractor
.
save
(
currentServer
,
sortedRooms
)
val
chatRoomsWithPreview
=
getChatRoomsWithPreviews
(
sortedRooms
)
return
getChatRoomWithStatus
(
chatRoomsWithPreview
)
}
fun
updateSortedChatRooms
()
{
val
currentServer
=
serverInteractor
.
get
()
!!
launchUI
(
strategy
)
{
val
roomList
=
getChatRoomsInteractor
.
getAll
(
currentServer
)
view
.
updateChatRooms
(
sortRooms
(
roomList
))
...
...
@@ -401,7 +406,6 @@ class ChatRoomsPresenter @Inject constructor(
room
.
name
?:
name
)
?.
status
,
name
=
room
.
name
?:
name
,
status
=
null
,
fullName
=
room
.
fullName
?:
fullName
,
readonly
=
room
.
readonly
,
updatedAt
=
room
.
updatedAt
?:
updatedAt
,
...
...
@@ -441,7 +445,6 @@ class ChatRoomsPresenter @Inject constructor(
subscription
.
name
)
?.
status
,
name
=
subscription
.
name
,
status
=
null
,
fullName
=
subscription
.
fullName
?:
fullName
,
readonly
=
subscription
.
readonly
?:
readonly
,
updatedAt
=
subscription
.
updatedAt
?:
updatedAt
,
...
...
@@ -505,6 +508,7 @@ class ChatRoomsPresenter @Inject constructor(
}
private
fun
updateChatRoomWithUserStatus
(
user_
:
User
)
{
Timber
.
d
(
"active User: $user_"
)
val
username
=
user_
.
username
val
status
=
user_
.
status
if
(
username
!=
null
&&
status
!=
null
)
{
...
...
@@ -546,10 +550,11 @@ class ChatRoomsPresenter @Inject constructor(
private
fun
updateChatRooms
()
{
Timber
.
i
(
"Updating ChatRooms"
)
launch
(
strategy
.
jobs
)
{
val
chatRooms
=
getChatRoomsWithPreviews
(
val
chatRooms
WithPreview
=
getChatRoomsWithPreviews
(
getChatRoomsInteractor
.
getAll
(
currentServer
)
)
view
.
updateChatRooms
(
chatRooms
)
val
chatRoomsWithStatus
=
getChatRoomWithStatus
(
chatRoomsWithPreview
)
view
.
updateChatRooms
(
chatRoomsWithStatus
)
}
}
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
ecb2a54c
...
...
@@ -32,12 +32,9 @@ import dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.fragment_chat_rooms.*
import
kotlinx.coroutines.experimental.Job
import
kotlinx.coroutines.experimental.NonCancellable.isActive
import
kotlinx.coroutines.experimental.android.UI
import
kotlinx.coroutines.experimental.launch
import
timber.log.Timber
import
javax.inject.Inject
class
ChatRoomsFragment
:
Fragment
(),
ChatRoomsView
{
@Inject
lateinit
var
presenter
:
ChatRoomsPresenter
@Inject
lateinit
var
serverInteractor
:
GetCurrentServerInteractor
...
...
@@ -67,7 +64,11 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
super
.
onDestroy
()
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
=
container
?.
inflate
(
R
.
layout
.
fragment_chat_rooms
)
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?
):
View
?
=
container
?.
inflate
(
R
.
layout
.
fragment_chat_rooms
)
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
...
...
@@ -100,7 +101,6 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
})
}
override
fun
onOptionsItemSelected
(
item
:
MenuItem
):
Boolean
{
when
(
item
.
itemId
)
{
R
.
id
.
action_sort
->
{
...
...
app/src/main/res/layout/item_chat.xml
View file @
ecb2a54c
...
...
@@ -31,9 +31,9 @@
<ImageView
android:id=
"@+id/image_chat_icon"
android:layout_width=
"
12dp
"
android:layout_height=
"
12dp
"
android:layout_gravity=
"center"
android:layout_width=
"
wrap_content
"
android:layout_height=
"
wrap_content
"
android:layout_gravity=
"center
_vertical
"
tools:src=
"@drawable/ic_lock_12_dp"
/>
<TextView
...
...
@@ -41,8 +41,10 @@
style=
"@style/ChatRoom.Name.TextView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginEnd=
"5dp"
android:layout_marginStart=
"8dp"
android:ellipsize=
"end"
android:textDirection=
"locale"
tools:text=
"A very very very very big chat room name"
/>
</LinearLayout>
...
...
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