From 6b0d024569b9a0ed92bdb4b3e5428957df40f5c5 Mon Sep 17 00:00:00 2001 From: ss99x2002 Date: Thu, 20 Jul 2023 03:58:08 +0900 Subject: [PATCH] =?UTF-8?q?[Refac/#89]=20=EB=8B=B5=EB=B3=80=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=ED=99=94=EB=A9=B4=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=EB=B0=94=EC=9D=B8=EB=94=A9=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/qna/ConfirmAnswerDialogFragment.kt | 11 +---------- .../presentation/qna/viewmodel/AnswerViewModel.kt | 2 -- .../ConfirmAnswerDialogFragmentViewModel.kt | 13 +++++++++++++ .../res/layout/fragment_confirm_answer_dialog.xml | 13 ++++++++----- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragment.kt b/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragment.kt index 32b78d7d..5e41e6db 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragment.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragment.kt @@ -36,8 +36,8 @@ class ConfirmAnswerDialogFragment : DialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + viewModel.setDataFromBundle(Bundle()) setBackgroundDesign() - setPreviewAnswer() setBtnClickEvent() observeResponseStatus() } @@ -51,15 +51,6 @@ class ConfirmAnswerDialogFragment : DialogFragment() { } } - private fun setPreviewAnswer() { - with(binding) { - tvAnswer.text = arguments?.getString("answer") - tvTopic.text = arguments?.getString("topic") - tvSection.text = arguments?.getString("section") - tvQuestion.text = arguments?.getString("question") - } - } - private fun setBackgroundDesign() { dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) } diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/qna/viewmodel/AnswerViewModel.kt b/app/src/main/java/com/sopt/umbba_android/presentation/qna/viewmodel/AnswerViewModel.kt index 4f7b8e7a..0ce797d0 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/qna/viewmodel/AnswerViewModel.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/qna/viewmodel/AnswerViewModel.kt @@ -3,10 +3,8 @@ package com.sopt.umbba_android.presentation.qna.viewmodel import android.content.Intent import android.os.Bundle import android.util.Log -import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -import com.sopt.umbba_android.data.entity.AnswerIntentResponse class AnswerViewModel : ViewModel() { var answer = MutableLiveData() diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/qna/viewmodel/ConfirmAnswerDialogFragmentViewModel.kt b/app/src/main/java/com/sopt/umbba_android/presentation/qna/viewmodel/ConfirmAnswerDialogFragmentViewModel.kt index 90af2e5b..1bb75d9c 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/qna/viewmodel/ConfirmAnswerDialogFragmentViewModel.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/qna/viewmodel/ConfirmAnswerDialogFragmentViewModel.kt @@ -1,5 +1,6 @@ package com.sopt.umbba_android.presentation.qna.viewmodel +import android.os.Bundle import android.util.Log import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel @@ -12,6 +13,18 @@ class ConfirmAnswerDialogFragmentViewModel(private val questionAnswerRepositoryI ViewModel() { var responseStatus = MutableLiveData() + var answer = MutableLiveData() + var question = MutableLiveData() + var section = MutableLiveData() + var topic = MutableLiveData() + + fun setDataFromBundle(bundle: Bundle) { + answer.value = bundle.getString("answer") + question.value = bundle.getString("question") + section.value = bundle.getString("section") + topic.value = bundle.getString("topic") + } + fun postAnswer(answerRequestDto: AnswerRequestDto) { viewModelScope.launch { questionAnswerRepositoryImpl.postAnswer(answerRequestDto) diff --git a/app/src/main/res/layout/fragment_confirm_answer_dialog.xml b/app/src/main/res/layout/fragment_confirm_answer_dialog.xml index e85299a4..3c64bac2 100644 --- a/app/src/main/res/layout/fragment_confirm_answer_dialog.xml +++ b/app/src/main/res/layout/fragment_confirm_answer_dialog.xml @@ -4,7 +4,9 @@ xmlns:tools="http://schemas.android.com/tools"> - + + android:text="@{vm.section}" /> @@ -49,7 +51,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cl_section" - tools:text="#1 가장 오래된 기억" /> + android:text="@{vm.topic}" /> + android:text="@{vm.question}" /> + android:text="@{vm.answer}" />