mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 21:48:50 +03:00
More cleanup
This commit is contained in:
parent
345e8a0679
commit
816301bf8d
1 changed files with 7 additions and 11 deletions
|
@ -119,33 +119,29 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmen
|
||||||
val inMemoryData = intent.getParcelableArrayListExtra<AttachmentData>(EXTRA_IN_MEMORY_DATA)
|
val inMemoryData = intent.getParcelableArrayListExtra<AttachmentData>(EXTRA_IN_MEMORY_DATA)
|
||||||
if (inMemoryData != null) {
|
if (inMemoryData != null) {
|
||||||
val sourceProvider = dataSourceFactory.createProvider(inMemoryData, room)
|
val sourceProvider = dataSourceFactory.createProvider(inMemoryData, room)
|
||||||
val index = inMemoryData.indexOfFirst { it.eventId == args.eventId }
|
initialIndex = inMemoryData.indexOfFirst { it.eventId == args.eventId }
|
||||||
initialIndex = index
|
|
||||||
sourceProvider.interactionListener = this
|
sourceProvider.interactionListener = this
|
||||||
setSourceProvider(sourceProvider)
|
setSourceProvider(sourceProvider)
|
||||||
this.currentSourceProvider = sourceProvider
|
this.currentSourceProvider = sourceProvider
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
pager2.setCurrentItem(index, false)
|
pager2.setCurrentItem(initialIndex, false)
|
||||||
// The page change listener is not notified of the change...
|
// The page change listener is not notified of the change...
|
||||||
pager2.post {
|
pager2.post {
|
||||||
onSelectedPositionChanged(index)
|
onSelectedPositionChanged(initialIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val events = room?.getAttachmentMessages()
|
val events = room?.getAttachmentMessages().orEmpty()
|
||||||
?: emptyList()
|
initialIndex = events.indexOfFirst { it.eventId == args.eventId }
|
||||||
val index = events.indexOfFirst { it.eventId == args.eventId }
|
|
||||||
initialIndex = index
|
|
||||||
|
|
||||||
val sourceProvider = dataSourceFactory.createProvider(events)
|
val sourceProvider = dataSourceFactory.createProvider(events)
|
||||||
sourceProvider.interactionListener = this
|
sourceProvider.interactionListener = this
|
||||||
setSourceProvider(sourceProvider)
|
setSourceProvider(sourceProvider)
|
||||||
this.currentSourceProvider = sourceProvider
|
this.currentSourceProvider = sourceProvider
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
pager2.setCurrentItem(index, false)
|
pager2.setCurrentItem(initialIndex, false)
|
||||||
// The page change listener is not notified of the change...
|
// The page change listener is not notified of the change...
|
||||||
pager2.post {
|
pager2.post {
|
||||||
onSelectedPositionChanged(index)
|
onSelectedPositionChanged(initialIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue