diff --git a/app/src/main/java/keijumt/devandroid/fragment/AsyncFragment.kt b/app/src/main/java/keijumt/devandroid/fragment/AsyncFragment.kt index 18e24f0..871b2fc 100644 --- a/app/src/main/java/keijumt/devandroid/fragment/AsyncFragment.kt +++ b/app/src/main/java/keijumt/devandroid/fragment/AsyncFragment.kt @@ -1,5 +1,6 @@ package keijumt.devandroid.fragment +import android.arch.lifecycle.Observer import android.arch.lifecycle.ViewModelProviders import android.databinding.DataBindingUtil import android.os.Bundle @@ -7,6 +8,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Toast import keijumt.devandroid.R import keijumt.devandroid.databinding.FragmentAsyncBinding import keijumt.devandroid.viewmodel.AsyncViewModel @@ -23,8 +25,14 @@ binding = DataBindingUtil.inflate(inflater, R.layout.fragment_async, null, false) asyncViewModel = ViewModelProviders.of(nonNullActivity, viewModelFactory).get(AsyncViewModel::class.java) binding.asyncViewModel = asyncViewModel + subscribe() return binding.root } + fun subscribe() { + asyncViewModel.toastMessage.observe(this, Observer { + Toast.makeText(activity, it, Toast.LENGTH_SHORT).show() + }) + } }