-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat/#66] 선택 질문 뷰 이동 로직 생성
- Loading branch information
Showing
25 changed files
with
676 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
app/src/main/java/com/sopt/umbba_android/presentation/onboarding/QuestActivity.kt
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
app/src/main/java/com/sopt/umbba_android/presentation/onboarding/QuestSubFragment.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package com.sopt.umbba_android.presentation.onboarding.quest | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.view.View | ||
import androidx.activity.viewModels | ||
import com.sopt.umbba_android.R | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentManager | ||
import androidx.fragment.app.commit | ||
import com.sopt.umbba_android.databinding.ActivityQuestBinding | ||
import com.sopt.umbba_android.presentation.onboarding.NotifyTimeActivity | ||
import com.sopt.umbba_android.presentation.onboarding.SetTimeActivity | ||
import com.sopt.umbba_android.util.binding.BindingActivity | ||
|
||
class QuestActivity : BindingActivity<ActivityQuestBinding>(R.layout.activity_quest), | ||
View.OnClickListener { | ||
|
||
private val viewModel by viewModels<QuestViewModel>() | ||
private var count = 0 | ||
private var quest = arrayOfNulls<String>(5) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding.viewmodel = viewModel | ||
binding.clickListener = this | ||
|
||
initFragment(QuestOneFragment()) | ||
checkNextButtonEnabled() | ||
clickNextButton() | ||
} | ||
|
||
override fun onClick(view: View?) { | ||
when (view?.id) { | ||
R.id.iv_basic_back -> { | ||
if (count in 1..4) { | ||
supportFragmentManager.popBackStack("$count", FragmentManager.POP_BACK_STACK_INCLUSIVE) | ||
binding.progressBar.progress -= 20 | ||
count -= 1 | ||
initChip() | ||
setBeforeButtonClick(count) | ||
} else { | ||
finish() | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun setBeforeButtonClick(count: Int) { | ||
when (quest[count].toString()) { | ||
"응" -> viewModel.isClickedYes.value = true | ||
"아니" -> viewModel.isClickedNo.value = true | ||
"애매해" -> viewModel.isClickedAmbiguous.value = true | ||
} | ||
Log.d("viewmodel", "pop stack : ${count}번 : ${quest[count].toString()}") | ||
} | ||
|
||
private fun initFragment(fragment: Fragment) { | ||
supportFragmentManager.beginTransaction() | ||
.add(R.id.fragment_question, fragment) | ||
.addToBackStack("$count") | ||
.commit() | ||
} | ||
|
||
private fun changeFragment(fragment: Fragment) { | ||
supportFragmentManager.commit { | ||
replace(R.id.fragment_question, fragment) | ||
.addToBackStack("$count") | ||
} | ||
} | ||
|
||
private fun checkNextButtonEnabled() { | ||
viewModel.isClickedComplete.observe(this) { | ||
binding.btnNext.isEnabled = true | ||
} | ||
} | ||
|
||
private fun clickNextButton() { | ||
binding.btnNext.setOnClickListener { | ||
Log.d("viewmodel", "chipText : ${viewModel.clickedChipText.value.toString()}") | ||
Log.d("viewmodel", "count : ${count}") | ||
quest[count] = viewModel.clickedChipText.value.toString() | ||
Log.d("viewmodel", "배열 값 : ${quest[count]}") | ||
initChip() | ||
count += 1 | ||
when (count) { | ||
0 -> changeFragment(QuestOneFragment()) | ||
1 -> changeFragment(QuestTwoFragment()) | ||
2 -> changeFragment(QuestThreeFragment()) | ||
3 -> changeFragment(QuestFourFragment()) | ||
4 -> changeFragment(QuestFiveFragment()) | ||
5 -> { | ||
goNextActivity() | ||
count = 4 | ||
} | ||
} | ||
binding.progressBar.progress += 20 | ||
} | ||
} | ||
|
||
private fun initChip() { | ||
with(viewModel) { | ||
isClickedYes.value = false | ||
isClickedNo.value = false | ||
isClickedAmbiguous.value = false | ||
} | ||
} | ||
|
||
private fun goNextActivity() { | ||
if (true) { //초대하는 측 | ||
startActivity(Intent(this, SetTimeActivity::class.java)) | ||
} else { //초대받는 측 | ||
startActivity(Intent(this, NotifyTimeActivity::class.java)) | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestFiveFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.sopt.umbba_android.presentation.onboarding.quest | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.activityViewModels | ||
import com.sopt.umbba_android.R | ||
import com.sopt.umbba_android.databinding.FragmentQuestFiveBinding | ||
import com.sopt.umbba_android.util.binding.BindingFragment | ||
|
||
class QuestFiveFragment : BindingFragment<FragmentQuestFiveBinding>(R.layout.fragment_quest_five) { | ||
private val viewModel by activityViewModels<QuestViewModel>() | ||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.viewmodel = viewModel | ||
|
||
checkButtonComplete() | ||
} | ||
|
||
private fun checkButtonComplete() { | ||
viewModel.isClickedYes.observe(viewLifecycleOwner) { | ||
viewModel.checkButtonComplete() | ||
viewModel.clickedChipText.value = binding.btnAnswer1.text.toString() | ||
} | ||
viewModel.isClickedNo.observe(viewLifecycleOwner) { | ||
viewModel.checkButtonComplete() | ||
viewModel.clickedChipText.value = binding.btnAnswer2.text.toString() | ||
} | ||
viewModel.isClickedAmbiguous.observe(viewLifecycleOwner) { | ||
viewModel.checkButtonComplete() | ||
viewModel.clickedChipText.value = binding.btnAnswer3.text.toString() | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestFourFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.sopt.umbba_android.presentation.onboarding.quest | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.activityViewModels | ||
import com.sopt.umbba_android.R | ||
import com.sopt.umbba_android.databinding.FragmentQuestFourBinding | ||
import com.sopt.umbba_android.util.binding.BindingFragment | ||
|
||
class QuestFourFragment : BindingFragment<FragmentQuestFourBinding>(R.layout.fragment_quest_four) { | ||
private val viewModel by activityViewModels<QuestViewModel>() | ||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.viewmodel = viewModel | ||
|
||
checkButtonComplete() | ||
} | ||
|
||
private fun checkButtonComplete() { | ||
viewModel.isClickedYes.observe(viewLifecycleOwner) { | ||
viewModel.checkButtonComplete() | ||
viewModel.clickedChipText.value = binding.btnAnswer1.text.toString() | ||
} | ||
viewModel.isClickedNo.observe(viewLifecycleOwner) { | ||
viewModel.checkButtonComplete() | ||
viewModel.clickedChipText.value = binding.btnAnswer2.text.toString() | ||
} | ||
viewModel.isClickedAmbiguous.observe(viewLifecycleOwner) { | ||
viewModel.checkButtonComplete() | ||
viewModel.clickedChipText.value = binding.btnAnswer3.text.toString() | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
app/src/main/java/com/sopt/umbba_android/presentation/onboarding/quest/QuestOneFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.sopt.umbba_android.presentation.onboarding.quest | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.activityViewModels | ||
import com.sopt.umbba_android.R | ||
import com.sopt.umbba_android.databinding.FragmentQuestOneBinding | ||
import com.sopt.umbba_android.util.binding.BindingFragment | ||
|
||
class QuestOneFragment : BindingFragment<FragmentQuestOneBinding>(R.layout.fragment_quest_one) { | ||
|
||
private val viewModel by activityViewModels<QuestViewModel>() | ||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.viewmodel = viewModel | ||
|
||
checkButtonComplete() | ||
} | ||
|
||
private fun checkButtonComplete() { | ||
viewModel.isClickedYes.observe(viewLifecycleOwner) { | ||
viewModel.checkButtonComplete() | ||
viewModel.clickedChipText.value = binding.btnAnswer1.text.toString() | ||
} | ||
viewModel.isClickedNo.observe(viewLifecycleOwner) { | ||
viewModel.checkButtonComplete() | ||
viewModel.clickedChipText.value = binding.btnAnswer2.text.toString() | ||
} | ||
viewModel.isClickedAmbiguous.observe(viewLifecycleOwner) { | ||
viewModel.checkButtonComplete() | ||
viewModel.clickedChipText.value = binding.btnAnswer3.text.toString() | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.