Created
April 10, 2018 22:58
-
-
Save dphans/16794700a9c16b823cbb002c63d7b6a1 to your computer and use it in GitHub Desktop.
Android Data Binding Example > Activities > BaseActivity.kt
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.dinophan.authapp.bases | |
import android.databinding.DataBindingUtil | |
import android.databinding.ViewDataBinding | |
import android.os.Bundle | |
import android.os.PersistableBundle | |
import android.support.annotation.LayoutRes | |
import android.support.v7.app.AppCompatActivity | |
abstract class BaseActivity<in T>(@LayoutRes private val layoutResId: Int? = null): AppCompatActivity() where T: ViewDataBinding { | |
abstract fun onActivityCreated(dataBinder: T) | |
final override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { | |
super.onCreate(savedInstanceState, persistentState) | |
[email protected]() | |
} | |
final override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
[email protected]() | |
} | |
private fun initial() { | |
[email protected]?.let { layoutId -> | |
val dataBinder = DataBindingUtil.setContentView<T>(this@BaseActivity, layoutId) | |
[email protected](dataBinder) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment