package com.aaron.kakao.hospitalmapfortube.ui

import android.databinding.DataBindingUtil
import android.databinding.ViewDataBinding
import android.os.Bundle
import android.support.annotation.LayoutRes
import android.support.v7.app.AppCompatActivity
import com.aaron.kakao.hospitalmapfortube.core.BaseViewModel

abstract class BindingActivity<T : ViewDataBinding, V : BaseViewModel> : AppCompatActivity() {

    @LayoutRes
    abstract fun getLayoutResId(): Int

    abstract fun getMyViewModel(): V

    protected lateinit var binding: T
        private set

    protected lateinit var viewModel: V
        private set

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = DataBindingUtil.setContentView(this, getLayoutResId())
        binding.setLifecycleOwner(this)
        viewModel = getMyViewModel()
    }
}
