-
Notifications
You must be signed in to change notification settings - Fork 207
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 #73 from shivan42/master
Added Moxy templates for Kotlin
- Loading branch information
Showing
35 changed files
with
424 additions
and
9 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
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 @@ | ||
<?xml version="1.0"?> | ||
<globals> | ||
<#include "../common/common_globals.xml.ftl" /> | ||
<global id="subpackage" value="<#if useSubPackage>${subPackage}/<#else></#if>" /> | ||
<global id="dotSubpackage" value="<#if useSubPackage>.${subPackage}<#else></#if>" /> | ||
</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,34 @@ | ||
<?xml version="1.0"?> | ||
<recipe> | ||
|
||
<#if includeLayout> | ||
<instantiate from="res/layout/activity_blank.xml.ftl" | ||
to="${escapeXmlAttribute(resOut)}/layout/${escapeXmlAttribute(activityName)}.xml" /> | ||
|
||
<open file="${escapeXmlAttribute(resOut)}/layout/${escapeXmlAttribute(activityName)}.xml" /> | ||
</#if> | ||
|
||
|
||
<instantiate from="src/app_package/ui/activity/BlankActivity.kt.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/ui/activity/${subpackage}${className}.kt" /> | ||
|
||
<open file="${escapeXmlAttribute(srcOut)}/ui/activity/${subpackage}${className}.kt" /> | ||
|
||
<#if includeView> | ||
<instantiate from="src/app_package/presentation/view/BlankView.kt.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/presentation/view/${subpackage}${viewName}.kt" /> | ||
|
||
<open file="${escapeXmlAttribute(srcOut)}/presentation/view/${subpackage}${viewName}.kt" /> | ||
</#if> | ||
|
||
<#if includePresenter> | ||
<instantiate from="src/app_package/presentation/presenter/BlankPresenter.kt.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/presentation/presenter/${subpackage}${presenterName}.kt" /> | ||
|
||
<open file="${escapeXmlAttribute(srcOut)}/presentation/presenter/${subpackage}${presenterName}.kt" /> | ||
</#if> | ||
|
||
<merge from="AndroidManifest.xml.ftl" | ||
to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" /> | ||
|
||
</recipe> |
6 changes: 6 additions & 0 deletions
6
moxy-templates/Kotlin/MoxyActivity/root/AndroidManifest.xml.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 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<application> | ||
<activity android:name=".ui.activity${dotSubpackage}.${className}"/> | ||
</application> | ||
</manifest> |
9 changes: 9 additions & 0 deletions
9
moxy-templates/Kotlin/MoxyActivity/root/res/layout/activity_blank.xml.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,9 @@ | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="${packageName}.ui.activity${dotSubpackage}.${className}"> | ||
|
||
|
||
|
||
</FrameLayout> |
10 changes: 10 additions & 0 deletions
10
...tes/Kotlin/MoxyActivity/root/src/app_package/presentation/presenter/BlankPresenter.kt.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}.presentation.presenter${dotSubpackage} | ||
|
||
import com.arellomobile.mvp.InjectViewState | ||
import com.arellomobile.mvp.MvpPresenter | ||
import ${packageName}.presentation.view${dotSubpackage}.${viewName} | ||
|
||
@InjectViewState | ||
class ${presenterName} : MvpPresenter<${viewName}>() { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
moxy-templates/Kotlin/MoxyActivity/root/src/app_package/presentation/view/BlankView.kt.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}.presentation.view${dotSubpackage} | ||
|
||
import com.arellomobile.mvp.MvpView | ||
|
||
interface ${viewName} : MvpView { | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
moxy-templates/Kotlin/MoxyActivity/root/src/app_package/ui/activity/BlankActivity.kt.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,34 @@ | ||
package ${packageName}.ui.activity${dotSubpackage} | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
<#if !extendsBaseActivity> | ||
import com.arellomobile.mvp.MvpActivity | ||
</#if> | ||
import com.arellomobile.mvp.presenter.InjectPresenter | ||
import ${packageName}.R | ||
import ${packageName}.presentation.view${dotSubpackage}.${viewName} | ||
import ${packageName}.presentation.presenter${dotSubpackage}.${presenterName} | ||
<#if extendsBaseActivity> | ||
import ${packageName}.ui.activity.BaseActivity | ||
</#if> | ||
|
||
class ${className} : <#if extendsBaseActivity>BaseActivity()<#else>MvpActivity()</#if>, ${viewName} { | ||
companion object { | ||
const val TAG = "${className}" | ||
<#if includeFactory> | ||
fun getIntent(context: Context): Intent = Intent(context, ${className}::class.java) | ||
</#if> | ||
} | ||
|
||
@InjectPresenter | ||
lateinit var m${presenterName}: ${presenterName} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
<#if includeLayout> | ||
setContentView(R.layout.${activityName}) | ||
</#if> | ||
} | ||
} |
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,109 @@ | ||
<?xml version="1.0"?> | ||
<template | ||
format="4" | ||
revision="1" | ||
name="Moxy activity" | ||
description="MVP activity constructor" | ||
minApi="9" | ||
minBuildApi="14"> | ||
|
||
<category value="Moxy" /> | ||
|
||
<parameter | ||
id="className" | ||
name="Activity Name" | ||
type="string" | ||
constraints="class|nonempty|unique" | ||
default="BlankActivity" | ||
help="The name of the activity class to create" /> | ||
|
||
<parameter | ||
id="useSubPackage" | ||
name="Use sub package?" | ||
type="boolean" | ||
default="true" | ||
help="Add generated classes to specified package" /> | ||
|
||
<parameter | ||
id="subPackage" | ||
name="Package name" | ||
type="string" | ||
default="blank" | ||
visibility="useSubPackage" | ||
help="Package name" /> | ||
|
||
<parameter | ||
id="includeLayout" | ||
name="Create layout XML?" | ||
type="boolean" | ||
default="true" | ||
help="Generate a layout XML for the activity" /> | ||
|
||
<parameter | ||
id="includeView" | ||
name="Create View?" | ||
type="boolean" | ||
default="true" | ||
help="Generate a view for the activity" /> | ||
|
||
<parameter | ||
id="includePresenter" | ||
name="Create Presenter?" | ||
type="boolean" | ||
default="true" | ||
help="Generate a presenter for the activity" /> | ||
|
||
<parameter | ||
id="extendsBaseActivity" | ||
name="extends from Base Activity" | ||
type="boolean" | ||
default="true" | ||
help="extends from your_package_name/ui/activity/BaseActivity otherwise MvpActivity" /> | ||
|
||
|
||
<parameter | ||
id="activityName" | ||
name="Activity Layout Name" | ||
type="string" | ||
constraints="layout|nonempty|unique" | ||
default="activity_blank" | ||
visibility="includeLayout" | ||
suggest="activity_${classToResource(className)}" | ||
help="The name of the layout to create" /> | ||
|
||
<parameter | ||
id="includeFactory" | ||
name="Include activity factory method?" | ||
type="boolean" | ||
default="true" | ||
help="Generate static activity factory method for easy instantiation" /> | ||
|
||
<parameter | ||
id="viewName" | ||
name="View Name" | ||
type="string" | ||
constraints="class|nonempty|unique" | ||
default="BlankView" | ||
visibility="includeView" | ||
suggest="${underscoreToCamelCase(classToResource(className))}View" | ||
help="The name of the view interface to create" /> | ||
|
||
<parameter | ||
id="presenterName" | ||
name="Presenter Name" | ||
type="string" | ||
constraints="class|nonempty|unique" | ||
default="BlankPresenter" | ||
visibility="includePresenter" | ||
suggest="${underscoreToCamelCase(classToResource(className))}Presenter" | ||
help="The name of the presenter interface to create" /> | ||
|
||
|
||
<thumbs> | ||
<thumb>template_moxy_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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0"?> | ||
<globals> | ||
<#include "../common/common_globals.xml.ftl" /> | ||
<global id="subpackage" value="<#if useSubPackage>${subPackage}/<#else></#if>" /> | ||
<global id="dotSubpackage" value="<#if useSubPackage>.${subPackage}<#else></#if>" /> | ||
</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,30 @@ | ||
<?xml version="1.0"?> | ||
<recipe> | ||
|
||
<#if includeLayout> | ||
<instantiate from="res/layout/fragment_blank.xml.ftl" | ||
to="${escapeXmlAttribute(resOut)}/layout/${escapeXmlAttribute(fragmentName)}.xml" /> | ||
|
||
<open file="${escapeXmlAttribute(resOut)}/layout/${escapeXmlAttribute(fragmentName)}.xml" /> | ||
</#if> | ||
|
||
<instantiate from="src/app_package/ui/fragment/BlankFragment.kt.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/ui/fragment/${subpackage}${className}.kt" /> | ||
|
||
<open file="${escapeXmlAttribute(srcOut)}/ui/fragment/${subpackage}${className}.kt" /> | ||
|
||
<#if includeView> | ||
<instantiate from="src/app_package/presentation/view/BlankView.kt.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/presentation/view/${subpackage}${viewName}.kt" /> | ||
|
||
<open file="${escapeXmlAttribute(srcOut)}/presentation/view/${subpackage}${viewName}.kt" /> | ||
</#if> | ||
|
||
<#if includePresenter> | ||
<instantiate from="src/app_package/presentation/presenter/BlankPresenter.kt.ftl" | ||
to="${escapeXmlAttribute(srcOut)}/presentation/presenter/${subpackage}${presenterName}.kt" /> | ||
|
||
<open file="${escapeXmlAttribute(srcOut)}/presentation/presenter/${subpackage}${presenterName}.kt" /> | ||
</#if> | ||
|
||
</recipe> |
7 changes: 7 additions & 0 deletions
7
moxy-templates/Kotlin/MoxyFragment/root/res/layout/fragment_blank.xml.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 @@ | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="${packageName}.ui.fragment${dotSubpackage}.${className}"> | ||
|
||
</FrameLayout> |
10 changes: 10 additions & 0 deletions
10
...tes/Kotlin/MoxyFragment/root/src/app_package/presentation/presenter/BlankPresenter.kt.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}.presentation.presenter${dotSubpackage} | ||
|
||
import com.arellomobile.mvp.InjectViewState | ||
import com.arellomobile.mvp.MvpPresenter | ||
import ${packageName}.presentation.view${dotSubpackage}.${viewName} | ||
|
||
@InjectViewState | ||
class ${presenterName} : MvpPresenter<${viewName}>() { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
moxy-templates/Kotlin/MoxyFragment/root/src/app_package/presentation/view/BlankView.kt.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}.presentation.view${dotSubpackage} | ||
|
||
import com.arellomobile.mvp.MvpView | ||
|
||
interface ${viewName} : MvpView { | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
moxy-templates/Kotlin/MoxyFragment/root/src/app_package/ui/fragment/BlankFragment.kt.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,42 @@ | ||
package ${packageName}.ui.fragment${dotSubpackage} | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import ${packageName}.R | ||
import ${packageName}.presentation.view${dotSubpackage}.${viewName} | ||
import ${packageName}.presentation.presenter${dotSubpackage}.${presenterName} | ||
|
||
import com.arellomobile.mvp.MvpFragment | ||
import com.arellomobile.mvp.presenter.InjectPresenter | ||
|
||
class ${className} : MvpFragment(), ${viewName} { | ||
companion object { | ||
const val TAG = "${className}" | ||
<#if includeFactory> | ||
|
||
fun newInstance(): ${className} { | ||
val fragment: ${className} = ${className}() | ||
val args: Bundle = Bundle() | ||
fragment.arguments = args | ||
return fragment | ||
} | ||
</#if> | ||
} | ||
|
||
@InjectPresenter | ||
lateinit var m${presenterName}: ${presenterName} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle?): View? { | ||
<#if includeLayout> | ||
return inflater.inflate(R.layout.${fragmentName}, container, false) | ||
</#if> | ||
} | ||
|
||
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
} | ||
} |
Oops, something went wrong.