Skip to content

Commit

Permalink
FEAT : navigateActivity 메소드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
minseonglove committed Dec 29, 2022
1 parent dd8cbad commit 338da3e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fakedevelopers.bidderbidder.ui.base

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -45,6 +46,11 @@ abstract class BaseFragment<VB : ViewDataBinding>(
}.show()
}

fun navigateActivity(activity: Class<*>) {
startActivity(Intent(requireContext(), activity))
requireActivity().finish()
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.fakedevelopers.bidderbidder.ui.login

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.fragment.app.viewModels
Expand Down Expand Up @@ -47,8 +46,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding>(
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.loginResponse.collect {
if (it.isSuccessful && it.body().toString() == LOGIN_SUCCESS) {
startActivity(Intent(requireContext(), MainActivity::class.java))
requireActivity().finish()
navigateActivity(MainActivity::class.java)
} else {
sendSnackBar(it.errorBody().toString())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.fakedevelopers.bidderbidder.ui.loginType

import android.app.Activity.RESULT_OK
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
Expand Down Expand Up @@ -81,8 +80,7 @@ class LoginTypeFragment : BaseFragment<FragmentLoginTypeBinding>(
viewModel.signinGoogleResponse.collect {
if (it.isSuccessful) {
sendSnackBar("success")
startActivity(Intent(requireContext(), MainActivity::class.java))
requireActivity().finish()
navigateActivity(MainActivity::class.java)
} else {
sendSnackBar(it.errorBody().toString())
}
Expand Down

0 comments on commit 338da3e

Please sign in to comment.