diff --git a/app/src/main/java/umc/com/mobile/project/ui/board/GradDateFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/board/GradDateFragment.kt index 3684339f..06265c98 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/board/GradDateFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/board/GradDateFragment.kt @@ -69,7 +69,7 @@ class GradDateFragment : Fragment() { val date = originalFormat.parse(dateString) val formattedDate = targetFormat.format(date) viewModel.updateDateInfo(formattedDate) - Toast.makeText(context, "저장되었습니다.", Toast.LENGTH_LONG).show() + //Toast.makeText(context, "저장되었습니다.", Toast.LENGTH_LONG).show() navigate(R.id.action_fragment_date_to_fragment_home) viewModel.onEditButtonClick() } catch (e: ParseException) { @@ -113,6 +113,11 @@ class GradDateFragment : Fragment() { binding.tvGradDateDday.text = "D-$dday" } + //api에서 메모 hint로 가져오기 + viewModel._dateResponse2.observe(viewLifecycleOwner) { response -> + binding.tvGradDateMemo.hint = response!!.result.message + } + //수정하기 및 버튼 visible 조건 viewModel.isEditMode.observe(viewLifecycleOwner, Observer { isEditMode -> if (isEditMode) { diff --git a/app/src/main/java/umc/com/mobile/project/ui/board/viewmodel/GradDateViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/board/viewmodel/GradDateViewModel.kt index 59b14f01..70e8fdd2 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/board/viewmodel/GradDateViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/board/viewmodel/GradDateViewModel.kt @@ -14,9 +14,11 @@ import umc.com.mobile.project.data.model.home.UpdateGradDateRequest import umc.com.mobile.project.data.model.home.UpdateGradDateResponse import umc.com.mobile.project.data.network.ApiClient import umc.com.mobile.project.data.network.api.HomeApi +import java.text.SimpleDateFormat import java.time.LocalDate import java.time.format.DateTimeFormatter import java.time.temporal.ChronoUnit +import java.util.Locale class GradDateViewModel : ViewModel() { val _selectedDate: MutableLiveData = MutableLiveData() @@ -55,10 +57,6 @@ class GradDateViewModel : ViewModel() { val isEditMode: LiveData get() = _isEditMode - init { - cheeringMessage.value = "" - } - fun init() { _isEditMode.value = false } @@ -86,12 +84,9 @@ class GradDateViewModel : ViewModel() { _isEditMode.value = !_isEditMode.value!! } - //전의 메모랑 같으면 저장 안됨 - private var previousMessage: String? = null - private var previousDDay: Int? = null - //버튼 활성화 조건 val isButtonEnabled = MediatorLiveData().apply { + //이전 메모랑 내용 같으면 저장 안됨 var previousMessage: String? = null var previousDDay: String? = null @@ -99,14 +94,14 @@ class GradDateViewModel : ViewModel() { val cheeringMessageObserver = Observer { currentMessage -> val dDayValue = _dday.value value = - previousMessage != currentMessage && currentMessage.isNotEmpty() && dDayValue != null && dDayValue != 0 + previousMessage != currentMessage && currentMessage.isNotEmpty() previousMessage = currentMessage } //_dday 값이 변경될 때마다 실행 val dDayObserver = Observer { currentDDay -> val messageValue = cheeringMessage.value value = - previousDDay != currentDDay.toString() && currentDDay != null && currentDDay != 0 && messageValue != null && messageValue.isNotEmpty() + previousDDay != currentDDay.toString() && currentDDay != null && currentDDay != 0 previousDDay = currentDDay.toString() } addSource(cheeringMessage, cheeringMessageObserver) @@ -124,8 +119,12 @@ class GradDateViewModel : ViewModel() { if (dateInfoResponse != null) { dateResponse.postValue(dateInfoResponse)//home에 있어서 놔둠 _dateResponse2.postValue(dateInfoResponse) - if (_dateResponse2.value != null && _dateResponse2.value!!.result != null) { - _selectedDate.value = _dateResponse2.value!!.result.gradDate + val originalFormat = SimpleDateFormat("yyyy-MM-dd", Locale.KOREA) + val targetFormat = SimpleDateFormat("yyyy-M월-d", Locale.KOREA) + if (dateInfoResponse.result.dday != null) { + val date = originalFormat.parse(dateInfoResponse.result.gradDate) + val formattedDate = targetFormat.format(date) + _selectedDateRequest.value = formattedDate } Log.d("gradDate", "${response.body()}") } else { diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditActivityFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditActivityFragment.kt index 71944ea3..e92bedfb 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditActivityFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditActivityFragment.kt @@ -75,6 +75,7 @@ class CareerEditActivityFragment : Fragment() { if (isDeleted) { //삭제 작업이 완료되면 목록 업데이트 navigate(R.id.action_fragment_edit_activity_to_fragment_career_activity) + Toast.makeText(mContext, "삭제되었습니다.", Toast.LENGTH_SHORT).show() } }) } @@ -84,6 +85,7 @@ class CareerEditActivityFragment : Fragment() { if (isUpdated) { //수정 작업이 완료되면 목록 업데이트 navigate(R.id.action_fragment_edit_activity_to_fragment_career_activity) + Toast.makeText(mContext, "수정되었습니다.", Toast.LENGTH_SHORT).show() } }) } @@ -101,7 +103,7 @@ class CareerEditActivityFragment : Fragment() { } }) //버튼 활성화 - viewModel.isFilledAllOptions.observe(viewLifecycleOwner) { isEnabled -> + viewModel.isFilledAnyOptions.observe(viewLifecycleOwner) { isEnabled -> binding?.btnCareerEdit?.isEnabled = isEnabled binding?.btnCareerEdit?.backgroundTintList = ContextCompat.getColorStateList( diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditCertificateFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditCertificateFragment.kt index 3bb63d00..07e06f02 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditCertificateFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditCertificateFragment.kt @@ -6,6 +6,7 @@ import android.text.Editable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Toast import androidx.core.content.ContextCompat import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment @@ -64,6 +65,7 @@ class CareerEditCertificateFragment : Fragment() { if (isDeleted) { //삭제 작업이 완료되면 목록 업데이트 navigate(R.id.action_fragment_edit_certificate_to_fragment_career_certificate) + Toast.makeText(mContext, "삭제되었습니다.", Toast.LENGTH_SHORT).show() } }) } @@ -74,6 +76,7 @@ class CareerEditCertificateFragment : Fragment() { if (isUpdated) { //수정 작업이 완료되면 목록 업데이트 navigate(R.id.action_fragment_edit_certificate_to_fragment_career_certificate) + Toast.makeText(mContext, "수정되었습니다.", Toast.LENGTH_SHORT).show() } }) } diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditContestFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditContestFragment.kt index 73220b84..cd461105 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditContestFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditContestFragment.kt @@ -6,6 +6,7 @@ import android.text.Editable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Toast import androidx.core.content.ContextCompat import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment @@ -72,6 +73,7 @@ class CareerEditContestFragment : Fragment() { if (isDeleted) { //삭제 작업이 완료되면 목록 업데이트 navigate(R.id.action_fragment_edit_contest_to_fragment_career_contest) + Toast.makeText(mContext, "삭제되었습니다.", Toast.LENGTH_SHORT).show() } }) } @@ -81,6 +83,7 @@ class CareerEditContestFragment : Fragment() { if (isUpdated) { //수정 작업이 완료되면 목록 업데이트 navigate(R.id.action_fragment_edit_contest_to_fragment_career_contest) + Toast.makeText(mContext, "수정되었습니다.", Toast.LENGTH_SHORT).show() } }) } diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditVolunteerFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditVolunteerFragment.kt index 7e337798..0cb729fe 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditVolunteerFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/CareerEditVolunteerFragment.kt @@ -6,6 +6,7 @@ import android.text.Editable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Toast import androidx.core.content.ContextCompat import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment @@ -63,6 +64,7 @@ class CareerEditVolunteerFragment : Fragment() { if (isDeleted) { //삭제 작업이 완료되면 목록 업데이트 navigate(R.id.action_fragment_edit_volunteer_to_fragment_career_volunteer) + Toast.makeText(mContext, "삭제되었습니다.", Toast.LENGTH_SHORT).show() } }) } @@ -72,6 +74,7 @@ class CareerEditVolunteerFragment : Fragment() { if (isUpdated) { //수정 작업이 완료되면 목록 업데이트 navigate(R.id.action_fragment_edit_volunteer_to_fragment_career_volunteer) + Toast.makeText(mContext, "수정되었습니다.", Toast.LENGTH_SHORT).show() } }) } 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 29f1f488..4ce6d014 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 @@ -28,12 +28,14 @@ class CareerAddActivityViewModel : ViewModel() { val endDate: MutableLiveData = MutableLiveData() val fileAddedEvent: MutableLiveData = MutableLiveData() val imageList: MutableList = mutableListOf() + val totalFileSize = MutableLiveData(0) init { title.value = "" startDate.value = "" endDate.value = "" imageList.clear() + totalFileSize.value = 0 } fun init() { @@ -41,6 +43,7 @@ class CareerAddActivityViewModel : ViewModel() { startDate.value = "" endDate.value = "" imageList.clear() + totalFileSize.value = 0 } /* 버튼 활성화 기능 */ @@ -48,22 +51,29 @@ class CareerAddActivityViewModel : ViewModel() { addSource(title) { value = areBothFieldsFilled() } addSource(startDate) { value = areBothFieldsFilled() } addSource(endDate) { value = areBothFieldsFilled() } + addSource(totalFileSize) { value = areBothFieldsFilled() } } private fun areBothFieldsFilled(): Boolean { return !(title.value.isNullOrEmpty() || title.value!!.contains(" ") || title.value!!.length > 20) && isDateValid( startDate.value - ) && isDateValid(endDate.value) + ) && isDateValid(endDate.value) && isFileSizeValid() } private fun isDateValid(date: String?): Boolean { return !date.isNullOrBlank() && date.length == 8 } + //파일 사이즈가 30MB를 넘지 않는지 체크 + private fun isFileSizeValid(): Boolean { + return totalFileSize.value ?: 0 <= 30 * 1024 * 1024 + } + fun addImageFile(file: File) { val requestFile = RequestBody.create("image/*".toMediaTypeOrNull(), file) val body = MultipartBody.Part.createFormData("image", file.name, requestFile) imageList.add(body) + calculateTotalFileSize() //파일 사이즈 계산 fileAddedEvent.value = true } @@ -93,9 +103,20 @@ class CareerAddActivityViewModel : ViewModel() { val filePart = MultipartBody.Part.createFormData("image", fileName, requestFile) imageList.add(filePart) + calculateTotalFileSize() //파일 사이즈 계산 fileAddedEvent.value = true } + //파일 사이즈 측정 + fun calculateTotalFileSize() { + var totalSize: Long = 0 + for (filePart in imageList) { + val file = filePart.body + totalSize += file?.contentLength() ?: 0 + } + totalFileSize.value = totalSize + } + //API에 전송할 데이터를 포함하는 RequestDto 생성 함수 fun createRequestDto(): ActivityDto? { val startDateString = startDate.value @@ -135,18 +156,6 @@ class CareerAddActivityViewModel : ViewModel() { val requestDtoPart: RequestBody = requestDtoJson.toRequestBody("application/json".toMediaTypeOrNull()) - //파일 사이즈 측정 - fun calculateTotalFileSize(): Long { - var totalSize: Long = 0 - for (filePart in imageList) { - val file = filePart.body - totalSize += file?.contentLength() ?: 0 - } - return totalSize - } - - val totalFileSize = calculateTotalFileSize() - Log.d("File Size", "Total File Size: $totalFileSize bytes") careerApiService.addCareer(imageList, requestDtoPart) .enqueue(object : Callback { override fun onResponse( @@ -158,7 +167,7 @@ class CareerAddActivityViewModel : ViewModel() { if (addCareerResponse != null) { _addedCareerInfo.postValue(addCareerResponse) Log.d("addCareer:Extras 성공", "${response.body()}") - Log.d("addSuccessFileName", imageList.toString()) + Log.d("totalFileSize", totalFileSize.value.toString()) } else { _error.postValue("서버 응답이 올바르지 않습니다.") } diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddCertificateViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddCertificateViewModel.kt index c7118178..5bbe3c3d 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddCertificateViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddCertificateViewModel.kt @@ -48,14 +48,14 @@ class CareerAddCertificateViewModel : ViewModel() { /* 버튼 활성화 기능 */ val isFilledAllOptions: LiveData = MediatorLiveData().apply { addSource(title) { value = areBothFieldsFilled() } + addSource(selectedCertificateType) { value = areBothFieldsFilled() } addSource(startDate) { value = areBothFieldsFilled() } addSource(endDate) { value = areBothFieldsFilled() } } private fun areBothFieldsFilled(): Boolean { - return !(title.value.isNullOrEmpty() || title.value!!.contains(" ") || title.value!!.length > 20) && isDateValid( - startDate.value - ) && isDateValid(endDate.value) + return !(title.value.isNullOrEmpty() || title.value!!.contains(" ") || title.value!!.length > 20) && !selectedCertificateType.value.isNullOrEmpty() + && isDateValid(startDate.value) && isDateValid(endDate.value) } private fun isDateValid(date: String?): Boolean { diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddContestViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddContestViewModel.kt index efce1bc7..4acb3157 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddContestViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddContestViewModel.kt @@ -48,14 +48,14 @@ class CareerAddContestViewModel : ViewModel() { /* 버튼 활성화 기능 */ val isFilledAllOptions: LiveData = MediatorLiveData().apply { addSource(title) { value = areBothFieldsFilled() } + addSource(selectedAward) { value = areBothFieldsFilled() } addSource(startDate) { value = areBothFieldsFilled() } addSource(endDate) { value = areBothFieldsFilled() } } private fun areBothFieldsFilled(): Boolean { - return !(title.value.isNullOrEmpty() || title.value!!.contains(" ") || title.value!!.length > 20) && isDateValid( - startDate.value - ) && isDateValid(endDate.value) + return !(title.value.isNullOrEmpty() || title.value!!.contains(" ") || title.value!!.length > 20) && !selectedAward.value.isNullOrEmpty() + && isDateValid(startDate.value) && isDateValid(endDate.value) } private fun isDateValid(date: String?): Boolean { diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddVolunteerViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddVolunteerViewModel.kt index eea2d439..24ec08d6 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddVolunteerViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerAddVolunteerViewModel.kt @@ -43,9 +43,8 @@ class CareerAddVolunteerViewModel : ViewModel() { } private fun areBothFieldsFilled(): Boolean { - return !(title.value.isNullOrEmpty() || title.value!!.contains(" ") || title.value!!.length > 20) && isDateValid( - startDate.value - ) && isDateValid(endDate.value) + return !(title.value.isNullOrEmpty() || title.value!!.contains(" ") || title.value!!.length > 20) && !hour.value.isNullOrBlank() + && isDateValid(startDate.value) && isDateValid(endDate.value) } private fun isDateValid(date: String?): Boolean { diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditActivityViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditActivityViewModel.kt index 49655c62..016cf03b 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditActivityViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditActivityViewModel.kt @@ -33,6 +33,10 @@ class CareerEditActivityViewModel : ViewModel() { val endDate: MutableLiveData = MutableLiveData() val fileAddedEvent: MutableLiveData = MutableLiveData() val addFiles: MutableList = mutableListOf() + val addFilesLive: MutableLiveData = MutableLiveData().apply { + value = addFiles.isNotEmpty() + } + val totalFileSize = MutableLiveData(0) init { studentId.value = 0 @@ -41,6 +45,7 @@ class CareerEditActivityViewModel : ViewModel() { startDate.value = "" endDate.value = "" addFiles.clear() + totalFileSize.value = 0 } fun init() { @@ -49,28 +54,38 @@ class CareerEditActivityViewModel : ViewModel() { startDate.value = "" endDate.value = "" addFiles.clear() + addFilesLive.value = addFiles.isNotEmpty() + totalFileSize.value = 0 } - val isFilledAllOptions: LiveData = MediatorLiveData().apply { - value = areBothFieldsFilled() - addSource(startDate) { value = areBothFieldsFilled() } - addSource(endDate) { value = areBothFieldsFilled() } + val isFilledAnyOptions: LiveData = MediatorLiveData().apply { + value = isAnyFieldFilled() + addSource(title) { value = isAnyFieldFilled() } + addSource(startDate) { value = isAnyFieldFilled() } + addSource(endDate) { value = isAnyFieldFilled() } + addSource(addFilesLive) { value = isAnyFieldFilled() } + addSource(totalFileSize) { value = isAnyFieldFilled() } } - private fun areBothFieldsFilled(): Boolean { - return (startDate.value.isNullOrBlank() && endDate.value.isNullOrBlank()) || (isDateValid( - startDate.value - ) && isDateValid(endDate.value)) + private fun isAnyFieldFilled(): Boolean { + return (!title.value.isNullOrBlank() || !startDate.value.isNullOrBlank() || !endDate.value.isNullOrBlank() || addFilesLive.value ?: false) && isFileSizeValid() } private fun isDateValid(date: String?): Boolean { return date.isNullOrBlank() || date.length == 8 } + //파일 사이즈가 30MB를 넘지 않는지 체크 + private fun isFileSizeValid(): Boolean { + return totalFileSize.value ?: 0 <= 30 * 1024 * 1024 + } + fun addImageFile(file: File) { val requestFile = RequestBody.create("image/*".toMediaTypeOrNull(), file) val body = MultipartBody.Part.createFormData("addFiles", file.name, requestFile) addFiles.add(body) + addFilesLive.value = addFiles.isNotEmpty() + calculateTotalFileSize() //파일 사이즈 계산 fileAddedEvent.value = true } @@ -99,9 +114,21 @@ class CareerEditActivityViewModel : ViewModel() { val requestFile: RequestBody = RequestBody.create(mimeType?.toMediaTypeOrNull(), file) val filePart = MultipartBody.Part.createFormData("addFiles", fileName, requestFile) addFiles.add(filePart) + addFilesLive.value = addFiles.isNotEmpty() + calculateTotalFileSize() //파일 사이즈 계산 fileAddedEvent.value = true } + //파일 사이즈 측정 + fun calculateTotalFileSize() { + var totalSize: Long = 0 + for (filePart in addFiles) { + val file = filePart.body + totalSize += file?.contentLength() ?: 0 + } + totalFileSize.value = totalSize + } + private val careerApiService = ApiClient.createService() private val _activityDetailInfo: MutableLiveData = MutableLiveData() diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditCertificateViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditCertificateViewModel.kt index 3af5d61d..20f51d07 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditCertificateViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditCertificateViewModel.kt @@ -44,17 +44,17 @@ class CareerEditCertificateViewModel : ViewModel() { startDate.value = "" endDate.value = "" } - + val isFilledAllOptions: LiveData = MediatorLiveData().apply { - value = areBothFieldsFilled() - addSource(startDate) { value = areBothFieldsFilled() } - addSource(endDate) { value = areBothFieldsFilled() } + value = isAnyFieldFilled() + addSource(title) { value = isAnyFieldFilled() } + addSource(type) { value = isAnyFieldFilled() } + addSource(startDate) { value = isAnyFieldFilled() } + addSource(endDate) { value = isAnyFieldFilled() } } - private fun areBothFieldsFilled(): Boolean { - return (startDate.value.isNullOrBlank() && endDate.value.isNullOrBlank()) || (isDateValid( - startDate.value - ) && isDateValid(endDate.value)) + private fun isAnyFieldFilled(): Boolean { + return !title.value.isNullOrBlank() || !type.value.isNullOrBlank() || !startDate.value.isNullOrBlank() || !endDate.value.isNullOrBlank() } private fun isDateValid(date: String?): Boolean { diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditContestViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditContestViewModel.kt index dc668e9a..8bd6c799 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditContestViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditContestViewModel.kt @@ -46,15 +46,15 @@ class CareerEditContestViewModel : ViewModel() { } val isFilledAllOptions: LiveData = MediatorLiveData().apply { - value = areBothFieldsFilled() - addSource(startDate) { value = areBothFieldsFilled() } - addSource(endDate) { value = areBothFieldsFilled() } + value = isAnyFieldFilled() + addSource(title) { value = isAnyFieldFilled() } + addSource(award) { value = isAnyFieldFilled() } + addSource(startDate) { value = isAnyFieldFilled() } + addSource(endDate) { value = isAnyFieldFilled() } } - private fun areBothFieldsFilled(): Boolean { - return (startDate.value.isNullOrBlank() && endDate.value.isNullOrBlank()) || (isDateValid( - startDate.value - ) && isDateValid(endDate.value)) + private fun isAnyFieldFilled(): Boolean { + return !title.value.isNullOrBlank() || !award.value.isNullOrBlank() || !startDate.value.isNullOrBlank() || !endDate.value.isNullOrBlank() } private fun isDateValid(date: String?): Boolean { diff --git a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditVolunteerViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditVolunteerViewModel.kt index c8ecee88..07fcccae 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditVolunteerViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/career/viewmodel/CareerEditVolunteerViewModel.kt @@ -46,15 +46,15 @@ class CareerEditVolunteerViewModel : ViewModel() { } val isFilledAllOptions: LiveData = MediatorLiveData().apply { - value = areBothFieldsFilled() - addSource(startDate) { value = areBothFieldsFilled() } - addSource(endDate) { value = areBothFieldsFilled() } + value = isAnyFieldFilled() + addSource(title) { value = isAnyFieldFilled() } + addSource(hour) { value = isAnyFieldFilled() } + addSource(startDate) { value = isAnyFieldFilled() } + addSource(endDate) { value = isAnyFieldFilled() } } - private fun areBothFieldsFilled(): Boolean { - return (startDate.value.isNullOrBlank() && endDate.value.isNullOrBlank()) || (isDateValid( - startDate.value - ) && isDateValid(endDate.value)) + private fun isAnyFieldFilled(): Boolean { + return !title.value.isNullOrBlank() || !hour.value.isNullOrBlank() || !startDate.value.isNullOrBlank() || !endDate.value.isNullOrBlank() } private fun isDateValid(date: String?): Boolean { diff --git a/app/src/main/res/layout/fragment_career.xml b/app/src/main/res/layout/fragment_career.xml index 0cac4861..2076eee2 100644 --- a/app/src/main/res/layout/fragment_career.xml +++ b/app/src/main/res/layout/fragment_career.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".ui.setting.SettingFragment"> + tools:context="ui.career.CareerFragment"> - - - - - + tools:context=".ui.board.GradDateFragment"> + android:layout_height="match_parent" + android:orientation="vertical"> + + + + - - + + + + + + + + + + + app:layout_constraintTop_toBottomOf="@+id/iv_grad_date_card1"> + + + + + + - - - - - - - + + - + android:layout_marginBottom="6dp" + android:background="@drawable/bg_solid_gray_radius_25" + android:backgroundTint="@color/gray" + android:minHeight="0dp" + android:paddingTop="17dp" + android:paddingBottom="17dp" + android:stateListAnimator="@null" + android:text="저장하기" + android:textColor="@color/skyBlue" + android:visibility="@{vm.isEditMode ? 0 : 8}" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="@+id/tv_grad_date_memo" + app:layout_constraintStart_toStartOf="@+id/tv_grad_date_memo" /> - - - - - - - + \ No newline at end of file