Lazyload listview cell elements
This commit is contained in:
parent
f5126e2d9e
commit
892058c47e
@ -39,7 +39,8 @@ private class EntryCell(
|
||||
private val hostServices: HostServices,
|
||||
) : ListCell<DictionaryEntryFx?>() {
|
||||
|
||||
private val labelHeadword = Label().apply {
|
||||
private val labelHeadword by lazy {
|
||||
Label().apply {
|
||||
styleClass.add("headword")
|
||||
styleProperty().bind(
|
||||
Bindings.concat(
|
||||
@ -49,8 +50,10 @@ private class EntryCell(
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val labelDefinition = Label().apply {
|
||||
private val labelDefinition by lazy {
|
||||
Label().apply {
|
||||
styleClass.add("definition")
|
||||
styleProperty().bind(
|
||||
Bindings.concat(
|
||||
@ -62,8 +65,10 @@ private class EntryCell(
|
||||
visibleProperty().bind(config.searchResults.shouldShowDefinition)
|
||||
managedProperty().bind(config.searchResults.shouldShowDefinition)
|
||||
}
|
||||
}
|
||||
|
||||
private val labelPronunciation = Label().apply {
|
||||
private val labelPronunciation by lazy {
|
||||
Label().apply {
|
||||
styleClass.add("pronunciation")
|
||||
styleProperty().bind(
|
||||
Bindings.concat(
|
||||
@ -75,15 +80,20 @@ private class EntryCell(
|
||||
visibleProperty().bind(config.searchResults.shouldShowPronunciation)
|
||||
managedProperty().bind(config.searchResults.shouldShowPronunciation)
|
||||
}
|
||||
}
|
||||
|
||||
private val flowPane = FlowPane(labelHeadword, labelPronunciation).apply {
|
||||
private val flowPane by lazy {
|
||||
FlowPane(labelHeadword, labelPronunciation).apply {
|
||||
hgap = FLOW_PANE_HGAP
|
||||
rowValignment = VPos.BASELINE
|
||||
}
|
||||
}
|
||||
|
||||
private val root = VBox(flowPane, labelDefinition).apply {
|
||||
private val root by lazy {
|
||||
VBox(flowPane, labelDefinition).apply {
|
||||
styleClass.add("search-result")
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
text = null
|
||||
|
@ -36,11 +36,16 @@ private class SentenceCell(
|
||||
private val hostServices: HostServices,
|
||||
) : ListCell<SentenceFx?>() {
|
||||
|
||||
private val labelSentence = Label().apply {
|
||||
private val labelSentence by lazy {
|
||||
Label().apply {
|
||||
styleClass.add("sentence")
|
||||
isWrapText = true
|
||||
}
|
||||
private val root = VBox(labelSentence)
|
||||
}
|
||||
|
||||
private val root by lazy {
|
||||
VBox(labelSentence)
|
||||
}
|
||||
|
||||
init {
|
||||
text = null
|
||||
@ -50,6 +55,7 @@ private class SentenceCell(
|
||||
super.updateItem(sentence, empty)
|
||||
if (empty || sentence == null) {
|
||||
graphic = null
|
||||
contextMenu = null
|
||||
} else {
|
||||
labelSentence.textProperty().bind(
|
||||
Bindings.createStringBinding(
|
||||
|
Loading…
Reference in New Issue
Block a user