Reputation: 16603
I'd like to refresh a specific row in a ListView (a custom class) when something happens in the ListView fragment or other (nested) fragment.
I'm currently using this pattern (News
is a custom class that NewsView
is displaying):
NewsView
constructor:
"UPDATE_NEWS_ITEM"
News
item and compare item IDNews
item as Serializable Extra.This means that each and every NewsView
has to deserialize the News
from the Intent and therefore this approach has a bit of an overhead.
On the other hand, I could register a broadcast receiver for each NewsView
with IntentFilter like "UPDATE_NEWS_ITEM_154"
, where 154 is the ID of the item. Then the broadcast intent would reach only one receiver and it seems more effective.
Is there any downside to registering so many broadcast receivers? Or Android will happily cope with potentially hundred of them?
Upvotes: 1
Views: 122
Reputation: 15379
If you are broadcasting only within your application, consider using intents through LocalBroadcastManager
instead of broadcasting intents with an intent-filter in your manifest.
As far as I know those translate directly to function calls and do not pass through the OS queues.
More about LocalBroadcastManager here
Upvotes: 1