Skip to content

Commit

Permalink
Merge pull request #167 from depromeet/fix/#161-seat-review-second-qa…
Browse files Browse the repository at this point in the history
…-final

[FEAT] 시야 등록 2차 MVP 2차 QA
  • Loading branch information
minju1459 authored Aug 29, 2024
2 parents 4580c8e + 2be50b4 commit 2183326
Show file tree
Hide file tree
Showing 22 changed files with 336 additions and 105 deletions.
Binary file modified buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin
Binary file not shown.
Binary file not shown.
Binary file modified buildSrc/build/libs/buildSrc.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import com.depromeet.designsystem.databinding.SpotSnackbarBinding
import com.dpm.designsystem.extension.dpToPx
import com.google.android.material.snackbar.Snackbar


class SpotSnackBar(
view: View,
private val snackBarBackground: Int,
private val message: String,
private val marginBottom: Int,
private val endMessage: String,
private val onClick: () -> Unit
private val onClick: () -> Unit,
private val visibleDialog: () -> Unit = {},
) {
companion object {
fun make(view: View, background: Int = R.drawable.rect_transfer_black_03_fill_60, marginBottom: Int = 0, message: String = "", endMessage: String = "", onClick: () -> Unit) =
SpotSnackBar(view = view, snackBarBackground = background, marginBottom = marginBottom, message= message, endMessage = endMessage, onClick = onClick)
fun make(view: View, background: Int = R.drawable.rect_transfer_black_03_fill_60, marginBottom: Int = 0, message: String = "", endMessage: String = "", onClick: () -> Unit, visibleDialog: () -> Unit = {}) =
SpotSnackBar(view = view, snackBarBackground = background, marginBottom = marginBottom, message = message, endMessage = endMessage, onClick = onClick, visibleDialog = visibleDialog)
}

private val context = view.context
Expand Down Expand Up @@ -57,6 +57,11 @@ class SpotSnackBar(
tvTrigger.text = endMessage
clContainer.setBackgroundResource(snackBarBackground)
}
snackbar.addCallback(object : Snackbar.Callback() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
visibleDialog()
}
})
}

private fun initEvent() {
Expand All @@ -73,4 +78,4 @@ class SpotSnackBar(
fun dismiss() {
snackbar.dismiss()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class ResponseSeatReviewDto(
@SerialName("id")
val id: Int,
@SerialName("member")
val member: Member,
val member: Member?,
@SerialName("stadium")
val stadium: Stadium,
@SerialName("section")
Expand All @@ -19,7 +19,7 @@ data class ResponseSeatReviewDto(
@SerialName("row")
val row: Row,
@SerialName("seat")
val seat: Seat,
val seat: Seat?,
@SerialName("dateTime")
val dateTime: String,
@SerialName("content")
Expand All @@ -39,7 +39,7 @@ data class ResponseSeatReviewDto(
@Serializable
data class Member(
@SerialName("profileImage")
val profileImage: String,
val profileImage: String?,
@SerialName("nickname")
val nickname: String,
@SerialName("level")
Expand Down Expand Up @@ -85,7 +85,7 @@ data class ResponseSeatReviewDto(
@SerialName("id")
val id: Int,
@SerialName("seatNumber")
val seatNumber: Int,
val seatNumber: Int?,
)

@Serializable
Expand Down
125 changes: 83 additions & 42 deletions presentation/src/main/java/com/dpm/presentation/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.dpm.designsystem.SpotSnackBar
import com.dpm.domain.entity.response.home.ResponseHomeFeed
import com.dpm.domain.entity.response.viewfinder.ResponseStadiums
import com.dpm.domain.model.seatreview.ReviewMethod
import com.dpm.domain.preference.SharedPreference
import com.dpm.presentation.extension.dpToPx
import com.dpm.presentation.extension.getCompatibleParcelableExtra
import com.dpm.presentation.home.adapter.StadiumAdapter
Expand All @@ -29,18 +30,23 @@ import com.dpm.presentation.seatrecord.adapter.LinearSpacingItemDecoration
import com.dpm.presentation.seatreview.dialog.ReviewTypeDialog
import com.dpm.presentation.seatreview.dialog.feed.FeedUploadDialog
import com.dpm.presentation.seatreview.dialog.view.ViewUploadDialog
import com.dpm.presentation.seatreview.sample.LevelUpManager
import com.dpm.presentation.setting.SettingActivity
import com.dpm.presentation.util.MixpanelManager
import com.dpm.presentation.util.Utils
import com.dpm.presentation.viewfinder.StadiumActivity
import com.dpm.presentation.viewfinder.StadiumDetailActivity
import com.dpm.presentation.viewfinder.StadiumSelectionActivity
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class HomeActivity : BaseActivity<ActivityHomeBinding>(
ActivityHomeBinding::inflate
ActivityHomeBinding::inflate,
) {
@Inject
lateinit var sharedPreference: SharedPreference

companion object {
const val STADIUM_EXTRA_ID = "stadium_id"
private const val START_SPACING_DP = 16
Expand All @@ -59,15 +65,48 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)


initView()
initEvent()
initObserver()

if (intent.getBooleanExtra("IS_VISIBLE_LEVELUP_DIALOG", false)) {
homeViewModel.getHomeFeed(isVisibleDialog = true) {
if (sharedPreference.level < it.level) {
LevelupDialog(
it.levelTitle,
it.level,
it.mascotImageUrl,
).show(supportFragmentManager, LevelupDialog.TAG)
}
sharedPreference.teamId = it.teamId ?: 0
sharedPreference.levelTitle = it.levelTitle
sharedPreference.teamName = it.teamName ?: ""
sharedPreference.level = it.level
}
}

LevelUpManager.setOnLevelUpListener {
homeViewModel.getHomeFeed(isVisibleDialog = true) {
if (sharedPreference.level < it.level) {
LevelupDialog(
it.levelTitle,
it.level,
it.mascotImageUrl,
).show(supportFragmentManager, LevelupDialog.TAG)
}
sharedPreference.teamId = it.teamId ?: 0
sharedPreference.levelTitle = it.levelTitle
sharedPreference.teamName = it.teamName ?: ""
sharedPreference.level = it.level
}
}
}

override fun onResume() {
super.onResume()
homeViewModel.getHomeFeed()
if (!(intent.getBooleanExtra("IS_VISIBLE_LEVELUP_DIALOG", false))) {
homeViewModel.getHomeFeed()
}
}

private fun initView() {
Expand Down Expand Up @@ -104,17 +143,34 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
message = "시야찾기에 내 게시글이 올라갔어요!",
endMessage = "확인하러 가기",
marginBottom = 87,
) {
val reviewData = intent.getCompatibleParcelableExtra<ReviewData>(REVIEW_DATA)
if (reviewData != null) {
Intent(this@HomeActivity, StadiumDetailActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
putExtra(SchemeKey.STADIUM_ID, reviewData.stadiumId)
putExtra(SchemeKey.BLOCK_CODE, reviewData.blockCode)
putExtra(SchemeKey.REVIEW_ID, reviewData.reviewId)
}.let { startActivity(it) }
onClick = {
val reviewData = intent.getCompatibleParcelableExtra<ReviewData>(REVIEW_DATA)
if (reviewData != null) {
Intent(this@HomeActivity, StadiumDetailActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
putExtra(SchemeKey.STADIUM_ID, reviewData.stadiumId)
putExtra(SchemeKey.BLOCK_CODE, reviewData.blockCode)
putExtra(SchemeKey.REVIEW_ID, reviewData.reviewId)
putExtra("IMAGE_UPLOAD", true)
}.let { startActivity(it) }
}
},
visibleDialog = {
homeViewModel.getHomeFeed(isVisibleDialog = true) {
if (sharedPreference.level < it.level) {
LevelupDialog(
it.levelTitle,
it.level,
it.mascotImageUrl,
).show(supportFragmentManager, LevelupDialog.TAG)
}
sharedPreference.teamId = it.teamId ?: 0
sharedPreference.levelTitle = it.levelTitle
sharedPreference.teamName = it.teamName ?: ""
sharedPreference.level = it.level
}
}
}.show()
).show()
}
}

Expand All @@ -126,9 +182,10 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
private fun initEvent() = with(binding) {
clHomeArchiving.setOnClickListener {
MixpanelManager.track("home_archiving")
startSeatRecordActivity() }
startSeatRecordActivity()
}
ivHomeInfo.setOnClickListener { showLevelDescriptionDialog() }
clHomeScrap.setOnClickListener{
clHomeScrap.setOnClickListener {
MixpanelManager.track("home_scrap")
startScrapActivity()
}
Expand Down Expand Up @@ -181,19 +238,6 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
setHomeFeedShimmer(false)
}
}

}

homeViewModel.levelState.asLiveData().observe(this) {
val currentState = homeViewModel.homeFeed.value
if (it && currentState is UiState.Success) {
LevelupDialog(
currentState.data.levelTitle,
currentState.data.level,
currentState.data.mascotImageUrl
).show(supportFragmentManager, LevelupDialog.TAG)
homeViewModel.levelState.value = false
}
}
}

Expand All @@ -218,30 +262,29 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
message = "현재 잠실야구장만 이용할 수 있어요!",
endMessage = "잠실야구장 보기",
marginBottom = 87,
) {
startStadiumActivity(it)
}.show()
onClick = {startStadiumActivity(it)}
) .show()

} else {
MixpanelManager.track("home_find_view")
startStadiumActivity(it)
}
}
},
)
binding.rvHomeStadium.adapter = stadiumAdapter
binding.rvHomeStadium.addItemDecoration(
LinearSpacingItemDecoration(
START_SPACING_DP.dpToPx(this),
BETWEEN_SPADING_DP.dpToPx(this)
)
BETWEEN_SPADING_DP.dpToPx(this),
),
)
binding.rvHomeStadium.itemAnimator = null
}


private fun startStadiumSelectionActivity() {
Intent(this@HomeActivity, StadiumSelectionActivity::class.java).apply {
startActivity(
this
this,
)
}
}
Expand All @@ -257,7 +300,7 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
private fun startStadiumActivity(stadium: ResponseStadiums) {
val intent = Intent(
this@HomeActivity,
StadiumActivity::class.java
StadiumActivity::class.java,
).apply {
if (stadium.id != 1) {
putExtra(STADIUM_EXTRA_ID, 1)
Expand All @@ -276,11 +319,9 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
if (isLoading) {
shimmerHomeStadium.startShimmer()
shimmerHomeStadium.visibility = View.VISIBLE

} else {
shimmerHomeStadium.stopShimmer()
shimmerHomeStadium.visibility = View.GONE

}
}
private fun setHomeFeedVisibility(isSuccess: Boolean) {
Expand All @@ -306,7 +347,6 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
} else {
csbvHomeTitle.setTextPart("시야 사진 ", data.reviewCntToLevelup, "장 더 올리면 레벨업!")
}

}

private fun navigateToReviewActivity() {
Expand Down Expand Up @@ -334,7 +374,7 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
messageColor = com.depromeet.designsystem.R.color.color_foreground_white,
icon = com.depromeet.designsystem.R.drawable.ic_alert_circle,
iconColor = com.depromeet.designsystem.R.color.color_error_secondary,
marginBottom = 87
marginBottom = 87,
).show()
}

Expand All @@ -360,7 +400,8 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
putExtra(SchemeKey.STADIUM_ID, navReviewDetail.stadiumId)
putExtra(SchemeKey.BLOCK_CODE, navReviewDetail.blockCode)
putExtra(SchemeKey.REVIEW_ID, navReviewDetail.reviewId)
putExtra("IMAGE_UPLOAD", true)
}.let { startActivity(it) }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.dpm.presentation.home.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.dpm.core.state.UiState
Expand Down Expand Up @@ -38,7 +40,7 @@ class HomeGuiViewModel @Inject constructor(
private val _levelUpInfo = MutableStateFlow<UiState<ResponseLevelUpInfo>>(UiState.Loading)
val levelUpInfo = _levelUpInfo.asStateFlow()

val levelState = MutableStateFlow(false)
val levelState = MutableLiveData(false)

fun getStadiums() {
viewModelScope.launch {
Expand All @@ -53,20 +55,25 @@ class HomeGuiViewModel @Inject constructor(
fun getLevelDescription() {
viewModelScope.launch {
homeRepository.getLevelByPost().onSuccess {

_levelDescriptions.value = UiState.Success(it)
}.onFailure {
_levelDescriptions.value = UiState.Failure(it.message.toString())
}
}
}

fun getHomeFeed() {
fun getHomeFeed(
isVisibleDialog: Boolean = false,
onSuccess : (ResponseHomeFeed) -> Unit = {}
) {
viewModelScope.launch {
homeRepository.getHomeFeed().onSuccess {
_homeFeed.value = UiState.Success(it)
putProfileInfo(it)

if (isVisibleDialog) {
onSuccess(it)
} else {
putProfileInfo(it)
}
}.onFailure {
_homeFeed.value = UiState.Failure(it.message.toString())
}
Expand All @@ -83,18 +90,9 @@ class HomeGuiViewModel @Inject constructor(
}
}

private fun checkLevelUp(level: Int) {
if (sharedPreference.level < level && sharedPreference.level != -1) {
levelState.value = true
}
sharedPreference.level = level
}

private fun putProfileInfo(data : ResponseHomeFeed){
checkLevelUp(data.level)
sharedPreference.teamId = data.teamId ?: 0
sharedPreference.levelTitle = data.levelTitle
sharedPreference.teamName = data.teamName ?: ""
sharedPreference.level = data.level
}
}
Loading

0 comments on commit 2183326

Please sign in to comment.