diff --git a/app/src/main/java/com/mashup/app/attendees/AttendeesFragment.kt b/app/src/main/java/com/mashup/app/attendees/AttendeesFragment.kt index cf11d94..ea9fb0f 100644 --- a/app/src/main/java/com/mashup/app/attendees/AttendeesFragment.kt +++ b/app/src/main/java/com/mashup/app/attendees/AttendeesFragment.kt @@ -57,7 +57,7 @@ class AttendeesFragment(attendanceList: List) : Fragment() { } private fun setupEventObserver() { - viewModel.closeEvent.observe(this, EventObserver { + viewModel.closeEvent.observe(viewLifecycleOwner, EventObserver { if (it) { activity?.finish() } diff --git a/app/src/main/java/com/mashup/app/notices/NoticesFragment.kt b/app/src/main/java/com/mashup/app/notices/NoticesFragment.kt index 624e133..477a27d 100644 --- a/app/src/main/java/com/mashup/app/notices/NoticesFragment.kt +++ b/app/src/main/java/com/mashup/app/notices/NoticesFragment.kt @@ -2,6 +2,7 @@ package com.mashup.app.notices import android.content.Intent import android.os.Bundle +import android.util.Log import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View @@ -56,7 +57,8 @@ class NoticesFragment : Fragment() { } private fun setupSnackbar() { - view?.setupSnackbar(this, viewModel.snackbarText, Snackbar.LENGTH_SHORT) + Log.d("lolos", "setup") + view?.setupSnackbar(viewLifecycleOwner, viewModel.snackbarText, Snackbar.LENGTH_SHORT) } private fun setupEventObserver() { diff --git a/app/src/main/java/com/mashup/util/ViewExt.kt b/app/src/main/java/com/mashup/util/ViewExt.kt index c6941e5..44fafe9 100644 --- a/app/src/main/java/com/mashup/util/ViewExt.kt +++ b/app/src/main/java/com/mashup/util/ViewExt.kt @@ -22,14 +22,11 @@ fun View.setupSnackbar( snackbarEvent: LiveData>, timeLength: Int ) { - - snackbarEvent.observe(lifecycleOwner, Observer { event -> - event.getContentIfNotHandled()?.let { - when (it) { - is Int -> showSnackbar(context.getString(it), timeLength) - is String -> showSnackbar(it, timeLength) - else -> throw TypeCastException() - } + snackbarEvent.observe(lifecycleOwner, EventObserver { + when (it) { + is Int -> showSnackbar(context.getString(it), timeLength) + is String -> showSnackbar(it, timeLength) + else -> throw TypeCastException() } }) }