Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
deskscreen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kowis-projects
deskscreen
Commits
5441fb3c
Commit
5441fb3c
authored
Mar 18, 2019
by
David
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A bit of optimization on calculating when something has cleared
parent
58c42686
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
src/main/kotlin/is/kow/deskscreen/ticker/TickerView.kt
src/main/kotlin/is/kow/deskscreen/ticker/TickerView.kt
+14
-5
No files found.
src/main/kotlin/is/kow/deskscreen/ticker/TickerView.kt
View file @
5441fb3c
...
...
@@ -173,7 +173,8 @@ class MarqueeView : View() {
private
val
logger
=
KotlinLogging
.
logger
{}
private
val
OFFSET
=
5.0
//Amount of space between entries!
private
val
activeTicks
=
ConcurrentLinkedQueue
<
TickerEntry
<
Node
>>()
//This might not need to be threadsafe, only one thing is adding/removing it
data class
ActiveTick
(
val
entry
:
TickerEntry
<
Node
>,
var
cleared
:
Boolean
=
false
)
private
val
activeTicks
=
ConcurrentLinkedQueue
<
ActiveTick
>()
//This might not need to be threadsafe, only one thing is adding/removing it
private
val
queuedTicks
=
ConcurrentLinkedQueue
<
TickerEntry
<
Node
>>()
//This one does, multiple threads!
private
val
pane
:
Pane
=
pane
()
...
...
@@ -215,7 +216,14 @@ class MarqueeView : View() {
fun
lastOneCleared
():
Boolean
{
//Determine if the last entry in the activeQueue has cleared
val
last
=
activeTicks
.
last
()
return
last
.
content
.
layoutBounds
.
width
+
last
.
content
.
layoutX
+
OFFSET
<=
root
.
width
if
(!
last
.
cleared
){
//Only do the math one time, well up to many times, but it might be cleared, and then clean it out
val
entry
=
last
.
entry
if
(
entry
.
content
.
layoutBounds
.
width
+
entry
.
content
.
layoutX
+
OFFSET
<=
root
.
width
)
{
last
.
cleared
=
true
}
}
return
last
.
cleared
}
val
subscriptions
=
HashMap
<
TickerEntry
<
Node
>,
Disposable
>()
...
...
@@ -230,13 +238,14 @@ class MarqueeView : View() {
if
(
newTickerEntry
!=
null
)
{
//Then just put it into the active queue, so it will start processing like normal
newTickerEntry
.
content
.
layoutX
=
root
.
prefWidth
//Where to start
activeTicks
.
add
(
newTickerEntry
)
activeTicks
.
add
(
ActiveTick
(
newTickerEntry
)
)
root
.
add
(
newTickerEntry
.
content
)
//this is where it gets added
//But I never remove them!?!? UH OH They get removed later
}
}
//Something isn't working out right here.
activeTicks
.
forEach
{
entry
->
activeTicks
.
forEach
{
active
->
val
entry
=
active
.
entry
val
content
=
entry
.
content
//I don't intend to bounce this
...
...
@@ -251,7 +260,7 @@ class MarqueeView : View() {
logger
.
debug
(
"ANIMATED ${entry.title} COMPLETELY OUT THE PANEL!"
)
//Now I ned to figure out how to remove it
entry
.
content
.
removeFromParent
()
//Is this legit?
activeTicks
.
remove
(
entry
)
//no longer here, shouldn't ruin the loop
activeTicks
.
remove
(
active
)
//no longer here, shouldn't ruin the loop
if
(
subscriptions
.
containsKey
(
entry
))
{
subscriptions
.
remove
(
entry
)
!!
.
dispose
()
//This should cancel it
logger
.
debug
(
"disposing observable for ${entry.title}"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment