Skip to content

Commit

Permalink
Fix: 커리어 수정하기 전으로 가기 버튼 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kimyujin-com committed Feb 20, 2024
1 parent 022f9b4 commit 25b1540
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -60,7 +61,6 @@ class CertificateFragment : Fragment() {
false // 그 외의 경우 이벤트 소비하지 않음
}
}

_binding!!.ivCareerCertificateBack.setOnClickListener {
navigate(R.id.action_fragment_certificate_to_fragment_career)
}
Expand All @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 초기화
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
}
}
Expand Down

0 comments on commit 25b1540

Please sign in to comment.