-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from alhazmy13/develop
- First Commit
- Loading branch information
Showing
13 changed files
with
351 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0"?> | ||
<globals> | ||
<global id="hasNoActionBar" type="boolean" value="false" /> | ||
<global id="parentActivityClass" value="" /> | ||
<global id="simpleLayoutName" value="${layoutName}" /> | ||
<global id="excludeMenu" type="boolean" value="true" /> | ||
<global id="generateActivityTitle" type="boolean" value="false" /> | ||
<#include "../common/common_globals.xml.ftl" /> | ||
</globals> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0"?> | ||
<recipe> | ||
<#include "../common/recipe_manifest.xml.ftl" /> | ||
|
||
<#if generateLayout> | ||
<#include "../common/recipe_simple.xml.ftl" /> | ||
<open file="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" /> | ||
</#if> | ||
|
||
<instantiate from="root/src/app_package/SimpleActivity.java.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/presentation/${activityClass}.java" /> | ||
|
||
<instantiate from="root/src/app_package/SimplePresenter.java.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/presentation/${presenterClass}.java" /> | ||
|
||
<instantiate from="root/src/app_package/SimpleView.java.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/presentation/${viewInterface}.java" /> | ||
|
||
<#if generateDataLayer> | ||
<instantiate from="root/src/app_package/SimpleService.java.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/data/${serviceClass}.java" /> | ||
|
||
<instantiate from="root/src/app_package/SimpleRepository.java.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/data/${repositoryInterface}.java" /> | ||
</#if> | ||
|
||
|
||
<#if generateModelLayer> | ||
<instantiate from="root/src/app_package/SimpleRepositoryImpl.java.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/model/${repositoryImplClass}.java" /> | ||
|
||
<instantiate from="root/src/app_package/SimpleRetroiftService.java.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/model/${retrofitService}.java" /> | ||
</#if> | ||
|
||
<#if generateModelLayer> | ||
<instantiate from="root/src/app_package/SimpleModel.java.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/model/model/${modelClass}.java" /> | ||
|
||
</#if> | ||
|
||
|
||
|
||
<open file="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /> | ||
</recipe> |
20 changes: 20 additions & 0 deletions
20
ActivityClean Architecture/root/src/app_package/SimpleActivity.java.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ${packageName}.presentation; | ||
|
||
import ${superClassFqcn}; | ||
import android.os.Bundle; | ||
|
||
public class ${activityClass} extends ${superClass} implements ${viewInterface}{ | ||
|
||
private ${presenterClass} mPresenter; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
<#if generateLayout> | ||
setContentView(R.layout.${layoutName}); | ||
</#if> | ||
if(mPresenter == null){ | ||
mPresenter = new ${presenterClass}(this); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
ActivityClean Architecture/root/src/app_package/SimpleModel.java.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package ${packageName}.model.model; | ||
|
||
|
||
public class ${modelClass}{ | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
ActivityClean Architecture/root/src/app_package/SimplePresenter.java.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ${packageName}.presentation; | ||
|
||
import ${superClassFqcn}; | ||
import android.os.Bundle; | ||
|
||
public class ${presenterClass} { | ||
|
||
private final ${viewInterface} mView; | ||
|
||
public ${presenterClass}(${viewInterface} view){ | ||
this.mView = view; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
ActivityClean Architecture/root/src/app_package/SimpleRepository.java.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ${packageName}.data; | ||
|
||
import rx.Observable; | ||
|
||
public interface ${repositoryInterface} { | ||
// Observable<${modelClass}> methodeFromRepo(); | ||
} |
30 changes: 30 additions & 0 deletions
30
ActivityClean Architecture/root/src/app_package/SimpleRepositoryImpl.java.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ${packageName}.model; | ||
|
||
|
||
import retrofit.Response; | ||
import rx.Observable; | ||
import rx.functions.Func1; | ||
|
||
|
||
public class ${repositoryImplClass} implements ${repositoryInterface} { | ||
|
||
private ${serviceClass} mRetrofitService; | ||
|
||
public ${repositoryImplClass}(${serviceClass} retrofitService) { | ||
this.mRetrofitService = retrofitService; | ||
} | ||
|
||
|
||
// @Override | ||
//public Observable<${modelClass}> methodeFromRepo() { | ||
// return mRetrofitService.methodeFromRetrofit().map(new Func1<Response<${modelClass}>, ${modelClass}>() { | ||
// @Override | ||
// public ${modelClass} call(Response<${modelClass}> response) { | ||
// if (response.isSuccess()) | ||
// return response.body(); | ||
// else | ||
// throw new RuntimeException(response.body().getResultMessage()); | ||
// } | ||
//}); | ||
// } | ||
} |
10 changes: 10 additions & 0 deletions
10
ActivityClean Architecture/root/src/app_package/SimpleRetroiftService.java.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package ${packageName}.model; | ||
|
||
import retrofit.Response; | ||
import rx.Observable; | ||
|
||
|
||
public interface ${retrofitService} { | ||
|
||
//Observable<Response<${modelClass}>> methodeFromRetrofit(); | ||
} |
19 changes: 19 additions & 0 deletions
19
ActivityClean Architecture/root/src/app_package/SimpleService.java.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ${packageName}.data; | ||
|
||
|
||
public class ${serviceClass} { | ||
|
||
private ${repositoryInterface} mRepo; | ||
|
||
public ${serviceClass}(${repositoryInterface} repo) { | ||
this.mRepo = repo; | ||
} | ||
|
||
// TODO:create methode in repo class | ||
// | ||
// public Observable<${modelClass}> methodeName() { | ||
// return mRepo.methodeFromRepo(); | ||
// } | ||
// | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
ActivityClean Architecture/root/src/app_package/SimpleView.java.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package ${packageName}.presentation; | ||
|
||
public interface ${viewInterface} { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?xml version="1.0"?> | ||
<template | ||
format="5" | ||
revision="1" | ||
name="Empty Activity (Clean Architecture)" | ||
minApi="7" | ||
minBuildApi="14" | ||
description="Creates a new activity with Clean Architecture"> | ||
|
||
<category value="Activity" /> | ||
<formfactor value="Mobile" /> | ||
|
||
<parameter | ||
id="activityClass" | ||
name="Activity Name" | ||
type="string" | ||
constraints="class|unique|nonempty" | ||
suggest="${layoutToActivity(layoutName)}" | ||
default="MainActivity" | ||
help="The name of the activity class to create" /> | ||
|
||
<parameter | ||
id="presenterClass" | ||
name="Presenter Name" | ||
type="string" | ||
constraints="class|unique|nonempty" | ||
suggest="${activityClass}Presenter" | ||
default="MainPresneter" | ||
help="The name of the presenter class to create" /> | ||
|
||
<parameter | ||
id="viewInterface" | ||
name="View Name" | ||
type="string" | ||
constraints="class|unique|nonempty" | ||
suggest="${activityClass}View" | ||
default="MainView" | ||
help="The name of the view to create" /> | ||
|
||
<parameter | ||
id="generateDataLayer" | ||
name="Generate Data Layer" | ||
type="boolean" | ||
default="true" | ||
help="If true, data layer will be generated" /> | ||
|
||
<parameter | ||
id="serviceClass" | ||
name="Service Name" | ||
type="string" | ||
constraints="class|unique|nonempty" | ||
suggest="${activityClass}Service" | ||
default="MainService" | ||
visibility="generateDataLayer" | ||
help="The name of the service to create" /> | ||
|
||
<parameter | ||
id="repositoryInterface" | ||
name="Repository Name" | ||
type="string" | ||
constraints="class|unique|nonempty" | ||
suggest="${activityClass}Repository" | ||
default="MainRepository" | ||
visibility="generateDataLayer" | ||
help="The name of the repository to create" /> | ||
|
||
<parameter | ||
id="generateModelLayer" | ||
name="Generate Model Layer" | ||
type="boolean" | ||
default="true" | ||
help="If true, model layer will be generated" /> | ||
|
||
<parameter | ||
id="repositoryImplClass" | ||
name="Repository Implementation name" | ||
type="string" | ||
constraints="class|unique|nonempty" | ||
suggest="${activityClass}RepositoryImpl" | ||
default="MainRepositoryImpl" | ||
visibility="generateModelLayer" | ||
help="The name of the repository implementation to create" /> | ||
|
||
<parameter | ||
id="retrofitService" | ||
name="Retrofit Service Name" | ||
type="string" | ||
constraints="class|unique|nonempty" | ||
suggest="${activityClass}RetrofitService" | ||
default="MainRetrofitService" | ||
visibility="generateModelLayer" | ||
help="The name of the retrofit service class to create" /> | ||
|
||
<parameter | ||
id="generateModel" | ||
name="Generate Model for responce" | ||
type="boolean" | ||
default="true" | ||
help="If true, model class will be generated" /> | ||
|
||
<parameter | ||
id="modelClass" | ||
name="Model name" | ||
type="string" | ||
constraints="class|unique|nonempty" | ||
default="MainModel" | ||
visibility="generateModel" | ||
help="The name of the model class to create" /> | ||
|
||
<parameter | ||
id="generateLayout" | ||
name="Generate Layout File" | ||
type="boolean" | ||
default="true" | ||
help="If true, a layout file will be generated" /> | ||
|
||
<parameter | ||
id="layoutName" | ||
name="Layout Name" | ||
type="string" | ||
constraints="layout|unique|nonempty" | ||
suggest="${activityToLayout(activityClass)}" | ||
default="activity_main" | ||
visibility="generateLayout" | ||
help="The name of the layout to create for the activity" /> | ||
|
||
<parameter | ||
id="isLauncher" | ||
name="Launcher Activity" | ||
type="boolean" | ||
default="false" | ||
help="If true, this activity will have a CATEGORY_LAUNCHER intent filter, making it visible in the launcher" /> | ||
|
||
<parameter | ||
id="packageName" | ||
name="Package name" | ||
type="string" | ||
constraints="package" | ||
default="com.mycompany.myapp" /> | ||
|
||
<!-- 128x128 thumbnails relative to template.xml --> | ||
<thumbs> | ||
<!-- default thumbnail is required --> | ||
<thumb>template_blank_activity.png</thumb> | ||
</thumbs> | ||
|
||
<globals file="globals.xml.ftl" /> | ||
<execute file="recipe.xml.ftl" /> | ||
|
||
</template> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,37 @@ | ||
# ActivityCleanArchitecture_Template | ||
# Activity Clean Architecture - Template | ||
|
||
A small template for Android Studio to create an empty activity with Clean Architecture. | ||
|
||
* To use this template you will need Android Studio. | ||
|
||
* Copy the `ActivityClean Architecture` folder into `<androidStudio-folder>/plugins/android/lib/templates/` and they will appear in the project explorer context menu. | ||
* Restart Android Studio, and you will find it in: **New -> Activity -> Empty Activity (Clean Architecture)** | ||
![Screen](https://cloud.githubusercontent.com/assets/4659608/18235206/7a7e3fb0-7320-11e6-826b-4870d4e70224.png) | ||
![Screen](https://cloud.githubusercontent.com/assets/4659608/18235205/7a7e2eee-7320-11e6-942a-1fdb57fecb6a.png) | ||
|
||
|
||
|
||
## License | ||
------ | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Abdullah Alhazmy | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
> The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |