I was wondering if the following is considered good practice.
I am creating mulitple Dot instance. A Dot instance is a value object
containing x,y, color, diameter fields.
I draw each created Dot to a view:
<code>
canvas.drawCircle( dot.getX(),dot.getY(),dot.getDiameter
(),paint);
</code>
Now i want all the Dots to listen to a certain event, lets say that i
want to click a button and move all the Dots.
What i do is in the Dot constructor i add this code:
<code>
IntentFilter intentFilter = new IntentFilter
("org.dadata.demo.SEND_TO_REACTOR");
Appcontext.registerReceiver(this, intentFilter);
.......
@Override
public void onReceive(Context context, Intent intent) {
this.x += 5;
}
</code>
Then from my button i send the intent :
<code>
intent.setAction("org.dadata.demo.SEND_TO_REACTOR");
getApplicationContext().sendBroadcast(intent);
View.invalidate();
</code>
I am wondering if someone could give me some feedback on this. Is it
expensive for instance, and are there better ways to achive the same.
Thank you,
Jiri
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---