This file contains hidden or 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
| override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { | |
| if (BuildConfig.DEBUG && keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && event?.isLongPress == true) { | |
| RoomInspector.inspect(this, MyDatabase::class.java, MyDatabase.DB_NAME) | |
| return true | |
| } | |
| return super.onKeyDown(keyCode, event) | |
| } |
This file contains hidden or 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
| abstract class BaseActivity<D : ViewDataBinding, V : BaseViewModel> : AppCompatActivity(){ | |
| @get:LayoutRes | |
| protected abstract val layoutId: Int | |
| protected abstract val viewModelClass: Class<V> | |
| internal val viewModel:V by lazy { ViewModelProvider(this).get(viewModelClass) } | |
| internal lateinit var binding: D |
This file contains hidden or 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
| abstract class BaseViewModel : ViewModel() { | |
| open fun onActivityCreated(extras: Bundle?) {} | |
| open fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {} | |
| } |
This file contains hidden or 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" encoding="utf-8"?> | |
| <layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools"> | |
| <data> | |
| <variable | |
| name="viewModel" | |
| type="yourpackage.YourViewModel" /> | |
| </data> | |
| <!-- Add your views here.--> |
This file contains hidden or 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"?> | |
| <template | |
| format="5" | |
| revision="5" | |
| name="App Activity" | |
| minApi="21" | |
| minBuildApi="21" | |
| description="Creates a new app activity"> | |
| <category value="Activity" /> |
This file contains hidden or 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> | |
| <merge from="root/res/values/strings.xml.ftl" | |
| to="${escapeXmlAttribute(resOut)}/values/strings.xml" /> | |
| <merge from="root/AndroidManifest.xml.ftl" | |
| to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" /> | |
| <instantiate from="root/src/app_package/Activity.kt.ftl" |
This file contains hidden or 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
| 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}>() { |
This file contains hidden or 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
| package com.ktvipin.templatedemo.demo | |
| import android.content.Context | |
| import android.content.Intent | |
| import android.os.Bundle | |
| import com.ktvipin.templatedemo.R | |
| import com.ktvipin.templatedemo.core.BaseActivity | |
| import com.ktvipin.templatedemo.databinding.ActivityDemoBinding | |
| class DemoActivity : BaseActivity<ActivityDemoBinding, DemoViewModel>() { |
This file contains hidden or 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
| class TimberRemoteTree(private val deviceDetails: DeviceDetails) : Timber.DebugTree() { | |
| private val dateFormat = SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()) | |
| private val timeFormat = SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS a zzz", Locale.getDefault()) | |
| private val date = dateFormat.format(Date(System.currentTimeMillis())) | |
| private val logRef = Firebase.database.getReference("logs/$date/${deviceDetails.deviceId}") | |
| override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { | |
| if (BuildConfig.REMOTE_LOG_ENABLED) { |
This file contains hidden or 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
| class TimberRemoteApp : Application() { | |
| @SuppressLint("HardwareIds") | |
| override fun onCreate() { | |
| super.onCreate() | |
| if (BuildConfig.DEBUG) { | |
| val deviceId = Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID) | |
| val deviceDetails = DeviceDetails(deviceId) | |
| val remoteTree = TimberRemoteTree(deviceDetails) |
OlderNewer