Skip to content

Commit 3d977e2

Browse files
sachinrana01sachinrana01
sachinrana01
authored and
sachinrana01
committed
MVP template with boiler code
1 parent 1ebfcd3 commit 3d977e2

12 files changed

+174
-0
lines changed

template/How_to_use_template.gif

4.62 MB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<recipe>
2+
<instantiate from="src/app_package/activity_layout.xml.ftl"
3+
to="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" />
4+
</recipe>

template/MVPActivity/globals.xml.ftl

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<globals>
3+
<global id="hasNoActionBar" type="boolean" value="false" />
4+
<global id="parentActivityClass" value="" />
5+
<global id="simpleLayoutName" value="${layoutName}" />
6+
<global id="excludeMenu" type="boolean" value="true" />
7+
<global id="generateActivityTitle" type="boolean" value="false" />
8+
<#include "../common/common_globals.xml.ftl" />
9+
</globals>

template/MVPActivity/recipe.xml.ftl

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<recipe>
3+
<#include "../common/recipe_manifest.xml.ftl" /><#if generateLayout>
4+
<#include "activity_layout_recipe.xml.ftl" />
5+
<open file="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" />
6+
</#if>
7+
<instantiate from="src/app_package/View.java.ftl"
8+
to="${escapeXmlAttribute(srcOut)}/${folderName}/${className}MvpView.java" />
9+
<instantiate from="src/app_package/Activity.java.ftl"
10+
to="${escapeXmlAttribute(srcOut)}/${folderName}/${activityClass}.java" />
11+
<instantiate from="src/app_package/Presenter.java.ftl"
12+
to="${escapeXmlAttribute(srcOut)}/${folderName}/${className}Presenter.java" />
13+
<instantiate from="src/app_package/MvpPresenter.java.ftl"
14+
to="${escapeXmlAttribute(srcOut)}/${folderName}/${className}MvpPresenter.java" />
15+
<open file="${srcOut}/${folderName}/${className}MvpPresenter.java"/>
16+
<open file="${srcOut}/${folderName}/${className}MvpView.java"/>
17+
<open file="${srcOut}/${folderName}/${className}Presenter.java"/>
18+
<open file="${srcOut}/${folderName}/${activityClass}.java"/></recipe>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package ${packageName}.${folderName};
2+
3+
import android.os.Bundle;
4+
import javax.inject.Inject;
5+
import butterknife.ButterKnife;
6+
import com.mindorks.framework.mvp.ui.base.BaseActivity;
7+
import android.content.Intent;
8+
import android.content.Context;
9+
import com.mindorks.framework.mvp.R;
10+
public class ${className}Activity extends BaseActivity implements ${className}MvpView {
11+
12+
@Inject
13+
${className}Presenter<${className}MvpView> mPresenter;
14+
15+
@Override
16+
protected void onCreate(final Bundle savedInstanceState) {
17+
super.onCreate(savedInstanceState);
18+
setContentView(R.layout.${layoutName});
19+
20+
getActivityComponent().inject(this);
21+
setUnBinder(ButterKnife.bind(this));
22+
mPresenter.onAttach(${className}Activity.this);
23+
}
24+
25+
public static Intent getStartIntent(Context context) {
26+
Intent intent = new Intent(context, ${className}Activity.class);
27+
return intent;
28+
}
29+
30+
@Override
31+
protected void onDestroy() {
32+
mPresenter.onDetach();
33+
super.onDestroy();
34+
}
35+
36+
@Override
37+
protected void setUp() {
38+
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package ${packageName}.${folderName};
2+
3+
import com.mindorks.framework.mvp.ui.base.MvpPresenter;
4+
5+
public interface ${className}MvpPresenter<V extends ${className}MvpView> extends MvpPresenter<V> {
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package ${packageName}.${folderName};
2+
3+
4+
import com.mindorks.framework.mvp.ui.base.BasePresenter;
5+
import com.mindorks.framework.mvp.utils.rx.SchedulerProvider;
6+
import com.mindorks.framework.mvp.data.DataManager;
7+
import io.reactivex.disposables.CompositeDisposable;
8+
9+
import javax.inject.Inject;
10+
11+
public class ${className}Presenter <V extends ${className}MvpView> extends BasePresenter<V> implements ${className}MvpPresenter<V> {
12+
13+
private static final String TAG = "${className}Presenter";
14+
15+
@Inject
16+
public ${className}Presenter(DataManager dataManager,
17+
SchedulerProvider schedulerProvider,
18+
CompositeDisposable compositeDisposable) {
19+
super(dataManager, schedulerProvider, compositeDisposable);
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package ${packageName}.${folderName};
2+
3+
import com.mindorks.framework.mvp.ui.base.MvpView;
4+
5+
public interface ${className}MvpView extends MvpView {
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context="${packageName}.${folderName}.${activityClass}">
8+
9+
</android.support.constraint.ConstraintLayout>

template/MVPActivity/template.xml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0"?>
2+
<template format="2"
3+
revision="1"
4+
name="MVP Activity"
5+
minApi="9"
6+
minBuildApi="14"
7+
description="Creates a new MVP activity">
8+
<category value="MVP" />
9+
<formfactor value="Mobile" />
10+
<parameter
11+
id="folderName"
12+
name="Folder Name"
13+
type="string"
14+
constraints="class|unique|nonempty"
15+
default="demo"
16+
help="MVP root folder" />
17+
<parameter
18+
id="className"
19+
name="Class Name ** Do not suffix Activity **"
20+
type="string"
21+
constraints="class|unique|nonempty"
22+
default="Demo"
23+
help="The name of the class to create" />
24+
<parameter
25+
id="activityClass"
26+
name="Activity Name"
27+
type="string"
28+
constraints="class|unique|nonempty|"
29+
suggest="${className}Activity"
30+
default="DemoActivity"
31+
visibility="false"
32+
help="The name of the activity class to create" />
33+
<parameter
34+
id="generateLayout"
35+
name="Generate Layout File"
36+
type="boolean"
37+
default="true"
38+
help="If true, a layout file will be generated" />
39+
<parameter
40+
id="isLauncher"
41+
name="Launcher Activity"
42+
type="boolean"
43+
default="false"/>
44+
<parameter
45+
id="layoutName"
46+
name="Layout Name"
47+
type="string"
48+
constraints="layout|unique|nonempty"
49+
suggest="${activityToLayout(activityClass)}"
50+
default="activity_demo_nb"
51+
visibility="generateLayout"
52+
help="The name of the layout to create for the activity" />
53+
<!-- 128x128 thumbnails relative to template.xml -->
54+
<thumbs>
55+
<!-- default thumbnail is required -->
56+
<thumb>template_blank_activity.png</thumb>
57+
</thumbs>
58+
<globals file="globals.xml.ftl" />
59+
<execute file="recipe.xml.ftl" />
60+
</template>
4.49 KB
Loading

template/how_to_install.gif

706 KB
Loading

0 commit comments

Comments
 (0)