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

[AN] feat: 모임 관련 이벤트 등록 #513

Merged
merged 2 commits into from
Aug 21, 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ object ParamKeys {
const val NEAR_FOOTPRINTS_SIZE = "near_footprints_size"
const val FOOTPRINT_MARK_BTN_HAS_PET = "footprint_mark_btn_has_pet"
const val FOOTPRINT_MARK_BTN_REMAINING_TIME = "footprint_mark_btn_remaining_time"
const val CLUB_PARTICIPATION_FILTER = "club_participation_filter"
const val CLUB_CLUB_FILTER = "club_club_filter"
const val CLUB_ADD_UN_SELECT_FILTER = "club_add_un_filter"
const val CLUB_MEMBER_COUNT = "club_member_count"
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,17 @@ object Types {
const val CLOSE_BTN_CLICKED = "close_btn_clicked"
const val FOOTPRINT_CLICKED = "footprint_clicked"
const val FOOTPRINT_MEMBER_NAME_CLICKED = "footprint_member_name_clicked"
const val CLUB_SELECT_PARTICIPATION_FILTER = "club_select_participation_filter"
const val CLUB_SELECT_CLUB_FILTER = "club_select_club_filter"
const val CLUB_ADD_UN_SELECT_FILTER = "club_add_un_select_filter"
const val CLUB_ADD_MEMBER_COUNT = "club_select_member_count"
const val CLUB_ADD_CLICKED = "club_add_clicked"
const val CLUB_DELETE_CLICKED = "club_delete_clicked"
const val CLUB_PARTICIPATE_CLICKED = "club_participate_clicked"
const val CLUB_UPDATE_CLICKED = "club_update_clicked"
const val CLUB_UPDATE_LOCATION_CLICKED = "club_update_location_clicked"
const val CLUB_CLUB_DETAIL_CLICKED = "club_detail_clicked"
const val CLUB_MY_CLICKED = "club_detail_clicked"
const val CLUB_MY_ADD_BTN_CLICKED = "club_my_add_btn_clicked"
const val CLUB_LIST_ADD_BTN_CLICKED = "club_list_add_btn_clicked"
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.happy.friendogly.presentation.ui.setting.SettingActivity
import com.happy.friendogly.presentation.ui.woof.WoofFragment
import com.happy.friendogly.presentation.utils.logChatListFragmentSwitched
import com.happy.friendogly.presentation.utils.logClubListFragmentSwitched
import com.happy.friendogly.presentation.utils.logMyClubClick
import com.happy.friendogly.presentation.utils.logMyPageFragmentSwitched
import com.happy.friendogly.presentation.utils.logWoofFragmentSwitched

Expand Down Expand Up @@ -157,6 +158,7 @@ class MainActivity :
}

override fun navigateToMyClub(isMyHead: Boolean) {
analyticsHelper.logMyClubClick()
startActivity(MyClubActivity.getIntent(this, isMyHead))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import okhttp3.MultipartBody
class ClubAddActivity : BaseActivity<ActivityClubAddBinding>(R.layout.activity_club_add) {
private val viewModel: ClubAddViewModel by viewModels<ClubAddViewModel> {
ClubAddViewModel.factory(
analyticsHelper = AppModule.getInstance().analyticsHelper,
getAddressUseCase = AppModule.getInstance().getAddressUseCase,
postClubUseCase = AppModule.getInstance().postClubUseCase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.happy.friendogly.analytics.AnalyticsHelper
import com.happy.friendogly.domain.model.UserAddress
import com.happy.friendogly.domain.usecase.GetAddressUseCase
import com.happy.friendogly.domain.usecase.PostClubUseCase
Expand All @@ -23,10 +24,14 @@ import com.happy.friendogly.presentation.ui.club.common.model.ClubFilterSelector
import com.happy.friendogly.presentation.ui.club.common.model.clubfilter.ClubFilter
import com.happy.friendogly.presentation.ui.club.filter.ClubFilterItemActionHandler
import com.happy.friendogly.presentation.utils.addSourceList
import com.happy.friendogly.presentation.utils.logAddClubClick
import com.happy.friendogly.presentation.utils.logSelectClubMemberCount
import com.happy.friendogly.presentation.utils.logUnSelectAddClubFilter
import kotlinx.coroutines.launch
import okhttp3.MultipartBody

class ClubAddViewModel(
private val analyticsHelper: AnalyticsHelper,
private val getAddressUseCase: GetAddressUseCase,
private val postClubUseCase: PostClubUseCase,
) : BaseViewModel(), ClubAddActionHandler, ClubFilterItemActionHandler {
Expand Down Expand Up @@ -81,6 +86,7 @@ class ClubAddViewModel(
}

fun settingClubCounter(count: Int) {
analyticsHelper.logSelectClubMemberCount(count)
_clubCounter.value = ClubCounter(count)
}

Expand Down Expand Up @@ -149,6 +155,7 @@ class ClubAddViewModel(
if (isSelected) {
clubFilterSelector.addClubFilter(clubFilter)
} else {
analyticsHelper.logUnSelectAddClubFilter(filterName)
clubFilterSelector.removeClubFilter(clubFilter)
}
}
Expand All @@ -161,6 +168,7 @@ class ClubAddViewModel(
dogs: List<Long>,
file: MultipartBody.Part?,
) = viewModelScope.launch {
analyticsHelper.logAddClubClick()
postClubUseCase(
title = clubTitle.value ?: return@launch,
content = clubContent.value ?: return@launch,
Expand Down Expand Up @@ -214,11 +222,13 @@ class ClubAddViewModel(
private const val MAX_CONTENT_LENGTH = 1000

fun factory(
analyticsHelper: AnalyticsHelper,
getAddressUseCase: GetAddressUseCase,
postClubUseCase: PostClubUseCase,
): ViewModelProvider.Factory {
return BaseViewModelFactory {
ClubAddViewModel(
analyticsHelper = analyticsHelper,
getAddressUseCase = getAddressUseCase,
postClubUseCase = postClubUseCase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ClubDetailActivity :

private val viewModel: ClubDetailViewModel by viewModels<ClubDetailViewModel> {
ClubDetailViewModel.factory(
analyticsHelper = AppModule.getInstance().analyticsHelper,
getClubUseCase = AppModule.getInstance().getClubUseCase,
postClubMemberUseCase = AppModule.getInstance().postClubMemberUseCase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.happy.friendogly.analytics.AnalyticsHelper
import com.happy.friendogly.domain.usecase.GetClubUseCase
import com.happy.friendogly.domain.usecase.PostClubMemberUseCase
import com.happy.friendogly.presentation.base.BaseViewModel
Expand All @@ -13,9 +14,11 @@ import com.happy.friendogly.presentation.base.emit
import com.happy.friendogly.presentation.ui.club.common.mapper.toPresentation
import com.happy.friendogly.presentation.ui.club.detail.model.ClubDetailViewType
import com.happy.friendogly.presentation.ui.club.modify.ClubModifyUiModel
import com.happy.friendogly.presentation.utils.logParticipateClick
import kotlinx.coroutines.launch

class ClubDetailViewModel(
private val analyticsHelper: AnalyticsHelper,
private val getClubUseCase: GetClubUseCase,
private val postClubMemberUseCase: PostClubMemberUseCase,
) : BaseViewModel(), ClubDetailActionHandler {
Expand Down Expand Up @@ -64,6 +67,7 @@ class ClubDetailViewModel(

fun joinClub(dogs: List<Long>) =
viewModelScope.launch {
analyticsHelper.logParticipateClick()
val clubDetailId = club.value?.clubId ?: return@launch
postClubMemberUseCase(
id = clubDetailId,
Expand All @@ -87,11 +91,13 @@ class ClubDetailViewModel(

companion object {
fun factory(
analyticsHelper: AnalyticsHelper,
getClubUseCase: GetClubUseCase,
postClubMemberUseCase: PostClubMemberUseCase,
): ViewModelProvider.Factory {
return BaseViewModelFactory {
ClubDetailViewModel(
analyticsHelper = analyticsHelper,
getClubUseCase = getClubUseCase,
postClubMemberUseCase = postClubMemberUseCase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ package com.happy.friendogly.presentation.ui.club.filter

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewmodel.viewModelFactory
import com.happy.friendogly.analytics.AnalyticsHelper
import com.happy.friendogly.presentation.base.BaseViewModel
import com.happy.friendogly.presentation.base.Event
import com.happy.friendogly.presentation.base.emit
import com.happy.friendogly.presentation.ui.club.common.model.ClubFilterSelector
import com.happy.friendogly.presentation.ui.club.common.model.clubfilter.ClubFilter
import com.happy.friendogly.presentation.ui.club.common.model.clubfilter.ParticipationFilter
import com.happy.friendogly.presentation.utils.logSelectClubFilter
import com.happy.friendogly.presentation.utils.logSelectParticipationFilter

class ClubFilterViewModel : BaseViewModel(), ClubFilterItemActionHandler, ClubFilterActionHandler {
class ClubFilterViewModel(
private val analyticsHelper: AnalyticsHelper,
) : BaseViewModel(), ClubFilterItemActionHandler, ClubFilterActionHandler {
private val _clubFilterEvent: MutableLiveData<Event<ClubFilterEvent>> = MutableLiveData()
val clubFilterEvent: LiveData<Event<ClubFilterEvent>> get() = _clubFilterEvent

Expand All @@ -18,6 +25,7 @@ class ClubFilterViewModel : BaseViewModel(), ClubFilterItemActionHandler, ClubFi
private val clubFilterSelector = ClubFilterSelector()

fun updateParticipationFilter(participationFilter: ParticipationFilter) {
analyticsHelper.logSelectParticipationFilter(participationFilter.filterName)
this.participationFilter = participationFilter
}

Expand Down Expand Up @@ -49,9 +57,20 @@ class ClubFilterViewModel : BaseViewModel(), ClubFilterItemActionHandler, ClubFi
) {
val clubFilter = ClubFilter.findClubFilter(filterName) ?: return
if (isSelected) {
analyticsHelper.logSelectClubFilter(filterName)
clubFilterSelector.addClubFilter(clubFilter)
} else {
clubFilterSelector.removeClubFilter(clubFilter)
}
}

companion object {
fun factory(analyticsHelper: AnalyticsHelper): ViewModelProvider.Factory {
return viewModelFactory {
ClubFilterViewModel(
analyticsHelper = analyticsHelper,
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.happy.friendogly.application.di.AppModule
import com.happy.friendogly.databinding.BottomSheetFilterSizeSelectorBinding
import com.happy.friendogly.databinding.BottomSheetGenderFilterSelectorBinding
import com.happy.friendogly.presentation.base.observeEvent
Expand All @@ -26,7 +27,11 @@ class ClubFilterBottomSheet(
private val genderBinding: BottomSheetGenderFilterSelectorBinding
get() = _genderBinding!!

private val viewModel: ClubFilterViewModel by viewModels()
private val viewModel: ClubFilterViewModel by viewModels<ClubFilterViewModel> {
ClubFilterViewModel.factory(
analyticsHelper = AppModule.getInstance().analyticsHelper,
)
}

override fun onCreateView(
inflater: LayoutInflater,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.happy.friendogly.R
import com.happy.friendogly.application.di.AppModule
import com.happy.friendogly.databinding.BottomSheetParticipationFilterSelectorBinding
import com.happy.friendogly.presentation.base.observeEvent
import com.happy.friendogly.presentation.ui.club.common.model.clubfilter.ParticipationFilter
Expand All @@ -21,7 +22,11 @@ class ParticipationFilterBottomSheet(
val binding: BottomSheetParticipationFilterSelectorBinding
get() = _binding!!

private val viewModel: ClubFilterViewModel by viewModels()
private val viewModel: ClubFilterViewModel by viewModels<ClubFilterViewModel> {
ClubFilterViewModel.factory(
analyticsHelper = AppModule.getInstance().analyticsHelper,
)
}

override fun onCreateView(
inflater: LayoutInflater,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ClubListFragment : BaseFragment<FragmentClubListBinding>(R.layout.fragment

private val viewModel: ClubListViewModel by viewModels<ClubListViewModel> {
ClubListViewModel.factory(
analyticsHelper = AppModule.getInstance().analyticsHelper,
getPetsMineUseCase = AppModule.getInstance().getPetsMineUseCase,
getAddressUseCase = AppModule.getInstance().getAddressUseCase,
searchingClubsUseCase = AppModule.getInstance().getSearchingClubsUseCase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.happy.friendogly.analytics.AnalyticsHelper
import com.happy.friendogly.domain.fold
import com.happy.friendogly.domain.model.Pet
import com.happy.friendogly.domain.model.UserAddress
Expand All @@ -23,9 +24,13 @@ import com.happy.friendogly.presentation.ui.club.common.model.ClubFilterSelector
import com.happy.friendogly.presentation.ui.club.common.model.ClubItemUiModel
import com.happy.friendogly.presentation.ui.club.common.model.clubfilter.ClubFilter
import com.happy.friendogly.presentation.ui.club.common.model.clubfilter.ParticipationFilter
import com.happy.friendogly.presentation.utils.logClubDetailClick
import com.happy.friendogly.presentation.utils.logListAddClubClick
import com.happy.friendogly.presentation.utils.logUpdateUserLocation
import kotlinx.coroutines.launch

class ClubListViewModel(
private val analyticsHelper: AnalyticsHelper,
private val getPetsMineUseCase: GetPetsMineUseCase,
private val getAddressUseCase: GetAddressUseCase,
private val searchingClubsUseCase: GetSearchingClubsUseCase,
Expand Down Expand Up @@ -114,10 +119,12 @@ class ClubListViewModel(
}

override fun loadClub(clubId: Long) {
analyticsHelper.logClubDetailClick()
_clubListEvent.emit(ClubListEvent.OpenClub(clubId))
}

override fun addClub() {
analyticsHelper.logListAddClubClick()
applyAddClubState()
}

Expand Down Expand Up @@ -170,6 +177,7 @@ class ClubListViewModel(
}

override fun addMyLocation() {
analyticsHelper.logUpdateUserLocation()
_clubListEvent.emit(
ClubListEvent.Navigation.NavigateToAddress,
)
Expand All @@ -179,12 +187,14 @@ class ClubListViewModel(

companion object {
fun factory(
analyticsHelper: AnalyticsHelper,
getPetsMineUseCase: GetPetsMineUseCase,
getAddressUseCase: GetAddressUseCase,
searchingClubsUseCase: GetSearchingClubsUseCase,
): ViewModelProvider.Factory {
return BaseViewModelFactory {
ClubListViewModel(
analyticsHelper = analyticsHelper,
getPetsMineUseCase = getPetsMineUseCase,
getAddressUseCase = getAddressUseCase,
searchingClubsUseCase = searchingClubsUseCase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ClubMenuBottomSheet(

private val viewModel: ClubMenuViewModel by viewModels<ClubMenuViewModel> {
ClubMenuViewModel.factory(
analyticsHelper = AppModule.getInstance().analyticsHelper,
deleteClubMemberUseCase = AppModule.getInstance().deleteClubMemberUseCase,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.happy.friendogly.analytics.AnalyticsHelper
import com.happy.friendogly.domain.usecase.DeleteClubMemberUseCase
import com.happy.friendogly.presentation.base.BaseViewModel
import com.happy.friendogly.presentation.base.BaseViewModelFactory
import com.happy.friendogly.presentation.base.Event
import com.happy.friendogly.presentation.base.emit
import com.happy.friendogly.presentation.ui.club.detail.model.ClubDetailViewType
import com.happy.friendogly.presentation.utils.logDeleteMemberClick
import com.happy.friendogly.presentation.utils.logUpdateClubClick
import kotlinx.coroutines.launch

class ClubMenuViewModel(
private val analyticsHelper: AnalyticsHelper,
private val deleteClubMemberUseCase: DeleteClubMemberUseCase,
) : BaseViewModel(), ClubMenuActionHandler {
private val _clubMenuEvent: MutableLiveData<Event<ClubMenuEvent>> = MutableLiveData()
Expand Down Expand Up @@ -42,10 +46,12 @@ class ClubMenuViewModel(
}

override fun selectModify() {
analyticsHelper.logUpdateClubClick()
_clubMenuEvent.emit(ClubMenuEvent.Modify)
}

override fun selectDelete() {
analyticsHelper.logDeleteMemberClick()
_clubMenuEvent.emit(ClubMenuEvent.Delete)
}

Expand All @@ -58,9 +64,13 @@ class ClubMenuViewModel(
}

companion object {
fun factory(deleteClubMemberUseCase: DeleteClubMemberUseCase): ViewModelProvider.Factory {
fun factory(
analyticsHelper: AnalyticsHelper,
deleteClubMemberUseCase: DeleteClubMemberUseCase,
): ViewModelProvider.Factory {
return BaseViewModelFactory {
ClubMenuViewModel(
analyticsHelper = analyticsHelper,
deleteClubMemberUseCase = deleteClubMemberUseCase,
)
}
Expand Down
Loading
Loading