Skip to content
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

Leave the method onDraw clean #2

Open
ppamorim opened this issue Jan 17, 2017 · 0 comments
Open

Leave the method onDraw clean #2

ppamorim opened this issue Jan 17, 2017 · 0 comments

Comments

@ppamorim
Copy link

Hi Harjot.

I would like to say to leave this method clean, try to move any instantiation of values or heavy operations to out of the scope of this element. You can reduce the CPU and battery usage doing this. This method was build just to read values and draw on canvas.

Of course, this is not a problem:

void onDraw(Canvas canvas) {
  canvas.draw(x + diff, y + diff, paint)
}

You can do it, the performance will be not affected when the calculation of values is not that heavy.
To create some values based on the bounds of its view, you can use the method onLayout(...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant