diff --git a/app/src/main/kotlin/jackall/overlaymulticounter/activity/MainActivity.kt b/app/src/main/kotlin/jackall/overlaymulticounter/activity/MainActivity.kt index 1d02b95..9495e86 100644 --- a/app/src/main/kotlin/jackall/overlaymulticounter/activity/MainActivity.kt +++ b/app/src/main/kotlin/jackall/overlaymulticounter/activity/MainActivity.kt @@ -1,18 +1,26 @@ package jackall.overlaymulticounter.activity -import android.content.Intent +import android.arch.lifecycle.ViewModelProviders +import android.databinding.DataBindingUtil import android.os.Bundle import android.support.v7.app.AppCompatActivity import jackall.overlaymulticounter.R +import jackall.overlaymulticounter.databinding.ActivityMainBinding import jackall.overlaymulticounter.db.CounterRealmHelper -import jackall.overlaymulticounter.service.MainService +import jackall.overlaymulticounter.viewmodel.MainViewModel import jackall.overlaymulticounter.vo.Counter class MainActivity : AppCompatActivity() { + lateinit var binding: ActivityMainBinding + lateinit var mainViewModel: MainViewModel + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + + binding = DataBindingUtil.setContentView(this, R.layout.activity_main) + mainViewModel = ViewModelProviders.of(this, MainViewModel.Factory()).get(MainViewModel::class.java) + binding.mainViewModel = mainViewModel if (CounterRealmHelper().getNextId() == 0) { CounterRealmHelper().insert( @@ -21,8 +29,5 @@ 0) ) } - - // TODO: RuntimePermissionの処理 - startService(Intent(this, MainService::class.java)) } }