forked from mirrors/linphone-iphone
Reload CollectionView (messages) when a single item has been downloaded
This commit is contained in:
parent
d1ae0af1f3
commit
d739052d1a
3 changed files with 30 additions and 7 deletions
|
|
@ -18,7 +18,7 @@ class ChatConversationTableViewModel: ControlsViewModel {
|
|||
|
||||
var chatRoom: ChatRoom? = nil
|
||||
|
||||
var nbEventDisplayed = MutableLiveData<Int>(20)
|
||||
var refreshIndexPath = MutableLiveData<Int>(0)
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
|
|
@ -68,4 +68,8 @@ class ChatConversationTableViewModel: ControlsViewModel {
|
|||
func eventTypeIsOfInterestForOne(toOneRoom type: EventLogType) -> Bool {
|
||||
return type.rawValue == LinphoneEventLogTypeConferenceChatMessage.rawValue || type.rawValue == LinphoneEventLogTypeConferenceEphemeralMessageEnabled.rawValue || type.rawValue == LinphoneEventLogTypeConferenceEphemeralMessageDisabled.rawValue || type.rawValue == LinphoneEventLogTypeConferenceEphemeralMessageLifetimeChanged.rawValue
|
||||
}
|
||||
|
||||
func reloadCollectionViewCell(){
|
||||
refreshIndexPath.value! += 1
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
}
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
|
||||
|
||||
ChatConversationTableViewModel.sharedModel.nbEventDisplayed.observe { index in
|
||||
self.collectionView.reloadData()
|
||||
}
|
||||
|
||||
ChatConversationTableViewModel.sharedModel.refreshIndexPath.observe { index in
|
||||
self.collectionView.reloadData()
|
||||
}
|
||||
|
||||
|
||||
collectionView.isUserInteractionEnabled = true
|
||||
|
|
@ -155,7 +155,7 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
}
|
||||
|
||||
if let event = ChatConversationTableViewModel.sharedModel.getMessage(index: indexPath.row){
|
||||
cell.configure(event: event)
|
||||
cell.configure(event: event, selfIndexPathConfigure: indexPath)
|
||||
|
||||
if (event.chatMessage != nil){
|
||||
cell.onLongClickOneClick {
|
||||
|
|
@ -377,4 +377,8 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
message.chatRoom?.deleteMessage(message: message)
|
||||
collectionView.reloadData()
|
||||
}
|
||||
|
||||
public func reloadCollectionViewCell(indexPath: IndexPath){
|
||||
collectionView.reloadItems(at: [indexPath])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
super.prepareForReuse()
|
||||
}
|
||||
|
||||
func configure(event: EventLog) {
|
||||
func configure(event: EventLog, selfIndexPathConfigure: IndexPath) {
|
||||
chatMessage = event.chatMessage
|
||||
addMessageDelegate()
|
||||
if event.chatMessage != nil {
|
||||
|
|
@ -1221,6 +1221,21 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
imagesGridContentCollection[indexTransferProgress] = content
|
||||
imagesGridURLCollection[indexTransferProgress] = (URL(string: content.filePath)!)
|
||||
imagesGridCollectionView[indexTransferProgress] = getImageFrom(content.getCobject, filePath: content.filePath, forReplyBubble: true)!
|
||||
|
||||
|
||||
if (imagesGridCollectionView.count <= 1){
|
||||
if let imageMessage = createThumbnailOfVideoFromFileURL(videoURL: content.filePath){
|
||||
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
|
||||
if (imageVideoViewBubble.image != nil && imagesGridCollectionView.count <= 1){
|
||||
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
|
||||
}
|
||||
} else if let imageMessage = UIImage(named: content.filePath){
|
||||
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
|
||||
if (imageViewBubble.image != nil && imagesGridCollectionView.count <= 1){
|
||||
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
collectionViewImagesGrid.reloadItems(at: [IndexPath(row: indexTransferProgress, section: 0)])
|
||||
indexTransferProgress = -1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue