Closed Piasy closed 7 years ago
Thanks your feedback!
Yes, you're right, now cannot use at multi modules.
Annotation processor options (like FragmentArgs) is most simple solution.
But as you pointed out, you need specific helper to bind (e.g. FooFragmentAutoBundle.bind(this)
).
Yep, but at least it's better. Can we add this feature?
Another solution is following.
First, in library project modules,
android {
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
className 'com.yatatsu.autobundle.processor.AutoBundleProcessor'
arguments = [ autoBundleAsLibrary : 'com.example.library' ]
}
}
}
}
and in app's build gradle,
android {
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
className 'com.yatatsu.autobundle.processor.AutoBundleProcessor'
arguments = [ subDispatchers : 'com.example.library.AutoBundleBindingDispatcher' ]
}
}
}
}
the code generated would be...
public final class AutoBundleBindingDispatcher {
final com.example.library.AutoBundleBindingDispatcher subDispatcher1 = new AutoBundleBindingDispatcher()
public void bind(@NonNull Object target, @NonNull Bundle args) {
if (target instanceof ExampleActivity) {
ExampleActivityAutoBundle.bind((ExampleActivity)target, args);
return;
// bind by library's dispatcher
subDispatcher1.bind(target, args);
}
}
What do you think this? Is it too much option?
That's cool, and it's one time configuration, totally ok, IMO.
Thanks, I will do it in a few days.
Now released 4.1.0, library module is supported! Please Follow README#use-in-library-module, try it.
Thats awesome! Thanks!
if use this way,but dagger2 can not use ??
I don't try with dagger2, but it may work. If you have problem, please report it.
@yatatsu yes,I am use dagger2 and this library in library module, if I set javaCompileOptions { annotationProcessorOptions { className 'com.yatatsu.autobundle.processor.AutoBundleProcessor' arguments = [ autoBundleAsLibrary : 'com.example.library' ] } }
but can not compile dagger2, I think is not you library problem,but I dont Know how to do
@shingohu I got it. Maybe DSL is wrong.
Try this.
javaCompileOptions {
annotationProcessorOptions {
arguments = [ autoBundleAsLibrary : 'com.example.library' ]
}
}
I will fix README. Thanks!
I updated README!
Thanks!😁😁
Currently if I use auto-bundle both at library module and app module, there will be multiple
AutoBundleBindingDispathcer
, which will cause the build fail:FragmentArgs support library module, but when using it in library module, we need to call the fragment-specific builder's
injectArguments
method, callFragmentArgs.inject
doesn't work, that's not a bad idea, could auto-bundle add this feature too?