diff --git a/app/src/main/kotlin/jackall/moncalc/viewmodel/LifecycleViewModel.kt b/app/src/main/kotlin/jackall/moncalc/viewmodel/LifecycleViewModel.kt new file mode 100644 index 0000000..ecbc8ab --- /dev/null +++ b/app/src/main/kotlin/jackall/moncalc/viewmodel/LifecycleViewModel.kt @@ -0,0 +1,37 @@ +package jackall.moncalc.viewmodel + +import android.arch.lifecycle.Lifecycle +import android.arch.lifecycle.LifecycleObserver +import android.arch.lifecycle.OnLifecycleEvent +import android.arch.lifecycle.ViewModel + +/** + * lifecycleObserverに対応したViewModel + * + * Created by matsumoto_k on 2017/11/03. + */ +open class LifecycleViewModel : ViewModel(), LifecycleObserver { + @OnLifecycleEvent(Lifecycle.Event.ON_CREATE) + open fun onCreate() { + } + + @OnLifecycleEvent(Lifecycle.Event.ON_START) + open fun onStart() { + } + + @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) + open fun onResume() { + } + + @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) + open fun onPause() { + } + + @OnLifecycleEvent(Lifecycle.Event.ON_STOP) + open fun onStop() { + } + + @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) + open fun onDestroy() { + } +} \ No newline at end of file