forked from upstream-mirrors/quik
Show conversation title in GalleryActivity
This commit is contained in:
@@ -35,13 +35,14 @@ class GalleryActivity : QkActivity<GalleryViewModel>(), GalleryView {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.gallery_activity)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
title = ""
|
||||
viewModel.bindView(this)
|
||||
}
|
||||
|
||||
override fun render(state: GalleryState) {
|
||||
toolbar.setVisible(state.navigationVisible)
|
||||
|
||||
title = state.title
|
||||
|
||||
if (image.drawable == null) {
|
||||
GlideApp.with(this).load(state.imagePath).into(image)
|
||||
}
|
||||
|
||||
@@ -20,5 +20,6 @@ package presentation.feature.gallery
|
||||
|
||||
data class GalleryState(
|
||||
val navigationVisible: Boolean = true,
|
||||
val title: String = "",
|
||||
val imagePath: String = ""
|
||||
)
|
||||
@@ -37,13 +37,19 @@ class GalleryViewModel(intent: Intent) : QkViewModel<GalleryView, GalleryState>(
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
|
||||
disposables += Flowable.just(intent)
|
||||
val partIdFlowable = Flowable.just(intent)
|
||||
.map { it.getLongExtra("partId", 0L) }
|
||||
.filter { partId -> partId != 0L }
|
||||
|
||||
disposables += partIdFlowable
|
||||
.mapNotNull { partId -> messageRepo.getPart(partId) }
|
||||
.mapNotNull { part -> part.image }
|
||||
.doOnNext { path -> newState { it.copy(imagePath = path) } }
|
||||
.subscribe()
|
||||
.subscribe { path -> newState { it.copy(imagePath = path) } }
|
||||
|
||||
disposables += partIdFlowable
|
||||
.mapNotNull { partId -> messageRepo.getMessageForPart(partId) }
|
||||
.mapNotNull { message -> messageRepo.getConversation(message.threadId) }
|
||||
.subscribe { conversation -> newState { it.copy(title = conversation.getTitle()) } }
|
||||
}
|
||||
|
||||
override fun bindView(view: GalleryView) {
|
||||
|
||||
Reference in New Issue
Block a user