ComposeActivity: fix crash

main
Alibek Omarov 5 years ago
parent ba7cbcffc3
commit 703d423f82
  1. 9
      app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt

@ -291,12 +291,13 @@ class ComposeActivity : BaseActivity(),
} }
} }
private var hasNoAttachmentLimits: Boolean = false
private fun reenableAttachments() { private fun reenableAttachments() {
// in case of we already had disabled attachments // in case of we already had disabled attachments
// but got information about extension later // but got information about extension later
enableButton(composeAddMediaButton, true, true) enableButton(composeAddMediaButton, true, true)
if(viewModel.poll == null) enablePollButton(viewModel.poll == null)
enablePollButton(true) hasNoAttachmentLimits = true
} }
private fun subscribeToUpdates(mediaAdapter: MediaPreviewAdapter) { private fun subscribeToUpdates(mediaAdapter: MediaPreviewAdapter) {
@ -335,11 +336,11 @@ class ComposeActivity : BaseActivity(),
updateScheduleButton() updateScheduleButton()
} }
combineOptionalLiveData(viewModel.media, viewModel.poll) { media, poll -> combineOptionalLiveData(viewModel.media, viewModel.poll) { media, poll ->
val active = viewModel.instanceParams.value!!.hasNoAttachmentLimits || (poll == null val active = (hasNoAttachmentLimits) || (poll == null
&& media!!.size != 4 && media!!.size != 4
&& media.firstOrNull()?.type != QueuedMedia.Type.VIDEO) && media.firstOrNull()?.type != QueuedMedia.Type.VIDEO)
enableButton(composeAddMediaButton, active, active) enableButton(composeAddMediaButton, active, active)
enablePollButton(media.isNullOrEmpty()) enablePollButton(active && poll == null)
}.subscribe() }.subscribe()
viewModel.uploadError.observe { viewModel.uploadError.observe {
displayTransientError(R.string.error_media_upload_sending) displayTransientError(R.string.error_media_upload_sending)

Loading…
Cancel
Save