diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/ActivityFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/career/ActivityFragment.kt index 5a53720..50d5d1e 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/ActivityFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/ActivityFragment.kt @@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.activity.OnBackPressedCallback import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels import androidx.lifecycle.Observer @@ -68,6 +69,13 @@ class ActivityFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + //뒤로가기 버튼 눌렀을 때 + val callback = object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + navigate(R.id.action_fragment_activity_to_fragment_career) + } + } + requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback) //대외 활동 api 연결 viewModel.getActivityInfo() } diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/CareerFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/career/CareerFragment.kt index b937b94..a7fe5e4 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/CareerFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/CareerFragment.kt @@ -5,6 +5,7 @@ import android.text.Editable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.activity.OnBackPressedCallback import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import umc.com.mobile.project.R diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/CertificateFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/career/CertificateFragment.kt index 8d815a8..f1331dc 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/CertificateFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/CertificateFragment.kt @@ -7,6 +7,7 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.activity.OnBackPressedCallback import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels import androidx.lifecycle.Observer @@ -60,7 +61,6 @@ class CertificateFragment : Fragment() { false // 그 외의 경우 이벤트 소비하지 않음 } } - _binding!!.ivCareerCertificateBack.setOnClickListener { navigate(R.id.action_fragment_certificate_to_fragment_career) } @@ -69,6 +69,13 @@ class CertificateFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + //뒤로가기 버튼 눌렀을 때 + val callback = object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + navigate(R.id.action_fragment_certificate_to_fragment_career) + } + } + requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback) //자격증 목록 api 연결 viewModel.getCertificateInfo() } diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/ContestFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/career/ContestFragment.kt index 91a95d2..bf94711 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/ContestFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/ContestFragment.kt @@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.activity.OnBackPressedCallback import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels import androidx.lifecycle.Observer @@ -53,6 +54,13 @@ class ContestFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + //뒤로가기 버튼 눌렀을 때 + val callback = object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + navigate(R.id.action_fragment_contest_to_fragment_career) + } + } + requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback) //공모전 목록 api 연결 viewModel.getContestInfo() // adapter 초기화 diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/VolunteerFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/career/VolunteerFragment.kt index e79cc1f..78f027d 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/VolunteerFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/VolunteerFragment.kt @@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.activity.OnBackPressedCallback import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels import androidx.lifecycle.Observer @@ -71,6 +72,13 @@ class VolunteerFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + //뒤로가기 버튼 눌렀을 때 + val callback = object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + navigate(R.id.action_fragment_volunteer_to_fragment_career) + } + } + requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback) //봉사 활동 목록 api 연결 viewModel.getVolunteerInfo() } diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddActivityViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddActivityViewModel.kt index 4ce6d01..5c93e9e 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddActivityViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddActivityViewModel.kt @@ -70,6 +70,7 @@ class CareerAddActivityViewModel : ViewModel() { } fun addImageFile(file: File) { + Log.d("imagePath", file.toString()) val requestFile = RequestBody.create("image/*".toMediaTypeOrNull(), file) val body = MultipartBody.Part.createFormData("image", file.name, requestFile) imageList.add(body) @@ -179,6 +180,8 @@ class CareerAddActivityViewModel : ViewModel() { } ?: RuntimeException("Unknown error") } catch (e: Exception) { Log.e("addCareerInfo", "addCareer:Extras API 오류: ${e.message}") + val errorMessage = response.errorBody()?.string() + Log.e("addCareerInfo", "addCareer:Extras API 오류: $errorMessage") e.printStackTrace() } }