You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
It would be a big problem, if it is the only place. E.g. I want to make my tests independent from AA, or drop AA at all in the future (don't believe that it is possible for me, but still :)).
Maybe it is better to have just one class for constructions like:
FragmentA fragment = GeneratedClasses.create(FragmentA.class);
Oh, true. But rewriting manifest is much simplier. Moreover, actualy I'm not sure that there is some real need for declare them in the manifest - gradle already processes manifest and generating new one - there is no problem to inject correct components during this step.
I'm also currently thinking of a kin of factory for generated class based on the original one. I'd like to get ride of direct call to generated class in the code (ie: MyActivity_.intent(...).startActivity())
Yep. I'm not sure that there is some way to avoid generated intent builders, but maybe we will get some clue while implementing other classes. So, I'll try to implement some cases in order to look deeper into the problem and make a PR, ok?
It also will be useful, if the factory class will have some way to set a strategy of instantiation. In this case it will be easier to mock up objects for testing.
I know that @jeremiemartinez and @fredszaq worked on a way to have a cleaner injection mechanism. They're also based on a kind of factory to do this. It may be great to merge these two features.
Yeah, looks great! But actually I would like to do it in another way - iterate over array while looking for creator is not the best idea, map of class to creator would be better. I'll take a closer look on this week, it is a very good point to start at. Thanks.
I started to work on this too, but was stuck with IntentBuilders of generated activities.
I used @Artyomcool way of doing this, with static methods of a factory class and reflexion.
You can see the it here.
I'll try to implement the same thing but without reflections. Looks like I need to make @fredszaq and @yDelouis approaches work together to achieve this.
As for IntentBuilders I don't see the direct way. But what if reimplement @Extra annotation for working with POJO? I mean something like that:
@EExtra
class Extra {
String stringExtra;
int intExtra;
}
@EActivity
class SomeActivity extends Activity {
@Extra
Extra extra;
}
Don't forget we have to keep retro-compatibility with AA < 3.1
So we're not going to drop the inner intent builder in generated classes. At least, not now.
That being said, in your suggested solution you're still using IntentBuilder<Extra> which is a generated inner-class. With this, you're not using the generated class but the generated inner-class. Not what we're looking for :)
I'll try to find a solution this week, but I'm afraid there is no elegant solution. Right now, I only thinking of using one generated class (the factory) or using reflection in the factory.
Hey, I'm not suggesting to drop compatibility :) Just to add a new way for creating intents, without removing the old one.
And IntentBuilder<Extra> is not supposed to be generated class, it is suppose to be an interface with setExtra method.
Your solution is way better than what I tried to propose in #431
I love this idea.
And I second the less reflection, the better approach: offering a feature that improves maintainability (and fixes some Eclipse quirks) but impairs performance for the end user is a real dilemma :)
No. This is about creating one builder class which can create instances of the generated classes, so we do not have to reference generated code. See the OP and initial discussion. BTW #1017 is little bit wants the same. We should clarify the scope of this issue and the other.
BTW, we could modify the manifest file easily in Gradle and Maven builds by replacing the Activity/Service names with the generated ones. With this and the builder, we cold completely get rid of "_"s. I think that would be cool.
Another idea: we could override startActivity etc. methods, and use the common builder in that. That way the user just have to call startActivity(this, new Intent(Annotated.class), and startActivity will modify the Intent to use the Annotated_.class. However in that way the user could not use the generated setter methods for @Extra etc, and requires more boilerplate then the current solution.
Activity
yDelouis commentedon Jan 13, 2014
You will still have to declare generated class in
AndroidManifest.xml.Artyomcool commentedon Jan 13, 2014
Oh, true. But rewriting manifest is much simplier. Moreover, actualy I'm not sure that there is some real need for declare them in the manifest - gradle already processes manifest and generating new one - there is no problem to inject correct components during this step.
Artyomcool commentedon Mar 17, 2014
Moreover, you don't need to declare generated class in manifest in situations:
E.g. it is awkward:
Much better would be something like this:
What do you think? If you do like such way, I'll try to implement it.
DayS commentedon Mar 17, 2014
I'm also currently thinking of a kin of factory for generated class based on the original one. I'd like to get ride of direct call to generated class in the code (ie:
MyActivity_.intent(...).startActivity())Artyomcool commentedon Mar 17, 2014
Yep. I'm not sure that there is some way to avoid generated intent builders, but maybe we will get some clue while implementing other classes. So, I'll try to implement some cases in order to look deeper into the problem and make a PR, ok?
Artyomcool commentedon Mar 17, 2014
It also will be useful, if the factory class will have some way to set a strategy of instantiation. In this case it will be easier to mock up objects for testing.
DayS commentedon Mar 17, 2014
I know that @jeremiemartinez and @fredszaq worked on a way to have a cleaner injection mechanism. They're also based on a kind of factory to do this. It may be great to merge these two features.
fredszaq commentedon Mar 17, 2014
Indeed both ideas seems very much alike, you can take a look at https://github.com/fredszaq/androidannotations/tree/inject for the work we've been doing on injection.
In any case, not having to explicitly use a generated class in java code seems to be a good thing !
Artyomcool commentedon Mar 17, 2014
Yeah, looks great! But actually I would like to do it in another way - iterate over array while looking for creator is not the best idea, map of class to creator would be better. I'll take a closer look on this week, it is a very good point to start at. Thanks.
yDelouis commentedon Mar 17, 2014
I started to work on this too, but was stuck with
IntentBuildersof generated activities.I used @Artyomcool way of doing this, with static methods of a factory class and reflexion.
You can see the it here.
Artyomcool commentedon Mar 18, 2014
I'll try to implement the same thing but without reflections. Looks like I need to make @fredszaq and @yDelouis approaches work together to achieve this.
As for
IntentBuildersI don't see the direct way. But what if reimplement@Extraannotation for working with POJO? I mean something like that:This allows us to make generic intent builder:
It is just an idea, so, tell me if I'm missing something.
DayS commentedon Mar 18, 2014
Don't forget we have to keep retro-compatibility with AA < 3.1
So we're not going to drop the inner intent builder in generated classes. At least, not now.
That being said, in your suggested solution you're still using
IntentBuilder<Extra>which is a generated inner-class. With this, you're not using the generated class but the generated inner-class. Not what we're looking for :)I'll try to find a solution this week, but I'm afraid there is no elegant solution. Right now, I only thinking of using one generated class (the factory) or using reflection in the factory.
Artyomcool commentedon Mar 18, 2014
Hey, I'm not suggesting to drop compatibility :) Just to add a new way for creating intents, without removing the old one.
And
IntentBuilder<Extra>is not supposed to be generated class, it is suppose to be an interface withsetExtramethod.WonderCsabo commentedon Apr 7, 2014
@fredszaq what are your custom injection does actually? Can it help #918 for example? Are you planning to finish the feature?
PerfectCarl commentedon Apr 7, 2014
Your solution is way better than what I tried to propose in #431
I love this idea.
And I second the less reflection, the better approach: offering a feature that improves maintainability (and fixes some Eclipse quirks) but impairs performance for the end user is a real dilemma :)
6 remaining items
PerfectCarl commentedon May 28, 2014
@jeremiemartinez Could you provide us a example of code using your feature?
PerfectCarl commentedon May 30, 2014
I built @jeremiemartinez inject branch.
So far, this what I could understand:
@Createsand@Creator@EApplicationhas been modified to take a list of creatorSo you create a Creator interface
that you reference in your application
and then you get to use the
CreatorFacadethat let you create enhanced beansNote that the old
@Beanwork also and the generated code will use the newCreatorFacadeclass.Here's the complete test project (with generated classes).
The feature is pretty neat, unfortunately it doesn't work for the bulk of my use cases:
EFragmentMyActivity.classtoMyActivity_.classconversion that are used when you open a new activity.That being said those features can be added :)
WonderCsabo commentedon May 30, 2014
Since Dagger now can be used in conjunction with AA, we should provide integratation with it and let Dagger inject our
@EBeans.BTW, this injection thing should be in a separate issue, it has little to do with builder classes.
DayS commentedon May 31, 2014
Tell me if I'm wrong but this issue should be closed now that #994 has been merged. Am I right ?
WonderCsabo commentedon May 31, 2014
No. This is about creating one builder class which can create instances of the generated classes, so we do not have to reference generated code. See the OP and initial discussion. BTW #1017 is little bit wants the same. We should clarify the scope of this issue and the other.
DayS commentedon Jun 2, 2014
Right, but I think this feature will be included in the other PR in order to handle your case 4 (ie: using EBean in non-enhanced classes).
WonderCsabo commentedon Jun 9, 2015
@Artyomcool this is the same as #1017 am i right?
WonderCsabo commentedon Jun 9, 2015
BTW, we could modify the manifest file easily in Gradle and Maven builds by replacing the Activity/Service names with the generated ones. With this and the builder, we cold completely get rid of "_"s. I think that would be cool.
WonderCsabo commentedon Jun 9, 2015
Another idea: we could override
startActivityetc. methods, and use the common builder in that. That way the user just have to callstartActivity(this, new Intent(Annotated.class), andstartActivitywill modify theIntentto use theAnnotated_.class. However in that way the user could not use the generated setter methods for@Extraetc, and requires more boilerplate then the current solution.