Skip to content

Commit

Permalink
feat: navigate 확장함수 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
junjange committed Jul 13, 2024
1 parent aedd97d commit 0527834
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.navigation.NavDirections
import androidx.navigation.fragment.findNavController
import com.google.android.material.snackbar.Snackbar

abstract class BaseFragment<T : ViewDataBinding>(
Expand Down Expand Up @@ -57,6 +59,12 @@ abstract class BaseFragment<T : ViewDataBinding>(
snackbar?.show()
}

protected fun Fragment.navigate(directions: NavDirections) {
val controller = findNavController()
controller.currentDestination?.getAction(directions.actionId) ?: return
controller.navigate(directions)
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
Expand Down

0 comments on commit 0527834

Please sign in to comment.