From 91a0e729db32c3cdbaf3cc32678c9853c44c16b8 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Thu, 15 Aug 2019 18:49:06 -0500 Subject: [PATCH] Fix MarkdownPresenterImpl Kotlin errors --- .../simplemarkdown/presentation/MarkdownPresenterImpl.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.kt b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.kt index 113d8b5..b8b2823 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.kt +++ b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.kt @@ -53,7 +53,7 @@ constructor(private val errorHandler: ErrorHandler) : MarkdownPresenter { listener: MarkdownPresenter.FileLoadedListener?, replaceCurrentFile: Boolean ) { - val fileLoader = { + fileHandler.post { val tmpFile = MarkdownFile() if (tmpFile.load(fileName, `in`)) { if (listener != null) { @@ -76,7 +76,6 @@ constructor(private val errorHandler: ErrorHandler) : MarkdownPresenter { listener?.onError() } } - fileHandler.post(fileLoader) } override fun newFile(newName: String) { @@ -119,12 +118,11 @@ constructor(private val errorHandler: ErrorHandler) : MarkdownPresenter { } override fun onMarkdownEdited(markdown: String?) { - markdown = markdown - val generateMarkdown = { + this.markdown = markdown ?: file?.content ?: "" + fileHandler.post { val currentPreviewView = previewView currentPreviewView?.updatePreview(generateHTML(null)) } - fileHandler.post(generateMarkdown) } override fun generateHTML(markdown: String?): String {