window.window.ui.unsetState(MainWindow.ITEM_HAS_CATEGORY)
}
- var mimeType: String? = null
- var content: String? = null
- if(item.contentHtml != null) {
- content = item.contentHtml
- mimeType = "text/html"
- } else if(item.contentText != null) {
- content = item.contentText
- mimeType = "text/plain"
- } else if(item.description != null) {
- content = item.description
- mimeType = "text/html"
- } else {
- content = ""
- mimeType = "text/plain"
- }
-
if(item.isBookmark) {
starred.setIntValue(1)
} else {
starred.setIntValue(0)
}
-
- webview.loadContent(item.link, content, mimeType, "utf-8")
+ val content = item.getContent()
+ webview.loadContent(item.link, content.text, content.type, "utf-8")
tabview.setIntValue(1)
preview.setIntValue(0) // reset preview toggle button
fun togglePreview() {
currentItem?.let { item ->
if(preview.intValue() == 0) {
- // TODO: codedup with selectItem, can we fix this?
- var mimeType: String? = null
- var content: String? = null
- if(item.contentHtml != null) {
- content = item.contentHtml
- mimeType = "text/html"
- } else if(item.contentText != null) {
- content = item.contentText
- mimeType = "text/plain"
- } else if(item.description != null) {
- content = item.description
- mimeType = "text/html"
- } else {
- content = ""
- mimeType = "text/plain"
- }
- webview.loadContent(item.link, content, mimeType, "utf-8")
+ val content = item.getContent()
+ webview.loadContent(item.link, content.text, content.type, "utf-8")
} else {
webview.loadUrl(item.link)
}
var feedName: String? = null
var feedUrl: String? = null
+
+ fun getContent(): Content {
+ contentHtml?.let {
+ return Content(it, "text/html")
+ }
+ contentText?.let {
+ return Content(it, "text/plain")
+ }
+ description?.let {
+ return Content(it, "text/html")
+ }
+ return Content("", "text/plain")
+ }
}
\ No newline at end of file