-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix receiver registered at onAttach #1286
fix receiver registered at onAttach #1286
Conversation
|
only caveat on this implementation is that the IntentFilter fields will get a own copy if they have the same registerAt value. but i think that should not be a big problem. |
|
what i have thought about is adding some kind of class extending eg. private final IntentFilter intentFilter2_ = new IntentFilter();
intentFilter2_.addAction("org.androidannotations.ACTION_1");
getActivity().registerReceiver(onActionOnAttachReceiver_, intentFilter2_);could become getActivity().registerReceiver(onActionOnAttachReceiver_, new ExtendedIntentFilter(new String[] {"org.androidannotations.ACTION_1"}));
// or like this, but that would make the generation code more complex.
getActivity().registerReceiver(onActionOnAttachReceiver_, new ExtendedIntentFilter("org.androidannotations.ACTION_1"));@yDelouis @WonderCsabo thoughts? |
Can you add an example? |
|
first let me start with a small correction. they get an own IntentFilter if they don't have the same registerAt value (but actions and schemes are the same). before this change there was only one IntentFilter field as all Receiver had the same private final IntentFilter intentFilter1_ = new IntentFilter();but after this change, also the |
|
with the suggested helper class this issue could go away and we wont have any IntentFilter fields at all. |
|
I am not sure we should add "new" API classes for this. We should keep the generated code understandable, e.g. using only plain Android code in it. |
|
Please rebase this. |
|
rebased. |
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 think using polymorphism and method overrides is a better design. Maybe you could create this method in EComponentHolder which just returns init body, and override it in EFragmentHolder to return the needed block?
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.
@dodgex did you miss this?
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.
yeah. sorry. i'll update the PR
|
Can you add a test? |
|
yeah. |
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.
Remove the Test suffix from the method names.
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.
whoops. done
…onAttach fix receiver registered at onAttach
|
FInally merged, thanks! |
see #1132