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
84cc9a42
Commit
84cc9a42
authored
Jun 29, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the Member, Pinned, Favorite and File list not showing bug.
parent
0cdd58ee
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
159 additions
and
68 deletions
+159
-68
ActivityBuilder.kt
...java/chat/rocket/android/dagger/module/ActivityBuilder.kt
+1
-1
FavoriteMessagesFragmentModule.kt
...oid/favoritemessages/di/FavoriteMessagesFragmentModule.kt
+27
-7
FavoriteMessagesFragmentProvider.kt
...d/favoritemessages/di/FavoriteMessagesFragmentProvider.kt
+1
-1
FavoriteMessagesPresenter.kt
...avoritemessages/presentation/FavoriteMessagesPresenter.kt
+10
-8
FilesFragmentModule.kt
.../java/chat/rocket/android/files/di/FilesFragmentModule.kt
+26
-6
FilesPresenter.kt
.../chat/rocket/android/files/presentation/FilesPresenter.kt
+13
-12
MembersFragmentModule.kt
...a/chat/rocket/android/members/di/MembersFragmentModule.kt
+23
-3
MembersPresenter.kt
...t/rocket/android/members/presentation/MembersPresenter.kt
+22
-16
PinnedMessagesFragmentModule.kt
...android/pinnedmessages/di/PinnedMessagesFragmentModule.kt
+26
-6
PinnedMessagesPresenter.kt
...id/pinnedmessages/presentation/PinnedMessagesPresenter.kt
+10
-8
No files found.
app/src/main/java/chat/rocket/android/dagger/module/ActivityBuilder.kt
View file @
84cc9a42
...
@@ -10,11 +10,11 @@ import chat.rocket.android.authentication.twofactor.di.TwoFAFragmentProvider
...
@@ -10,11 +10,11 @@ import chat.rocket.android.authentication.twofactor.di.TwoFAFragmentProvider
import
chat.rocket.android.authentication.ui.AuthenticationActivity
import
chat.rocket.android.authentication.ui.AuthenticationActivity
import
chat.rocket.android.chatroom.di.ChatRoomFragmentProvider
import
chat.rocket.android.chatroom.di.ChatRoomFragmentProvider
import
chat.rocket.android.chatroom.di.ChatRoomModule
import
chat.rocket.android.chatroom.di.ChatRoomModule
import
chat.rocket.android.chatroom.di.FavoriteMessagesFragmentProvider
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.chatrooms.di.ChatRoomsFragmentProvider
import
chat.rocket.android.chatrooms.di.ChatRoomsFragmentProvider
import
chat.rocket.android.createchannel.di.CreateChannelProvider
import
chat.rocket.android.createchannel.di.CreateChannelProvider
import
chat.rocket.android.dagger.scope.PerActivity
import
chat.rocket.android.dagger.scope.PerActivity
import
chat.rocket.android.favoritemessages.di.FavoriteMessagesFragmentProvider
import
chat.rocket.android.files.di.FilesFragmentProvider
import
chat.rocket.android.files.di.FilesFragmentProvider
import
chat.rocket.android.main.di.MainModule
import
chat.rocket.android.main.di.MainModule
import
chat.rocket.android.main.ui.MainActivity
import
chat.rocket.android.main.ui.MainActivity
...
...
app/src/main/java/chat/rocket/android/favoritemessages/di/FavoriteMessagesFragmentModule.kt
View file @
84cc9a42
package
chat.rocket.android.
chatroom
.di
package
chat.rocket.android.
favoritemessages
.di
import
androidx.lifecycle.LifecycleOwner
import
androidx.lifecycle.LifecycleOwner
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.DatabaseManagerFactory
import
chat.rocket.android.favoritemessages.presentation.FavoriteMessagesView
import
chat.rocket.android.favoritemessages.presentation.FavoriteMessagesView
import
chat.rocket.android.favoritemessages.ui.FavoriteMessagesFragment
import
chat.rocket.android.favoritemessages.ui.FavoriteMessagesFragment
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
dagger.Module
import
dagger.Module
import
dagger.Provides
import
dagger.Provides
import
kotlinx.coroutines.experimental.Job
import
kotlinx.coroutines.experimental.Job
import
javax.inject.Named
@Module
@Module
class
FavoriteMessagesFragmentModule
{
class
FavoriteMessagesFragmentModule
{
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideJob
()
=
Job
()
fun
provideFavoriteMessagesView
(
frag
:
FavoriteMessagesFragment
):
FavoriteMessagesView
{
return
frag
}
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideLifecycleOwner
(
frag
:
FavoriteMessagesFragment
):
LifecycleOwner
{
@Named
(
"currentServer"
)
return
frag
fun
provideCurrentServer
(
currentServerInteractor
:
GetCurrentServerInteractor
):
String
{
return
currentServerInteractor
.
get
()
!!
}
}
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideCancelStrategy
(
owner
:
LifecycleOwner
,
jobs
:
Job
):
CancelStrategy
{
fun
provideDatabaseManager
(
return
CancelStrategy
(
owner
,
jobs
)
factory
:
DatabaseManagerFactory
,
@Named
(
"currentServer"
)
currentServer
:
String
):
DatabaseManager
{
return
factory
.
create
(
currentServer
)
}
}
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideFavoriteMessagesView
(
frag
:
FavoriteMessagesFragment
):
FavoriteMessagesView
{
fun
provideJob
()
=
Job
()
@Provides
@PerFragment
fun
provideLifecycleOwner
(
frag
:
FavoriteMessagesFragment
):
LifecycleOwner
{
return
frag
return
frag
}
}
@Provides
@PerFragment
fun
provideCancelStrategy
(
owner
:
LifecycleOwner
,
jobs
:
Job
):
CancelStrategy
{
return
CancelStrategy
(
owner
,
jobs
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/favoritemessages/di/FavoriteMessagesFragmentProvider.kt
View file @
84cc9a42
package
chat.rocket.android.
chatroom
.di
package
chat.rocket.android.
favoritemessages
.di
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.favoritemessages.ui.FavoriteMessagesFragment
import
chat.rocket.android.favoritemessages.ui.FavoriteMessagesFragment
...
...
app/src/main/java/chat/rocket/android/favoritemessages/presentation/FavoriteMessagesPresenter.kt
View file @
84cc9a42
...
@@ -2,26 +2,27 @@ package chat.rocket.android.favoritemessages.presentation
...
@@ -2,26 +2,27 @@ package chat.rocket.android.favoritemessages.presentation
import
chat.rocket.android.chatroom.uimodel.UiModelMapper
import
chat.rocket.android.chatroom.uimodel.UiModelMapper
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.ChatRoomsInteractor
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.getFavoriteMessages
import
chat.rocket.core.internal.rest.getFavoriteMessages
import
timber.log.Timber
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
import
javax.inject.Named
class
FavoriteMessagesPresenter
@Inject
constructor
(
class
FavoriteMessagesPresenter
@Inject
constructor
(
private
val
view
:
FavoriteMessagesView
,
private
val
view
:
FavoriteMessagesView
,
private
val
strategy
:
CancelStrategy
,
private
val
strategy
:
CancelStrategy
,
private
val
roomsInteractor
:
ChatRoomsInteractor
,
private
val
dbManager
:
DatabaseManager
,
@Named
(
"currentServer"
)
private
val
currentServer
:
String
,
private
val
mapper
:
UiModelMapper
,
private
val
mapper
:
UiModelMapper
,
val
serverInteractor
:
GetCurrentServerInteractor
,
val
factory
:
RocketChatClientFactory
val
factory
:
RocketChatClientFactory
)
{
)
{
private
val
serverUrl
=
serverInteractor
.
get
()
!!
private
val
client
:
RocketChatClient
=
factory
.
create
(
currentServer
)
private
val
client
=
factory
.
create
(
serverUrl
)
private
var
offset
:
Int
=
0
private
var
offset
:
Int
=
0
/**
/**
...
@@ -33,8 +34,9 @@ class FavoriteMessagesPresenter @Inject constructor(
...
@@ -33,8 +34,9 @@ class FavoriteMessagesPresenter @Inject constructor(
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
view
.
showLoading
()
view
.
showLoading
()
roomsInteractor
.
getById
(
serverUrl
,
roomId
)
?.
let
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
val
favoriteMessages
=
client
.
getFavoriteMessages
(
roomId
,
it
.
type
,
offset
)
val
favoriteMessages
=
client
.
getFavoriteMessages
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
)
val
messageList
=
mapper
.
map
(
favoriteMessages
.
result
,
asNotReversed
=
true
)
val
messageList
=
mapper
.
map
(
favoriteMessages
.
result
,
asNotReversed
=
true
)
view
.
showFavoriteMessages
(
messageList
)
view
.
showFavoriteMessages
(
messageList
)
offset
+=
1
*
30
offset
+=
1
*
30
...
...
app/src/main/java/chat/rocket/android/files/di/FilesFragmentModule.kt
View file @
84cc9a42
...
@@ -3,34 +3,54 @@ package chat.rocket.android.files.di
...
@@ -3,34 +3,54 @@ package chat.rocket.android.files.di
import
androidx.lifecycle.LifecycleOwner
import
androidx.lifecycle.LifecycleOwner
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.DatabaseManagerFactory
import
chat.rocket.android.files.presentation.FilesView
import
chat.rocket.android.files.presentation.FilesView
import
chat.rocket.android.files.ui.FilesFragment
import
chat.rocket.android.files.ui.FilesFragment
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
dagger.Module
import
dagger.Module
import
dagger.Provides
import
dagger.Provides
import
kotlinx.coroutines.experimental.Job
import
kotlinx.coroutines.experimental.Job
import
javax.inject.Named
@Module
@Module
class
FilesFragmentModule
{
class
FilesFragmentModule
{
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideJob
()
=
Job
()
fun
provideFilesView
(
frag
:
FilesFragment
):
FilesView
{
return
frag
}
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideLifecycleOwner
(
frag
:
FilesFragment
):
LifecycleOwner
{
@Named
(
"currentServer"
)
return
frag
fun
provideCurrentServer
(
currentServerInteractor
:
GetCurrentServerInteractor
):
String
{
return
currentServerInteractor
.
get
()
!!
}
}
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideCancelStrategy
(
owner
:
LifecycleOwner
,
jobs
:
Job
):
CancelStrategy
{
fun
provideDatabaseManager
(
return
CancelStrategy
(
owner
,
jobs
)
factory
:
DatabaseManagerFactory
,
@Named
(
"currentServer"
)
currentServer
:
String
):
DatabaseManager
{
return
factory
.
create
(
currentServer
)
}
}
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideFilesView
(
frag
:
FilesFragment
):
FilesView
{
fun
provideJob
()
=
Job
()
@Provides
@PerFragment
fun
provideLifecycleOwner
(
frag
:
FilesFragment
):
LifecycleOwner
{
return
frag
return
frag
}
}
@Provides
@PerFragment
fun
provideCancelStrategy
(
owner
:
LifecycleOwner
,
jobs
:
Job
):
CancelStrategy
{
return
CancelStrategy
(
owner
,
jobs
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/files/presentation/FilesPresenter.kt
View file @
84cc9a42
...
@@ -2,28 +2,29 @@ package chat.rocket.android.files.presentation
...
@@ -2,28 +2,29 @@ package chat.rocket.android.files.presentation
import
androidx.core.net.toUri
import
androidx.core.net.toUri
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.files.uimodel.FileUiModel
import
chat.rocket.android.files.uimodel.FileUiModel
import
chat.rocket.android.files.uimodel.FileUiModelMapper
import
chat.rocket.android.files.uimodel.FileUiModelMapper
import
chat.rocket.android.server.domain.ChatRoomsInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.getFiles
import
chat.rocket.core.internal.rest.getFiles
import
timber.log.Timber
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
import
javax.inject.Named
class
FilesPresenter
@Inject
constructor
(
class
FilesPresenter
@Inject
constructor
(
private
val
view
:
FilesView
,
private
val
view
:
FilesView
,
private
val
strategy
:
CancelStrategy
,
private
val
strategy
:
CancelStrategy
,
private
val
roomsInteractor
:
ChatRoomsInteracto
r
,
private
val
dbManager
:
DatabaseManage
r
,
private
val
mapper
:
FileUiModelMapper
,
@Named
(
"currentServer"
)
private
val
currentServer
:
String
,
val
serverInteractor
:
GetCurrentServerInteracto
r
,
private
val
mapper
:
FileUiModelMappe
r
,
val
factory
:
RocketChatClientFactory
val
factory
:
RocketChatClientFactory
)
{
)
{
private
val
serverUrl
=
serverInteractor
.
get
()
!!
private
val
client
:
RocketChatClient
=
factory
.
create
(
currentServer
)
private
val
client
=
factory
.
create
(
serverUrl
)
private
var
offset
:
Int
=
0
private
var
offset
:
Int
=
0
/**
/**
...
@@ -35,8 +36,8 @@ class FilesPresenter @Inject constructor(
...
@@ -35,8 +36,8 @@ class FilesPresenter @Inject constructor(
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
view
.
showLoading
()
view
.
showLoading
()
roomsInteractor
.
getById
(
serverUrl
,
roomId
)
?.
let
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
val
files
=
client
.
getFiles
(
roomId
,
it
.
type
,
offset
)
val
files
=
client
.
getFiles
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
)
,
offset
)
val
filesUiModel
=
mapper
.
mapToUiModelList
(
files
.
result
)
val
filesUiModel
=
mapper
.
mapToUiModelList
(
files
.
result
)
view
.
showFiles
(
filesUiModel
,
files
.
total
)
view
.
showFiles
(
filesUiModel
,
files
.
total
)
offset
+=
1
*
30
offset
+=
1
*
30
...
...
app/src/main/java/chat/rocket/android/members/di/MembersFragmentModule.kt
View file @
84cc9a42
...
@@ -4,19 +4,25 @@ import androidx.lifecycle.LifecycleOwner
...
@@ -4,19 +4,25 @@ import androidx.lifecycle.LifecycleOwner
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.DatabaseManagerFactory
import
chat.rocket.android.members.presentation.MembersNavigator
import
chat.rocket.android.members.presentation.MembersNavigator
import
chat.rocket.android.members.presentation.MembersView
import
chat.rocket.android.members.presentation.MembersView
import
chat.rocket.android.members.ui.MembersFragment
import
chat.rocket.android.members.ui.MembersFragment
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
dagger.Module
import
dagger.Module
import
dagger.Provides
import
dagger.Provides
import
kotlinx.coroutines.experimental.Job
import
kotlinx.coroutines.experimental.Job
import
javax.inject.Named
@Module
@Module
class
MembersFragmentModule
{
class
MembersFragmentModule
{
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideJob
()
=
Job
()
fun
membersView
(
frag
:
MembersFragment
):
MembersView
{
return
frag
}
@Provides
@Provides
@PerFragment
@PerFragment
...
@@ -24,10 +30,24 @@ class MembersFragmentModule {
...
@@ -24,10 +30,24 @@ class MembersFragmentModule {
@Provides
@Provides
@PerFragment
@PerFragment
fun
membersView
(
frag
:
MembersFragment
):
MembersView
{
@Named
(
"currentServer"
)
return
frag
fun
provideCurrentServer
(
currentServerInteractor
:
GetCurrentServerInteractor
):
String
{
return
currentServerInteractor
.
get
()
!!
}
@Provides
@PerFragment
fun
provideDatabaseManager
(
factory
:
DatabaseManagerFactory
,
@Named
(
"currentServer"
)
currentServer
:
String
):
DatabaseManager
{
return
factory
.
create
(
currentServer
)
}
}
@Provides
@PerFragment
fun
provideJob
()
=
Job
()
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideLifecycleOwner
(
frag
:
MembersFragment
):
LifecycleOwner
{
fun
provideLifecycleOwner
(
frag
:
MembersFragment
):
LifecycleOwner
{
...
...
app/src/main/java/chat/rocket/android/members/presentation/MembersPresenter.kt
View file @
84cc9a42
package
chat.rocket.android.members.presentation
package
chat.rocket.android.members.presentation
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.members.uimodel.MemberUiModel
import
chat.rocket.android.members.uimodel.MemberUiModel
import
chat.rocket.android.members.uimodel.MemberUiModelMapper
import
chat.rocket.android.members.uimodel.MemberUiModelMapper
import
chat.rocket.android.server.domain.ChatRoomsInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.getMembers
import
chat.rocket.core.internal.rest.getMembers
import
timber.log.Timber
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
import
javax.inject.Named
class
MembersPresenter
@Inject
constructor
(
class
MembersPresenter
@Inject
constructor
(
private
val
view
:
MembersView
,
private
val
view
:
MembersView
,
private
val
navigator
:
MembersNavigator
,
private
val
navigator
:
MembersNavigator
,
private
val
dbManager
:
DatabaseManager
,
@Named
(
"currentServer"
)
private
val
currentServer
:
String
,
private
val
strategy
:
CancelStrategy
,
private
val
strategy
:
CancelStrategy
,
private
val
roomsInteractor
:
ChatRoomsInteractor
,
private
val
mapper
:
MemberUiModelMapper
,
private
val
mapper
:
MemberUiModelMapper
,
val
serverInteractor
:
GetCurrentServerInteractor
,
val
factory
:
RocketChatClientFactory
val
factory
:
RocketChatClientFactory
)
{
)
{
private
val
serverUrl
=
serverInteractor
.
get
()
!!
private
val
client
:
RocketChatClient
=
factory
.
create
(
currentServer
)
private
val
client
:
RocketChatClient
=
factory
.
create
(
serverUrl
)
private
var
offset
:
Long
=
0
private
var
offset
:
Long
=
0
/**
* Loads all the chat room members for the given room id.
*
* @param roomId The id of the room to get chat room members from.
*/
fun
loadChatRoomsMembers
(
roomId
:
String
)
{
fun
loadChatRoomsMembers
(
roomId
:
String
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
view
.
showLoading
()
view
.
showLoading
()
roomsInteractor
.
getById
(
serverUrl
,
roomId
)
?.
let
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
val
members
=
client
.
getMembers
(
it
.
id
,
it
.
type
,
offset
,
60
)
val
members
=
client
.
getMembers
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
,
60
)
val
memberUiModels
=
mapper
.
mapToUiModelList
(
members
.
result
)
val
memberUiModels
=
mapper
.
mapToUiModelList
(
members
.
result
)
view
.
showMembers
(
memberUiModels
,
members
.
total
)
view
.
showMembers
(
memberUiModels
,
members
.
total
)
offset
+=
1
*
60L
offset
+=
1
*
60L
}.
ifNull
{
}.
ifNull
{
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server"
)
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server
.
"
)
}
}
}
catch
(
exception
:
RocketChatException
)
{
}
catch
(
exception
:
RocketChatException
)
{
exception
.
message
?.
let
{
exception
.
message
?.
let
{
...
@@ -52,12 +58,12 @@ class MembersPresenter @Inject constructor(
...
@@ -52,12 +58,12 @@ class MembersPresenter @Inject constructor(
}
}
fun
toMemberDetails
(
memberUiModel
:
MemberUiModel
)
{
fun
toMemberDetails
(
memberUiModel
:
MemberUiModel
)
{
val
avatarUri
=
memberUiModel
.
avatarUri
.
toString
()
navigator
.
toMemberDetails
(
val
realName
=
memberUiModel
.
realName
.
toString
()
memberUiModel
.
avatarUri
.
toString
(),
val
username
=
"@${memberUiModel.username}"
memberUiModel
.
realName
.
toString
(),
val
email
=
memberUiModel
.
email
?:
""
"@${memberUiModel.username}"
,
val
utcOffset
=
memberUiModel
.
utcOffset
.
toString
()
memberUiModel
.
email
?:
""
,
memberUiModel
.
utcOffset
.
toString
()
navigator
.
toMemberDetails
(
avatarUri
,
realName
,
username
,
email
,
utcOffset
)
)
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/pinnedmessages/di/PinnedMessagesFragmentModule.kt
View file @
84cc9a42
...
@@ -3,34 +3,54 @@ package chat.rocket.android.pinnedmessages.di
...
@@ -3,34 +3,54 @@ package chat.rocket.android.pinnedmessages.di
import
androidx.lifecycle.LifecycleOwner
import
androidx.lifecycle.LifecycleOwner
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.DatabaseManagerFactory
import
chat.rocket.android.pinnedmessages.presentation.PinnedMessagesView
import
chat.rocket.android.pinnedmessages.presentation.PinnedMessagesView
import
chat.rocket.android.pinnedmessages.ui.PinnedMessagesFragment
import
chat.rocket.android.pinnedmessages.ui.PinnedMessagesFragment
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
dagger.Module
import
dagger.Module
import
dagger.Provides
import
dagger.Provides
import
kotlinx.coroutines.experimental.Job
import
kotlinx.coroutines.experimental.Job
import
javax.inject.Named
@Module
@Module
class
PinnedMessagesFragmentModule
{
class
PinnedMessagesFragmentModule
{
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideJob
()
=
Job
()
fun
providePinnedMessagesView
(
frag
:
PinnedMessagesFragment
):
PinnedMessagesView
{
return
frag
}
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideLifecycleOwner
(
frag
:
PinnedMessagesFragment
):
LifecycleOwner
{
@Named
(
"currentServer"
)
return
frag
fun
provideCurrentServer
(
currentServerInteractor
:
GetCurrentServerInteractor
):
String
{
return
currentServerInteractor
.
get
()
!!
}
}
@Provides
@Provides
@PerFragment
@PerFragment
fun
provideCancelStrategy
(
owner
:
LifecycleOwner
,
jobs
:
Job
):
CancelStrategy
{
fun
provideDatabaseManager
(
return
CancelStrategy
(
owner
,
jobs
)
factory
:
DatabaseManagerFactory
,
@Named
(
"currentServer"
)
currentServer
:
String
):
DatabaseManager
{
return
factory
.
create
(
currentServer
)
}
}
@Provides
@Provides
@PerFragment
@PerFragment
fun
providePinnedMessagesView
(
frag
:
PinnedMessagesFragment
):
PinnedMessagesView
{
fun
provideJob
()
=
Job
()
@Provides
@PerFragment
fun
provideLifecycleOwner
(
frag
:
PinnedMessagesFragment
):
LifecycleOwner
{
return
frag
return
frag
}
}
@Provides
@PerFragment
fun
provideCancelStrategy
(
owner
:
LifecycleOwner
,
jobs
:
Job
):
CancelStrategy
{
return
CancelStrategy
(
owner
,
jobs
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/pinnedmessages/presentation/PinnedMessagesPresenter.kt
View file @
84cc9a42
...
@@ -2,26 +2,27 @@ package chat.rocket.android.pinnedmessages.presentation
...
@@ -2,26 +2,27 @@ package chat.rocket.android.pinnedmessages.presentation
import
chat.rocket.android.chatroom.uimodel.UiModelMapper
import
chat.rocket.android.chatroom.uimodel.UiModelMapper
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.ChatRoomsInteractor
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.getPinnedMessages
import
chat.rocket.core.internal.rest.getPinnedMessages
import
timber.log.Timber
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
import
javax.inject.Named
class
PinnedMessagesPresenter
@Inject
constructor
(
class
PinnedMessagesPresenter
@Inject
constructor
(
private
val
view
:
PinnedMessagesView
,
private
val
view
:
PinnedMessagesView
,
private
val
strategy
:
CancelStrategy
,
private
val
strategy
:
CancelStrategy
,
private
val
roomsInteractor
:
ChatRoomsInteractor
,
private
val
dbManager
:
DatabaseManager
,
@Named
(
"currentServer"
)
private
val
currentServer
:
String
,
private
val
mapper
:
UiModelMapper
,
private
val
mapper
:
UiModelMapper
,
val
serverInteractor
:
GetCurrentServerInteractor
,
val
factory
:
RocketChatClientFactory
val
factory
:
RocketChatClientFactory
)
{
)
{
private
val
serverUrl
=
serverInteractor
.
get
()
!!
private
val
client
:
RocketChatClient
=
factory
.
create
(
currentServer
)
private
val
client
=
factory
.
create
(
serverUrl
)
private
var
offset
:
Int
=
0
private
var
offset
:
Int
=
0
/**
/**
...
@@ -33,8 +34,9 @@ class PinnedMessagesPresenter @Inject constructor(
...
@@ -33,8 +34,9 @@ class PinnedMessagesPresenter @Inject constructor(
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
view
.
showLoading
()
view
.
showLoading
()
roomsInteractor
.
getById
(
serverUrl
,
roomId
)
?.
let
{
dbManager
.
getRoom
(
roomId
)
?.
let
{
val
pinnedMessages
=
client
.
getPinnedMessages
(
roomId
,
it
.
type
,
offset
)
val
pinnedMessages
=
client
.
getPinnedMessages
(
roomId
,
roomTypeOf
(
it
.
chatRoom
.
type
),
offset
)
val
messageList
=
mapper
.
map
(
pinnedMessages
.
result
,
asNotReversed
=
true
)
val
messageList
=
mapper
.
map
(
pinnedMessages
.
result
,
asNotReversed
=
true
)
view
.
showPinnedMessages
(
messageList
)
view
.
showPinnedMessages
(
messageList
)
offset
+=
1
*
30
offset
+=
1
*
30
...
...
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