New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/particles view update #375
Feature/particles view update #375
Conversation
Takt.stock(getApplication()) | ||
.seat(Seat.BOTTOM_RIGHT) | ||
.interval(250) | ||
.listener(fps -> Log.w("DroidKaigi", "heartbeat() called with: fps = [" + fps + "]")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Android Lint] reported by reviewdog 🐶
Error: Using 'Log' instead of 'Timber' [LogNotTimber]
…actually un-comment the normal way. some type and grammar fix
Thank you for contribution! Interesting! |
Thanks. Let me fix the license and conflict in few minutes :D |
FYI @konifar I would like to ask @roana0229 (author of this View) to review this if possible. My change may conflict with the expected behaviour in some unexpected ways. |
@@ -226,6 +226,9 @@ dependencies { | |||
debugCompile 'com.tomoima.debot:debot:2.0.2' | |||
releaseCompile 'com.tomoima.debot:debot-no-op:2.0.2' | |||
|
|||
// fps, track the frame rate of animation view. | |||
compile 'jp.wasabeef:takt:1.0.3' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆒
@@ -52,12 +54,24 @@ protected void onCreate(Bundle savedInstanceState) { | |||
protected void onStart() { | |||
super.onStart(); | |||
loadSessionsForCache(); | |||
|
|||
// Starting new Activity normally will not destroy this Activity, so set this up in start/stop cycle | |||
// TODO remove it if you hate it ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it. So let's remove this TODO
comment 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just push a commit to remove the TODO :D.
|
||
private class Line { | ||
/** | ||
* A Pair of 'Particles' whose centers can be 'linked to each other ... Called 'Line'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! 👍
Looks good. Thanks 😃 |
…eim/conference-app-2017 into feature/particles-view-update
@konifar my latest commit cause a failed build on circleci, checking it, turns out |
Sorry, currently CI is not stable. I'll work on it tonight. |
Thanks, just take your time :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for improving performance! Awesome 👍
I learned from this PR. 😄
|
||
private class Line { | ||
/** | ||
* A Pair of 'Particles' whose centers can be 'linked to each other ... Called 'Line'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! 👍
+ (point[3] - point[1]) * (point[3] - point[1]) | ||
)); | ||
void draw(Canvas canvas, Paint paint) { | ||
if (!first.shouldBeLinked(LINK_HEXAGON_DISTANCE, second)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, shouldBeLinked
is not necessary if first particle compare second particle in draw
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roana0229 not really get your full point, but do you mean to call shouldBeLinked
from ParticlesAnimationView#onDraw
instead of here? It will end up removing the need of using "Line" object (a Line is actually just a bridge between 2 particles :D).
Yesterday I thought about something like:
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
for (int i = 0, size = particles.size(); i < size; i++) {
particles.get(i).draw(canvas, paint);
}
// for (int i = 0, size = lines.size(); i < size; i++) {
// lines.get(i).draw(canvas, paint);
//}
for (int i = 0; i < particles.size() - 1; i++) {
for (int j = i + 1; j < particles.size(); j++) {
if (particles.get(i).shouldBeLinked(LINK_HEXAGON_DISTANCE, particles.get(j))) {
// TODO draw, use the code from Line
}
}
}
}
I think what you mean is the following:
// ParticlesAnimationView
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
for (int i = 0, size = particles.size(); i < size; i++) {
particles.get(i).draw(canvas, paint);
}
for (int i = 0, size = lines.size(); i < size; i++) {
if (lines.get(i).shouldDraw()) {
lines.get(i).draw(canvas, paint);
}
}
}
// ParticlesAnimationView$Line
///// shouldDraw simply returns the comparison
boolean shouldDraw() {
return first.shouldBeLinked(LINK_HEXAGON_DISTANCE, second);
}
Neither of above gain any huge impact (but the later looks clean and better, in fact :D). For now I would like to keep current version (this PR is pretty huge now) and maybe another PR from you if you really want to :p. So it is up to you ^^.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that the following code
was good.
For now I would like to keep current version (this PR is pretty huge now) and maybe another PR from you
OK! 😄
LGTM 👍 |
Thanks for improvement! |
IMPORTANT:
I commented out some lines in SplashActivity to make the sample, please read it and un-comment for normal behaviour.Issue
ParticlesAnimationView
is beautifully implemented. But it comes with some trade off as follow:createLines(particles)
uses Stream which will allocate new Iterators each calls. Furthermore it unnecessarily generates new Lines.createLines(particles)
will draw each line twice, which is not so good.drawLines
to draw a single line is not so good too.Overview: what I did
isShouldLinked
is actuallyshouldBeLinked
I think :D.Discussion: so it worth the change?
Screenshot