If you have a standard Android Studio installation:
Just run the install script at the root of this repository:
./install.sh
Manual installation:
Just copy all 5 directories
BaseCleanArchitectureTemplateKotlin
DataTemplateKotlin
DomainTemplateKotlin
PresenterActivityTemplateKotlin
PresenterFragmentTemplateKotlin
PresenterServiceTemplateKotlin
PresenterBroadcastReceiverTemplateKotlin
and paste to $ANDROID_STUDIO_FOLDER$/Contents/plugins/android/lib/templates/activities/
For Windows:
Just copy all 5 directories
BaseCleanArchitectureTemplateKotlin
DataTemplateKotlin
DomainTemplateKotlin
PresenterActivityTemplateKotlin
PresenterFragmentTemplateKotlin
PresenterServiceTemplateKotlin
PresenterBroadcastReceiverTemplateKotlin
and paste to $ANDROID_STUDIO_FOLDER$\plugins\android\lib\templates\activities\
How to Use
1. Generate Base template
First of all, create the base hierarchy and classes using CleanArchitectureTemplate from the root package folder. This needs to be done only once per project:
Or if you create a new project, please select CleanArchitectureTemplate on this screen.
Android Studio 3.3 maybe unsupport to add original Template to Create a new Project Selection..
Next, you set project config.
Application Class Name -> Set Root ApplicationClass Name
Create kotlin src dir? -> Please check if you have not previously created the kotlin folder
Need Retrofit2? -> Please check this when using Retrofit2
Use Swagger? -> Please check this if the Retrofit API was created by Swagger(RxJava2 used)
When all settings are completed click the Finish button!!
2.FIX build.gradles!!
Completed to generate Base classes, it will added FIXME_merge_to_build.gradle files.
Open these files and merge to original build.gradle files.
End of merge, execute gradle sync!!
Use CleanArchitecture Template
Some templates need your work.
DataTemplateKotlin
This template create data-layer template.
This template will add DataSourceClass and DataRepositoryClass.
And then, please see DataSourceClass.The following notice is written there.
/* FIXME MUST add below method to RepositoryModules */
// @Binds abstract fun bindSomeDataSource(repository: SomeRepository):SomeDataSource
So, Copy @Binds abstract fun bindSomeDataSource(repository: SomeRepository):SomeDataSource to RepositoryModules
This Layer Provide Interface to domain.
DomainTemplateKotlin
This template create domain-layer template.
This template will add IoUsecaseClass or InputOnlyUseCaseClass or OutputOnlyUseCaseClass or SimpleUseCaseClass.
This Layer Provide Bussiness Logic and connect DataLayer to PresentationLayer.
PresenterActivityTemplateKotlin
This template create presenter-layer template.
This template will add ContractClass, ModuleClass, PresenterViewModelClass, ActivityClass, FragmentClass and fragment.xml.
And then, please see ModuleClass. The following notice is written there.
/* FIXME MUST add below method to BindingModules */
// @ContributesAndroidInjector(modules = [SomeModule::class]) @ActivityScope abstract fun contributeSomeActivityInjector(): SomeActivity
So, Copy @ContributesAndroidInjector(modules = [SomeModule::class]) @ActivityScope abstract fun contributeSomeActivityInjector(): SomeActivity to BindingModules.
This Layer Provides UserInterface(Activity & Fragment).
And presenterClass communicate domain-layer.
PresenterFragmentTemplateKotlin
This template create presenter-layer template.
This template will add ContractClass, PresenterViewModelClass, FragmentClass and fragment.xml.
And then, please see FragmentClass. The following notice is written there.
/* FIXME MUST add below method to Parent Activity's Module */
// @Binds @IntoMap @ViewModelKey(SomePresenterViewModel::class) abstract fun bindSomePresenterViewModel(viewModel: SomePresenterViewModel): ViewModel
// @ContributesAndroidInjector abstract fun contributeSomeFragment():SomeFragment
So, Copy @Binds @IntoMap @ViewModelKey(SomePresenterViewModel::class) abstract fun bindSomePresenterViewModel(viewModel: SomePresenterViewModel): ViewModel and @ContributesAndroidInjector abstract fun contributeSomeFragment():SomeFragment to Parent activity's module.
This Layer Provides UserInterface(Fragment).
And presenterClass communicate domain-layer.
PresenterServiceTemplateKotlin
This template create presenter-layer template.
This template will add ContractClass, ModuleClass, PresenterClass and ServiceClass.
And then, please see ModuleClass. The following notice is written there.
/* FIXME MUST add below method to BindingModules */
// @ContributesAndroidInjector(modules = [SomeServiceModule::class]) abstract fun contributeSomeServiceServiceInjector(): SomeServiceService
So, Copy @ContributesAndroidInjector(modules = [SomeServiceModule::class]) abstract fun contributeSomeServiceServiceInjector(): SomeServiceService to BindingModules.
This Layer Provides UserInterface(Service).
And presenterClass communicate domain-layer.
PresenterBroadCastReceiverTemplateKotlin
This template create presenter-layer template.
This template will add ContractClass, ModuleClass, PresenterClass and ReceiverClass.
And then, please see ModuleClass. The following notice is written there.
/* FIXME MUST add below method to BindingModules */
// @ContributesAndroidInjector(modules = [SomeReceiverModule::class]) abstract fun contributeSomeReceiverReceiverInjector(): SomeReceiverReceiver
So, Copy @ContributesAndroidInjector(modules = [SomeReceiverModule::class]) abstract fun contributeSomeReceiverReceiverInjector(): SomeReceiverReceiver to BindingModules.
This Layer Provides UserInterface(BroadCastReceiver).
And presenterClass communicate domain-layer.
Copyright 2017- kiuchi keisuke
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
请发表评论