mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed broken media viewer
This commit is contained in:
parent
598ac6cbd3
commit
940937a9b7
3 changed files with 22 additions and 1 deletions
|
|
@ -28,6 +28,7 @@ import org.linphone.core.Factory
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.chat.model.FileModel
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class ConversationDocumentsListViewModel @UiThread constructor() : ViewModel() {
|
||||
companion object {
|
||||
|
|
@ -107,7 +108,13 @@ class ConversationDocumentsListViewModel @UiThread constructor() : ViewModel() {
|
|||
coreContext.postOnCoreThread {
|
||||
val list = arrayListOf<FileModel>()
|
||||
if (::chatRoom.isInitialized) {
|
||||
Log.i(
|
||||
"$TAG Loading document contents for conversation [${LinphoneUtils.getChatRoomId(
|
||||
chatRoom
|
||||
)}]"
|
||||
)
|
||||
val documents = chatRoom.documentContents
|
||||
Log.i("$TAG [${documents.size}] documents have been fetched")
|
||||
for (documentContent in documents) {
|
||||
val path = documentContent.filePath.orEmpty()
|
||||
val name = documentContent.name.orEmpty()
|
||||
|
|
@ -119,6 +126,7 @@ class ConversationDocumentsListViewModel @UiThread constructor() : ViewModel() {
|
|||
list.add(model)
|
||||
}
|
||||
}
|
||||
Log.i("$TAG [${documents.size}] documents have been processed")
|
||||
}
|
||||
documentsList.postValue(list)
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.linphone.core.Factory
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.chat.model.FileModel
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class ConversationMediaListViewModel @UiThread constructor() : ViewModel() {
|
||||
companion object {
|
||||
|
|
@ -111,7 +112,13 @@ class ConversationMediaListViewModel @UiThread constructor() : ViewModel() {
|
|||
coreContext.postOnCoreThread {
|
||||
val list = arrayListOf<FileModel>()
|
||||
if (::chatRoom.isInitialized) {
|
||||
Log.i(
|
||||
"$TAG Loading media contents for conversation [${LinphoneUtils.getChatRoomId(
|
||||
chatRoom
|
||||
)}]"
|
||||
)
|
||||
val media = chatRoom.mediaContents
|
||||
Log.i("$TAG [${media.size}] media have been fetched")
|
||||
for (mediaContent in media) {
|
||||
val path = mediaContent.filePath.orEmpty()
|
||||
val name = mediaContent.name.orEmpty()
|
||||
|
|
@ -123,6 +130,7 @@ class ConversationMediaListViewModel @UiThread constructor() : ViewModel() {
|
|||
list.add(model)
|
||||
}
|
||||
}
|
||||
Log.i("$TAG [${media.size}] media have been processed")
|
||||
}
|
||||
mediaList.postValue(list)
|
||||
|
||||
|
|
|
|||
|
|
@ -102,12 +102,17 @@ class MediaListViewerFragment : GenericFragment() {
|
|||
val chatRoom = sharedViewModel.displayedChatRoom
|
||||
viewModel.findChatRoom(chatRoom, localSipUri, remoteSipUri)
|
||||
|
||||
viewModel.chatRoomFoundEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
viewModel.loadMediaList()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.mediaList.observe(viewLifecycleOwner) {
|
||||
val count = it.size
|
||||
Log.i(
|
||||
"$TAG Found [$count] media for conversation with local SIP URI [$localSipUri] and remote SIP URI [$remoteSipUri]"
|
||||
)
|
||||
|
||||
adapter = MediaListAdapter(this, viewModel)
|
||||
viewPager = binding.mediaViewPager
|
||||
viewPager.adapter = adapter
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue