Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

fix receiver registered at onAttach#1286

Merged
WonderCsabo merged 2 commits into
androidannotations:developandroidannotations/androidannotations:developfrom
dodgex:1132_fix_receiver_registered_at_onAttachCopy head branch name to clipboard
Mar 22, 2015
Merged

fix receiver registered at onAttach#1286
WonderCsabo merged 2 commits into
androidannotations:developandroidannotations/androidannotations:developfrom
dodgex:1132_fix_receiver_registered_at_onAttachCopy head branch name to clipboard

Conversation

@dodgex

@dodgex dodgex commented Dec 23, 2014

Copy link
Copy Markdown
Member

see #1132

@dodgex

dodgex commented Dec 23, 2014

Copy link
Copy Markdown
Member Author

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.

@dodgex

dodgex commented Dec 23, 2014

Copy link
Copy Markdown
Member Author

what i have thought about is adding some kind of class extending IntentFilter that has an constructor with two arrays for actions and dataSchemes that we don't have to use those fields.

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?

@WonderCsabo

Copy link
Copy Markdown
Member

only caveat on this implementation is that the IntentFilter fields will get a own copy if they have the same registerAt value.

Can you add an example?

@dodgex

dodgex commented Dec 24, 2014

Copy link
Copy Markdown
Member Author

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).

the sample:
https://github.com/excilys/androidannotations/blob/develop/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/receiver/FragmentWithReceiver.java

before this change there was only one IntentFilter field as all Receiver had the same actions and dataSchemes (empty)

private final IntentFilter intentFilter1_ = new IntentFilter();

but after this change, also the registerAt is taken care of and that results in 4 such fields in this sample. this could more or less easily be changed to only 2 fields by modifying the hashCode and equals of the IntentFilterData class that was introduced with the dataSchemes update. but for now i decided to keep these function with a default/non specialized behaviour.

@dodgex

dodgex commented Dec 24, 2014

Copy link
Copy Markdown
Member Author

with the suggested helper class this issue could go away and we wont have any IntentFilter fields at all.

@WonderCsabo

Copy link
Copy Markdown
Member

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.

@WonderCsabo

Copy link
Copy Markdown
Member

Please rebase this.

@dodgex

dodgex commented Dec 28, 2014

Copy link
Copy Markdown
Member Author

rebased.

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member Author

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

@WonderCsabo

Copy link
Copy Markdown
Member

Can you add a test?

@dodgex

dodgex commented Jan 8, 2015

Copy link
Copy Markdown
Member Author

yeah.

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops. done

WonderCsabo added a commit that referenced this pull request Mar 22, 2015
…onAttach

fix receiver registered at onAttach
@WonderCsabo WonderCsabo merged commit 5e72dfe into androidannotations:develop Mar 22, 2015
@WonderCsabo WonderCsabo added this to the 3.3 milestone Mar 22, 2015
@WonderCsabo

Copy link
Copy Markdown
Member

FInally merged, thanks!

@dodgex dodgex deleted the 1132_fix_receiver_registered_at_onAttach branch March 25, 2015 08:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.