Hello Friends,
Today I am sharing the android MVP template which make the development
Faster. This is an android studio template inspired by android view-model template.
When we follow Android MVP architecture in any project, for each module or feature
we need to create an Activity/Fragment, a Presenter and a Contract class and also
a layout file corresponding to them. This is really an time taking process.
So Taking advantage of Android Studio template I created a MVP template
which creates all this file at the start.
Getting Started
1. Download the MVPActivity Teamplate ,which you found at the bottom of this blog.
2. For WINDOW, Just copy directory MVPActivity
to $ANDROID_STUDIO_FOLDER$\plugins\android\lib\templates\activities\
3. For Mac, Just copy directory MVPActivity
to $ANDROID_STUDIO_FOLDER$/Contents/plugins/android/lib/templates/activities/
A. template.xml – This will contain information about the template
Today I am sharing the android MVP template which make the development
Faster. This is an android studio template inspired by android view-model template.
When we follow Android MVP architecture in any project, for each module or feature
we need to create an Activity/Fragment, a Presenter and a Contract class and also
a layout file corresponding to them. This is really an time taking process.
So Taking advantage of Android Studio template I created a MVP template
which creates all this file at the start.
Getting Started
1. Download the MVPActivity Teamplate ,which you found at the bottom of this blog.
2. For WINDOW, Just copy directory MVPActivity
to $ANDROID_STUDIO_FOLDER$\plugins\android\lib\templates\activities\
3. For Mac, Just copy directory MVPActivity
to $ANDROID_STUDIO_FOLDER$/Contents/plugins/android/lib/templates/activities/
4. Below are the few common files,
name, minSdkVersion, etc
B. recipe.xml.ftl - This will contain instructions explaining how to
create the template, including what variables to ask the user for and
what should be done with those variables.
C. globals.xml.ftl – This defines global variables
D. root/ folder – this will contain the template code.

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
<template format="5" | |
revision="1" | |
name="MVP Activity(Java)" | |
minApi="14" | |
minBuildApi="14" | |
description="Creates a new MVP Activity as per andrid standard - Presenter, View and Contract"> | |
<category value="Activity"/> | |
<formfactor value="Mobile"/> | |
<parameter | |
id="className" | |
name="Activity Name" | |
type="string" | |
constraints="class|unique|nonempty" | |
default="FunctionalityName" | |
help="The name of the feature activity"/> | |
<parameter | |
id="activityLayoutName" | |
name="Activity Layout Name" | |
type="string" | |
constraints="layout|unique|nonempty" | |
suggest="activity_${classToResource(className)}" | |
default="activity_main" | |
help="The name of the layout to create for the activity" /> | |
<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> |
B. recipe.xml.ftl - This will contain instructions explaining how to
create the template, including what variables to ask the user for and
what should be done with those variables.
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
<?xml version="1.0"?> | |
<recipe> | |
<dependency mavenUrl="com.android.support:appcompat-v7:${buildApi}.+"/> | |
<dependency mavenUrl="com.android.support.constraint:constraint-layout:+" /> | |
<instantiate from="root/res/layout/activity.xml.ftl" | |
to="${escapeXmlAttribute(resOut)}/layout/${escapeXmlAttribute(activityLayoutName )}.xml" /> | |
<instantiate from="root/src/app_package/Contract.java.ftl" | |
to="${escapeXmlAttribute(srcOut)}/contract/${className}Contract.java" /> | |
<instantiate from="root/src/app_package/MVPActivity.java.ftl" | |
to="${escapeXmlAttribute(srcOut)}/${className}Activity.java" /> | |
<instantiate from="root/src/app_package/Presenter.java.ftl" | |
to="${escapeXmlAttribute(srcOut)}/presenter/${className}Presenter.java" /> | |
<open file="${srcOut}/${className}Presenter.java"/> | |
</recipe> |
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
<?xml version="1.0"?> | |
<globals> | |
<global id="resOut" value="${resDir}" /> | |
<global id="srcOut" value="${srcDir}/${slashedPackageName(packageName)}" /> | |
<#include "../common/common_globals.xml.ftl" /> | |
</globals> |
Download code from here
Hope this will helps some one...
Enjoy Coding........... :)
0 comments:
Post a Comment