diff --git a/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/before/LeaderVoteBeforeFragment.kt b/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/before/LeaderVoteBeforeFragment.kt index 9ff693e..9684482 100644 --- a/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/before/LeaderVoteBeforeFragment.kt +++ b/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/before/LeaderVoteBeforeFragment.kt @@ -49,16 +49,16 @@ class LeaderVoteBeforeFragment : BaseFragment(R private val requestLauncher: ActivityResultLauncher = registerForActivityResult( ActivityResultContracts.StartActivityForResult() - ) { - it.data?.apply { - getBooleanExtra(CRATE_VOTE_SUCCESS_STATE, false).let { isCreateVoteSuccess -> - if (isCreateVoteSuccess) { // 투표 생성 완료 - val extras = Bundle().apply { - putInt(GROUP_ID, groupId) - putExtra(CRATE_VOTE_MSG_EXTRA, this.getString(CRATE_VOTE_MSG_EXTRA)) // 스낵바 메세지 - } - initNavigation(R.id.leaderVoteProgressFragment, extras) + ) { result -> + result.data?.let { data -> + val isCreateVoteSuccess = data.getBooleanExtra(CRATE_VOTE_SUCCESS_STATE, false) + if (isCreateVoteSuccess) { // 투표 생성 완료 + val extras = Bundle().apply { + putInt(GROUP_ID, groupId) + putBoolean(CRATE_VOTE_SUCCESS_STATE, true) // 생성 직후 진행화면으로 넘어온 것인지 확인을 위한 변수 + putString(CRATE_VOTE_MSG_EXTRA, data.getStringExtra(CRATE_VOTE_MSG_EXTRA)) // 스낵바 메세지 } + initNavigation(R.id.leaderVoteProgressFragment, extras) } } } diff --git a/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/create/CreateVoteActivity.kt b/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/create/CreateVoteActivity.kt index 8918cce..8a17ebb 100644 --- a/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/create/CreateVoteActivity.kt +++ b/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/create/CreateVoteActivity.kt @@ -195,13 +195,11 @@ class CreateVoteActivity : BaseActivity(R.layout.acti fun onClickCreateVote() { // viewModel.crateVote(groupId) val message = if (viewModel.hasEndTime.value == true) { - getString(R.string.create_vote_end_time_msg_vote_start) + viewModel.endTimeTxt.value!!.replace("투표가 종료됩니다.", "투표가 자동으로 종료돼요.") + getString(R.string.create_vote_end_time_msg_vote_start) + "\n" + viewModel.endTimeTxt.value!!.replace("투표가 종료됩니다.", "투표가 자동으로 종료돼요.") } else { - getString(R.string.create_vote_end_time_msg_vote_start) + getString(R.string.create_vote_end_time_msg_vote_end) + getString(R.string.create_vote_end_time_msg_vote_start) + "\n" + getString(R.string.create_vote_end_time_msg_vote_end) } - Log.d("kite", message.toString()) - intent.apply { putExtra(CRATE_VOTE_SUCCESS_STATE, true) putExtra(CRATE_VOTE_MSG_EXTRA, message) diff --git a/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/progress/LeaderVoteProgressFragment.kt b/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/progress/LeaderVoteProgressFragment.kt index 03bf7e0..71cc727 100644 --- a/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/progress/LeaderVoteProgressFragment.kt +++ b/app/src/main/java/com/moidot/moidot/presentation/main/group/space/leader/vote/progress/LeaderVoteProgressFragment.kt @@ -1,8 +1,28 @@ package com.moidot.moidot.presentation.main.group.space.leader.vote.progress +import android.os.Bundle +import android.view.View import com.moidot.moidot.R import com.moidot.moidot.databinding.FragmentLeaderVoteProgressBinding import com.moidot.moidot.presentation.base.BaseFragment +import com.moidot.moidot.util.Constant.CRATE_VOTE_MSG_EXTRA +import com.moidot.moidot.util.Constant.CRATE_VOTE_SUCCESS_STATE +import com.moidot.moidot.util.Constant.GROUP_ID +import com.moidot.moidot.util.CustomSnackBar class LeaderVoteProgressFragment : BaseFragment(R.layout.fragment_leader_vote_progress) { + + private val groupId by lazy { arguments?.getInt(GROUP_ID) ?: -1 } + private val voteCreateState by lazy { arguments?.getBoolean(CRATE_VOTE_SUCCESS_STATE) ?: false } + private val voteCreateSnackBarMsg by lazy { arguments?.getString(CRATE_VOTE_MSG_EXTRA) ?: getString(R.string.create_vote_end_time_msg_vote_start) } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + showSnackBarAfterVoteCreation() + } + + private fun showSnackBarAfterVoteCreation() { + if (voteCreateState) CustomSnackBar.makeSnackBar(binding.root, voteCreateSnackBarMsg).show() + } + } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_leader_vote_progress.xml b/app/src/main/res/layout/fragment_leader_vote_progress.xml index 5ab8b29..67ed5d4 100644 --- a/app/src/main/res/layout/fragment_leader_vote_progress.xml +++ b/app/src/main/res/layout/fragment_leader_vote_progress.xml @@ -7,8 +7,7 @@ + android:layout_height="match_parent"> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dc86c56..6e039bd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -177,7 +177,7 @@ 투표 시작하기 날짜 선택 시간 선택 - 투표가 시작되었어요!\n + 투표가 시작되었어요! 종료하기를 누르면 투표가 종료돼요.