johncarl81 / transfuse

:syringe: Transfuse - A Dependency Injection and Integration framework for Google Android
http://androidtransfuse.org/
Apache License 2.0
220 stars 28 forks source link

configurable naming strategy #68

Open ghost opened 10 years ago

ghost commented 10 years ago

I'd like to be able to name my Activities Activity without having to reference ActivityActivity in code... it would be cool if transfuse could use a configurable naming strategy... So ultimately I could end up with MyActivity -> MyTransfuseActivity and MyFragment -> MyTransfuseFragment ... or something like that, without spelling out said strategy on every single component.

johncarl81 commented 10 years ago

Great idea and this may go hand in hand with different manifest generation strategies... ie: you having to manually add the activity to the manifest. Also, this would be a nice extension to add in the plugin environment I've been envisioning.

Have you tried using the Components utility? This gives you a mapping of all generated components in the system in the hope that you wouldn't have to reference a class that doen't exist before compile time:

Components.get(MyTransfuseActivity.class) -> MyTransfuseActivityActivity.class

Looks like this is missing from the docs.

ghost commented 10 years ago

Ah, I had not played with that yet...

It doesn't help too much when I need to inject the concrete version of a component.. and it doesn't look like it helps me get the strategy for an activity component.

johncarl81 commented 10 years ago

Right, referencing the Intent Strategies is one of the few times when you need to use the generated classes directly.

How are you injecting the concrete version of a component?

ghost commented 10 years ago

When I want to inject some number of fragments into an activity so they can be swapped in and out based on my navigation widgets I am doing it by the concrete component name... is there a better way?

johncarl81 commented 10 years ago

Fragments do need to be referenced directly as well currently... but I wonder if we could make a Fragments utility to instantiate the related generated code instead of having you do it, ie:

Fragments.create(MyTransfuseFragment.class) -> new instance of MyTransfuseFragmentFragment

thoughts?

ghost commented 10 years ago

I think that would be helpful in most cases... aside from the injection I am treating them as their base class (or at least I could be... )