Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PlayWallDesktop
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PlayWall
PlayWallDesktop
Commits
fe4ac7bc
Commit
fe4ac7bc
authored
Feb 2, 2019
by
Tobias Ullerich
Browse files
Options
Downloads
Patches
Plain Diff
Remove duplicated code in ModernDesignAnimator
parent
355edace
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
PlayWall/src/main/java/de/tobias/playpad/design/ModernDesignAnimator.java
+15
-29
15 additions, 29 deletions
...n/java/de/tobias/playpad/design/ModernDesignAnimator.java
with
15 additions
and
29 deletions
PlayWall/src/main/java/de/tobias/playpad/design/ModernDesignAnimator.java
+
15
−
29
View file @
fe4ac7bc
...
...
@@ -24,43 +24,16 @@ public class ModernDesignAnimator {
private
static
HashMap
<
Integer
,
Timeline
>
timelines
=
new
HashMap
<>();
public
static
void
animateFade
(
IPadViewController
padViewController
,
FadeableColor
startColor
,
FadeableColor
endColor
,
Duration
duration
)
{
int
index
=
padViewController
.
getPad
().
getPosition
();
if
(
timelines
.
containsKey
(
index
))
{
timelines
.
get
(
index
).
stop
();
}
ChangeListener
<
FadeableColor
>
fadeListener
=
(
observable
,
oldValue
,
newValue
)
->
padViewController
.
getView
().
setStyle
(
"-fx-background-color: "
+
newValue
.
toString
()
+
";"
);
ObjectProperty
<
FadeableColor
>
backgroundColor
=
new
SimpleObjectProperty
<>();
backgroundColor
.
addListener
(
fadeListener
);
Timeline
timeline
=
new
Timeline
(
new
KeyFrame
(
Duration
.
seconds
(
0
),
new
KeyValue
(
backgroundColor
,
startColor
)),
new
KeyFrame
(
duration
,
new
KeyValue
(
backgroundColor
,
endColor
)));
timeline
.
playFromStart
();
timeline
.
setOnFinished
(
event
->
{
backgroundColor
.
removeListener
(
fadeListener
);
padViewController
.
getView
().
setStyle
(
""
);
timelines
.
remove
(
index
);
});
// Memory
timelines
.
put
(
index
,
timeline
);
animate
(
padViewController
,
timeline
,
backgroundColor
);
}
public
static
void
animateWarn
(
IPadViewController
padViewController
,
FadeableColor
startColor
,
FadeableColor
endColor
,
Duration
duration
)
{
int
index
=
padViewController
.
getPad
().
getPosition
();
if
(
timelines
.
containsKey
(
index
))
{
timelines
.
get
(
index
).
stop
();
}
ChangeListener
<
FadeableColor
>
fadeListener
=
(
observable
,
oldValue
,
newValue
)
->
padViewController
.
getView
().
setStyle
(
"-fx-background-color: "
+
newValue
.
toString
()
+
";"
);
ObjectProperty
<
FadeableColor
>
backgroundColor
=
new
SimpleObjectProperty
<>();
backgroundColor
.
addListener
(
fadeListener
);
Timeline
timeline
=
new
Timeline
(
new
KeyFrame
(
Duration
.
seconds
(
0
),
new
KeyValue
(
backgroundColor
,
startColor
)),
new
KeyFrame
(
Duration
.
seconds
(
0.125
),
new
KeyValue
(
backgroundColor
,
startColor
)),
...
...
@@ -69,11 +42,24 @@ public class ModernDesignAnimator {
timeline
.
setAutoReverse
(
true
);
timeline
.
setCycleCount
((
int
)
(
duration
.
toSeconds
()
/
0.625
));
animate
(
padViewController
,
timeline
,
backgroundColor
);
}
private
static
void
animate
(
IPadViewController
padViewController
,
Timeline
timeline
,
ObjectProperty
<
FadeableColor
>
objectProperty
)
{
int
index
=
padViewController
.
getPad
().
getPosition
();
if
(
timelines
.
containsKey
(
index
))
{
timelines
.
get
(
index
).
stop
();
}
ChangeListener
<
FadeableColor
>
fadeListener
=
(
observable
,
oldValue
,
newValue
)
->
padViewController
.
getView
().
setStyle
(
"-fx-background-color: "
+
newValue
.
toString
()
+
";"
);
objectProperty
.
addListener
(
fadeListener
);
timeline
.
playFromStart
();
timeline
.
setOnFinished
(
event
->
{
backgroundColor
.
removeListener
(
fadeListener
);
objectProperty
.
removeListener
(
fadeListener
);
padViewController
.
getView
().
setStyle
(
""
);
timelines
.
remove
(
index
);
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment