Skip to content

Instantly share code, notes, and snippets.

@ktvipin27
Last active May 29, 2020
Embed
What would you like to do?
Sample template files for demo of template architecture.
package ${escapeKotlinIdentifiers(packageName)}
import android.content.Context
import android.content.Intent
import android.os.Bundle
import ${applicationPackage}.R
import ${applicationPackage}.core.BaseActivity
import ${applicationPackage}.databinding.${underscoreToCamelCase(layoutName)}Binding
class ${activityClass} : BaseActivity<${underscoreToCamelCase(layoutName)}Binding,${viewModelClass}>() {
override val layoutId: Int
get() = R.layout.${layoutName}
override val viewModelClass: Class<${viewModelClass}>
get() = ${viewModelClass}::class.java
override fun onCreated(savedInstanceState: Bundle?, extras: Bundle?) {
super.onCreated(savedInstanceState, extras)
}
companion object{
fun start(context: Context) {
context.startActivity((Intent(context,${activityClass}::class.java)))
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="${packageName}.${viewModelClass}" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}">
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity android:name="${packageName}.${activityClass}"
android:label="@string/title_${activityToLayout(activityClass)}" />
</application>
</manifest>
<resources>
<string name="title_${activityToLayout(activityClass)}">${escapeXmlString(activityTitle)}</string>
</resources>
package ${escapeKotlinIdentifiers(packageName)}
import android.os.Bundle
import ${applicationPackage}.core.BaseViewModel
class ${viewModelClass} : BaseViewModel() {
override fun onActivityCreated(extras: Bundle?) {
super.onActivityCreated(extras)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment