Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/#131] 친해지기 런칭데이 QA #134

Merged
merged 13 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ dependencies {
implementation(libs.androidx.constraintLayout)
implementation(libs.google.oss.plugin)
implementation(libs.play.services.location)
implementation(libs.flexbox)
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
android:usesCleartextTraffic="true"
tools:targetApi="tiramisu">
<activity
android:name=".presentation.shaketopic.ShakeTopicActivity"
android:name=".presentation.familiar.shaketopic.ShakeTopicActivity"
android:exported="false" />
<service
android:name=".config.TeumMessagingService"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FamiliarFragment :
if (!sharedPreferencesManager.isOnboardingCompleted()) {
startActivity(Intent(requireContext(), FamiliarOnBoardingActivity::class.java))
} else {
startActivity(Intent(requireContext(), NeighborActivity::class.java)) //todo - 테스트용 임시 랜딩
startActivity(Intent(requireContext(), NeighborActivity::class.java))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import com.teumteum.base.util.extension.setOnSingleClickListener
import com.teumteum.domain.entity.Friend
import com.teumteum.teumteum.R
import com.teumteum.teumteum.databinding.ActivityIntroduceBinding
import com.teumteum.teumteum.presentation.familiar.FamiliarDialogActivity
import com.teumteum.teumteum.presentation.familiar.FamiliarDialogActivity.Companion.EXTRA_SOURCE
import com.teumteum.teumteum.presentation.familiar.FamiliarDialogActivity.Companion.SOURCE_INTRODUCE
import com.teumteum.teumteum.presentation.familiar.neighbor.NeighborActivity.Companion.EXTRA_NEIGHBORS_IDS
import com.teumteum.teumteum.presentation.familiar.shaketopic.ShakeTopicActivity
import dagger.hilt.android.AndroidEntryPoint
import java.io.Serializable

Expand Down Expand Up @@ -51,15 +49,14 @@ class IntroduceActivity

private fun setUpListener() {
binding.btnStart.setOnSingleClickListener {
startFamiliarDialogActivity()
startShakeTopicActivity()
}
}

private fun startFamiliarDialogActivity() {
private fun startShakeTopicActivity() {
val friends = viewModel.introduceUser.value ?: listOf()
val intent = Intent(this, FamiliarDialogActivity::class.java).apply {
val intent = Intent(this, ShakeTopicActivity::class.java).apply {
putExtra(EXTRA_FRIENDS, ArrayList(friends) as Serializable)
putExtra(EXTRA_SOURCE, SOURCE_INTRODUCE)
}
startActivity(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class IntroduceAdapter() :

with(binding.cardviewBack) {
tvGoalTitle.text = "GOAL"
tvGoalTitle.setTextColor(ResMapper.getColorByCharacterId(itemView.context, item.characterId))
tvGoalContent.text = item.goal

Glide.with(itemView.context)
Expand All @@ -110,7 +111,7 @@ class IntroduceAdapter() :
.into(ivCharacter)

isModify = false
isModifyDetail = false
// isModifyDetail = false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import com.teumteum.base.component.appbar.AppBarLayout
import com.teumteum.base.component.appbar.AppBarMenu
import com.teumteum.base.databinding.LayoutCommonAppbarBinding
import com.teumteum.base.util.extension.setOnSingleClickListener
import com.teumteum.base.util.extension.toast
import com.teumteum.domain.entity.NeighborEntity
import com.teumteum.domain.entity.UserInfo
import com.teumteum.domain.repository.RequestPostNeighborUser
import com.teumteum.teumteum.R
import com.teumteum.teumteum.databinding.ActivityNeighborBinding
import com.teumteum.teumteum.presentation.familiar.introduce.IntroduceActivity
import com.teumteum.teumteum.util.AuthUtils
import com.teumteum.teumteum.util.ResMapper
import com.teumteum.teumteum.util.custom.uistate.UiState
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -32,20 +33,25 @@ class NeighborActivity : BindingActivity<ActivityNeighborBinding>(R.layout.activ
AppBarLayout {
private lateinit var fusedLocationProviderClient: FusedLocationProviderClient
private lateinit var locationCallback: LocationCallback
private var isMyInfoInitialized = false
private val viewModel by viewModels<NeighborViewModel>()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initAppBarLayout()
initMyCharacter()
getMyInfoFromServer()
setUpListener()
setUpObserver()
}

override val appBarBinding: LayoutCommonAppbarBinding
get() = binding.appBar

private fun getMyInfoFromServer() {
viewModel.getMyInfoFromServer()
}

override fun initAppBarLayout() {
setAppBarHeight(48)

Expand All @@ -59,26 +65,6 @@ class NeighborActivity : BindingActivity<ActivityNeighborBinding>(R.layout.activ
)
}

private fun initMyCharacter() {
val myInfo = AuthUtils.getMyInfo(this)
if (myInfo != null) {
Timber.tag("테스트").d("${myInfo.id}")
val view = binding.cvMe
setCharacterView(
neighbor = NeighborEntity(
id = myInfo.id,
name = myInfo.name,
jobDetailClass = myInfo.job.detailClass,
characterId = myInfo.characterId
),
view = view
).apply {
view.isEnabled = false //내 캐릭터 터치 시 체크박스 활성화 방지
}
}
}


private fun setUpListener() {
binding.btnStart.setOnSingleClickListener {
startIntroduceActivity()
Expand Down Expand Up @@ -110,6 +96,31 @@ class NeighborActivity : BindingActivity<ActivityNeighborBinding>(R.layout.activ
viewModel.selectedNeighborIds.observe(this) { selectedIds ->
binding.btnStart.isEnabled = selectedIds.isNotEmpty()
}

viewModel.myInfo.observe(this) { myInfo ->
if (myInfo != null) {
isMyInfoInitialized = true
initMyCharacter(myInfo = myInfo)
} else {
toast("내 정보 조회 실패")
}
}
}

private fun initMyCharacter(myInfo: UserInfo) {
val view = binding.cvMe

setCharacterView(
neighbor = NeighborEntity(
id = myInfo.id,
name = myInfo.name,
jobDetailClass = myInfo.job.detailClass,
characterId = myInfo.characterId
),
view = view
).apply {
view.isEnabled = false //내 캐릭터 터치 시 체크박스 활성화 방지
}
}

private fun setCharacterView(neighbor: NeighborEntity, view: CharacterView) {
Expand Down Expand Up @@ -159,10 +170,12 @@ class NeighborActivity : BindingActivity<ActivityNeighborBinding>(R.layout.activ
for (location in locationResult.locations) {
Timber.tag("Location")
.d("${location.latitude}, ${location.longitude}") //todo - post함수 추가
postNeighborUser(
latitude = location.latitude,
longitude = location.longitude
)
if (isMyInfoInitialized) {
postNeighborUser(
latitude = location.latitude,
longitude = location.longitude
)
}
}
}
}
Expand All @@ -175,8 +188,7 @@ class NeighborActivity : BindingActivity<ActivityNeighborBinding>(R.layout.activ
}

private fun postNeighborUser(latitude: Double, longitude: Double) { //todo - 함수명 수정
val myInfo = AuthUtils.getMyInfo(this)
Timber.tag("getMyInfo").d("$myInfo")
val myInfo = viewModel.getMyInfo()

if (myInfo != null) {
viewModel.postNeighborUser(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.teumteum.domain.entity.NeighborEntity
import com.teumteum.domain.entity.UserInfo
import com.teumteum.domain.repository.NeighborRepository
import com.teumteum.domain.repository.RequestPostNeighborUser
import com.teumteum.domain.repository.UserRepository
import com.teumteum.teumteum.util.custom.uistate.UiState
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class NeighborViewModel @Inject constructor(
private val neighborRepository: NeighborRepository
private val neighborRepository: NeighborRepository,
private val userRepository: UserRepository,
) : ViewModel() {

private var _neighborUserState = MutableLiveData<UiState>(UiState.Empty)
Expand All @@ -27,6 +30,30 @@ class NeighborViewModel @Inject constructor(
val selectedNeighborIds: LiveData<MutableList<Long>>
get() = _selectedNeighborIds

private val _myInfo = MutableLiveData<UserInfo?>()
val myInfo: LiveData<UserInfo?> = _myInfo

private fun saveUserInfo(userInfo: UserInfo) {
userRepository.saveUserInfo(userInfo)
}

fun getMyInfo(): UserInfo? {
return userRepository.getUserInfo()
}

fun getMyInfoFromServer() {
viewModelScope.launch {
userRepository.getMyInfoFromServer()
.onSuccess { //todo - 예외 처리
_myInfo.value = it
saveUserInfo(userInfo = it)
}
.onFailure {
}
}
}


fun addSelectedNeighborId(id: Long) {
val currentList = _selectedNeighborIds.value ?: mutableListOf()
if (!currentList.contains(id)) {
Expand All @@ -48,12 +75,14 @@ class NeighborViewModel @Inject constructor(
runCatching {
_neighborUserState.value = UiState.Loading
neighborRepository.postNeighborUser(requestPostNeighborUser = requestPostNeighborUser)
}.onSuccess { //todo - null 처리
}.onSuccess {
if (it.isEmpty()) {
_neighborUserState.value = UiState.Failure
return@onSuccess
} else {
neighborUsers = it
// id를 기준으로 중복 제거
neighborUsers =
it.distinctBy { neighborEntity -> neighborEntity.id }.toMutableList()
_neighborUserState.value = UiState.Success
}
}.onFailure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class FamiliarOnBoardingAdapter() :
class ItemViewHolder(private val binding: ItemFamiliarOnboardingBinding) :
RecyclerView.ViewHolder(binding.root) {
fun bind(item: FamiliarOnBoarding) {
with(binding) {
tvTitle.text = item.title
with(binding) { tvTitle.text = item.title
tvSubtitle.text = item.subtitle

Glide.with(itemView.context)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.teumteum.teumteum.presentation.shaketopic
package com.teumteum.teumteum.presentation.familiar.shaketopic

import android.os.Bundle
import androidx.activity.viewModels
Expand All @@ -8,8 +8,8 @@ import com.teumteum.domain.entity.Friend
import com.teumteum.teumteum.R
import com.teumteum.teumteum.databinding.ActivityShakeTopicBinding
import com.teumteum.teumteum.presentation.familiar.introduce.IntroduceActivity.Companion.EXTRA_FRIENDS
import com.teumteum.teumteum.presentation.shaketopic.shake.ShakeFragment
import com.teumteum.teumteum.presentation.shaketopic.topic.TopicFragment
import com.teumteum.teumteum.presentation.familiar.shaketopic.shake.ShakeFragment
import com.teumteum.teumteum.presentation.familiar.shaketopic.topic.TopicFragment
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber

Expand Down Expand Up @@ -43,6 +43,7 @@ class ShakeTopicActivity :
}
}
}

fun onShakeCompleted() {
Timber.d("흔들기 3초 완료")
isShakeCompleted = true
Expand Down
Loading
Loading