mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed media list when VFS is enabled + removed debug logs and trying something else instead
This commit is contained in:
parent
30927ac6db
commit
945fd709d4
4 changed files with 31 additions and 34 deletions
|
|
@ -245,16 +245,14 @@ class ConversationEventAdapter :
|
|||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: EventLogModel, newItem: EventLogModel): Boolean {
|
||||
return if (oldItem.isEvent && newItem.isEvent) {
|
||||
true
|
||||
} else if (!oldItem.isEvent && !newItem.isEvent) {
|
||||
return if (!oldItem.isEvent && !newItem.isEvent) {
|
||||
val oldModel = (oldItem.model as MessageModel)
|
||||
val newModel = (newItem.model as MessageModel)
|
||||
oldModel.statusIcon.value == newModel.statusIcon.value &&
|
||||
newModel.isRead &&
|
||||
oldModel.groupedWithNextMessage.value == newModel.groupedWithNextMessage.value &&
|
||||
oldModel.groupedWithPreviousMessage.value == newModel.groupedWithPreviousMessage.value
|
||||
} else {
|
||||
false
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,6 +185,10 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
|||
|
||||
private val dataObserver = object : AdapterDataObserver() {
|
||||
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
|
||||
if (positionStart == adapter.itemCount - itemCount) {
|
||||
adapter.notifyItemChanged(positionStart - 1) // For grouping purposes
|
||||
}
|
||||
|
||||
if (viewModel.isUserScrollingUp.value == true) {
|
||||
Log.i(
|
||||
"$TAG [$itemCount] events have been loaded but user was scrolling up in conversation, do not scroll"
|
||||
|
|
@ -203,10 +207,6 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
|||
)
|
||||
}
|
||||
scrollToFirstUnreadMessageOrBottom()
|
||||
|
||||
if (positionStart > 0) {
|
||||
adapter.notifyItemChanged(positionStart - 1) // For grouping purposes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -567,23 +567,6 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
|
||||
@WorkerThread
|
||||
private fun addEvents(eventLogs: Array<EventLog>) {
|
||||
// TODO FIXME: remove later, for debug purposes
|
||||
Log.e("$TAG Adding ${eventLogs.size} events to conversation")
|
||||
for (event in eventLogs) {
|
||||
if (event.type == EventLog.Type.ConferenceChatMessage) {
|
||||
val message = event.chatMessage
|
||||
val describe = if (message != null) {
|
||||
LinphoneUtils.getTextDescribingMessage(message)
|
||||
} else {
|
||||
"Failed to get message for event log [$event]"
|
||||
}
|
||||
Log.e("$TAG Adding chat message event: [$describe]")
|
||||
} else {
|
||||
Log.e("$TAG Adding [${event.type}] event: [$event]")
|
||||
}
|
||||
}
|
||||
// End of TODO FIXME
|
||||
|
||||
val list = arrayListOf<EventLogModel>()
|
||||
list.addAll(eventsList)
|
||||
val lastEvent = list.lastOrNull()
|
||||
|
|
@ -659,16 +642,10 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
val groupedEventLogs = arrayListOf<EventLog>()
|
||||
|
||||
if (history.size == 1) {
|
||||
// TODO FIXME: remove later, for debug purposes
|
||||
Log.e("$TAG Adding a single event to conversation")
|
||||
|
||||
// If there is a single event, improve processing speed by skipping grouping tasks
|
||||
val event = history[0]
|
||||
eventsList.addAll(processGroupedEvents(arrayListOf(event)))
|
||||
} else {
|
||||
// TODO FIXME: remove later, for debug purposes
|
||||
Log.e("$TAG Processing list of events (${history.size}) to add to conversation")
|
||||
|
||||
for (event in history) {
|
||||
if (filter.isNotEmpty()) {
|
||||
if (event.type == EventLog.Type.ConferenceChatMessage) {
|
||||
|
|
|
|||
|
|
@ -115,11 +115,33 @@ class MediaListViewerFragment : GenericFragment() {
|
|||
|
||||
viewPager.registerOnPageChangeCallback(pageListener)
|
||||
|
||||
val index = it.indexOfFirst { model ->
|
||||
var index = it.indexOfFirst { model ->
|
||||
model.file == path
|
||||
}
|
||||
Log.i("$TAG Path [$path] is at index [$index]")
|
||||
|
||||
if (index == -1) {
|
||||
Log.i(
|
||||
"$TAG Path [$path] not found in media list (expected if VFS is enabled), trying using file name"
|
||||
)
|
||||
val fileName = File(path).name
|
||||
val underscore = fileName.indexOf("_")
|
||||
val originalFileName = if (underscore != -1 && underscore < 2) {
|
||||
fileName.subSequence(underscore, fileName.length)
|
||||
} else {
|
||||
fileName
|
||||
}
|
||||
index = it.indexOfFirst { model ->
|
||||
model.file.endsWith(originalFileName)
|
||||
}
|
||||
if (index == -1) {
|
||||
Log.w(
|
||||
"$TAG Path [$path] not found either using filename [$originalFileName] match"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val position = if (index == -1) {
|
||||
Log.e("$TAG File [$path] not found, using latest one available instead!")
|
||||
count - 1
|
||||
} else {
|
||||
index
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue