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

feat: 약속 목록 조회 api 연결 #279

Merged
merged 8 commits into from
Aug 6, 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
9 changes: 1 addition & 8 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".presentation.meetinglist.MeetingsActivity"
android:name=".presentation.home.HomeActivity"
android:exported="false"
android:screenOrientation="portrait"/>

<activity
android:name=".presentation.FloatingButtonActivity"
android:exported="true" />
<activity
android:name=".presentation.invitecode.InviteCodeActivity"
android:exported="false"
Expand Down Expand Up @@ -69,10 +66,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".presentation.intro.IntroActivity"
android:exported="false"
android:screenOrientation="portrait" />

<service
android:name=".data.remote.thirdparty.fcm.service.FCMService"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.woowacourse.ody.data.remote.core.entity.meeting.mapper

import com.woowacourse.ody.data.remote.core.entity.meeting.response.MeetingCatalogResponse
import com.woowacourse.ody.data.remote.core.entity.meeting.response.MeetingCatalogsResponse
import com.woowacourse.ody.domain.model.MeetingCatalog
import java.time.LocalDate
import java.time.LocalTime

fun MeetingCatalogResponse.toMeetingCatalog(): MeetingCatalog {
val date = LocalDate.parse(date)
val time = LocalTime.parse(time)
val dateTime = date.atTime(time)
return MeetingCatalog(
durationMinutes = durationMinutes,
id = id,
mateCount = mateCount,
name = name,
originAddress = originAddress,
targetAddress = targetAddress,
datetime = dateTime,
)
}

fun MeetingCatalogsResponse.toMeetingCatalogs(): List<MeetingCatalog> = meetingCatalogs.map { it.toMeetingCatalog() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 함수가 안 쓰이고 있는 것 같은데, DefaultMeetingRepository에서 사용하면 될 것 같네요

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.woowacourse.ody.data.remote.core.entity.meeting.response

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class MeetingCatalogResponse(
@Json(name = "date")
val date: String,
@Json(name = "durationMinutes")
val durationMinutes: Int,
@Json(name = "id")
val id: Long,
@Json(name = "mateCount")
val mateCount: Int,
@Json(name = "name")
val name: String,
@Json(name = "originAddress")
val originAddress: String,
@Json(name = "targetAddress")
val targetAddress: String,
@Json(name = "time")
val time: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.woowacourse.ody.data.remote.core.entity.meeting.response

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class MeetingCatalogsResponse(
@Json(name = "meetings")
val meetingCatalogs: List<MeetingCatalogResponse>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package com.woowacourse.ody.data.remote.core.repository

import com.woowacourse.ody.data.remote.core.entity.meeting.mapper.toMateEtas
import com.woowacourse.ody.data.remote.core.entity.meeting.mapper.toMeeting
import com.woowacourse.ody.data.remote.core.entity.meeting.mapper.toMeetingCatalogs
import com.woowacourse.ody.data.remote.core.entity.meeting.mapper.toMeetingRequest
import com.woowacourse.ody.data.remote.core.entity.meeting.request.MatesEtaRequest
import com.woowacourse.ody.data.remote.core.service.MeetingService
import com.woowacourse.ody.domain.model.MateEta
import com.woowacourse.ody.domain.model.Meeting
import com.woowacourse.ody.domain.model.MeetingCatalog
import com.woowacourse.ody.domain.model.MeetingCreationInfo
import com.woowacourse.ody.domain.repository.ody.MeetingRepository

Expand Down Expand Up @@ -35,4 +37,9 @@ class DefaultMeetingRepository(private val service: MeetingService) : MeetingRep
).toMateEtas()
}
}

override suspend fun fetchMeetingCatalogs(): Result<List<MeetingCatalog>> =
runCatching {
service.fetchMeetingCatalogs().toMeetingCatalogs()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.woowacourse.ody.data.remote.core.service
import com.woowacourse.ody.data.remote.core.entity.meeting.request.MatesEtaRequest
import com.woowacourse.ody.data.remote.core.entity.meeting.request.MeetingRequest
import com.woowacourse.ody.data.remote.core.entity.meeting.response.MatesEtaResponse
import com.woowacourse.ody.data.remote.core.entity.meeting.response.MeetingCatalogsResponse
import com.woowacourse.ody.data.remote.core.entity.meeting.response.MeetingCreationResponse
import com.woowacourse.ody.data.remote.core.entity.meeting.response.MeetingsResponse
import retrofit2.http.Body
Expand Down Expand Up @@ -31,6 +32,9 @@ interface MeetingService {
@Body matesEtaRequest: MatesEtaRequest,
): MatesEtaResponse

@GET("/v1/meetings/me")
suspend fun fetchMeetingCatalogs(): MeetingCatalogsResponse

companion object {
const val MEETING_PATH = "/meetings/me"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.woowacourse.ody.domain.model

import java.time.LocalDateTime

data class MeetingCatalog(
val durationMinutes: Int,
val id: Long,
val mateCount: Int,
val name: String,
val originAddress: String,
val targetAddress: String,
val datetime: LocalDateTime,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.woowacourse.ody.domain.repository.ody

import com.woowacourse.ody.domain.model.MateEta
import com.woowacourse.ody.domain.model.Meeting
import com.woowacourse.ody.domain.model.MeetingCatalog
import com.woowacourse.ody.domain.model.MeetingCreationInfo

interface MeetingRepository {
Expand All @@ -17,4 +18,6 @@ interface MeetingRepository {
currentLatitude: String,
currentLongitude: String,
): Result<List<MateEta>>

suspend fun fetchMeetingCatalogs(): Result<List<MeetingCatalog>>
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.woowacourse.ody.presentation.creation.date.MeetingDateFragment
import com.woowacourse.ody.presentation.creation.destination.MeetingDestinationFragment
import com.woowacourse.ody.presentation.creation.name.MeetingNameFragment
import com.woowacourse.ody.presentation.creation.time.MeetingTimeFragment
import com.woowacourse.ody.presentation.intro.IntroActivity
import com.woowacourse.ody.presentation.home.HomeActivity
import com.woowacourse.ody.presentation.join.MeetingJoinActivity

class MeetingCreationActivity :
Expand Down Expand Up @@ -85,8 +85,8 @@ class MeetingCreationActivity :

viewModel.navigateAction.observe(this) {
when (it) {
MeetingCreationNavigateAction.NavigateToIntro -> {
startActivity(IntroActivity.getIntent(this))
MeetingCreationNavigateAction.NavigateToHome -> {
startActivity(HomeActivity.getIntent(this))
}

MeetingCreationNavigateAction.NavigateToCreationComplete -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.woowacourse.ody.presentation.creation

sealed interface MeetingCreationNavigateAction {
data object NavigateToIntro : MeetingCreationNavigateAction
data object NavigateToHome : MeetingCreationNavigateAction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

궁금한게 있는데.. 모임 개설 후에 바로 모임 리스트로 이동하는 경우가 있나요??
저는 "모임 개설 -> 모임 참여 -> 모임방"으로 이동하는 플로우라고 생각했는데요.
그래서 개설에서는 개설 완료 화면이나 모임 참여 화면으로만 이동할 수 있다고 생각했습니다.
혹시 제가 잘못 이해한 걸까봐 여쭤봅니다~!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 사용하고 있는 쪽 쫓아가보니까, back 버튼 눌렀을 때 아예 새로운 홈 화면을 시작해주네요. 기존 구현이 이런 방식이었네요.. ㄷㄷ
홈 화면이 이미 백스택에 쌓여있으니까, 새로운 홈 화면을 생성하지 않고 바로 finish 하면 될 것 같은데요. 일단은 이대로 냅두고 추후 다같이 리팩터링 논의 해봅시당

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"모임 개설 -> 모임 참여 -> 모임방" 이 맞죠.
Intro로 진입하는 부분 있기에 이름 고치는 과정에서 저기까지 고치긴 했는데, 필요 없으리라 여겨짐..


data object NavigateToCreationComplete : MeetingCreationNavigateAction
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class MeetingCreationViewModel(
}

fun navigateToIntro() {
_navigateAction.setValue(MeetingCreationNavigateAction.NavigateToIntro)
_navigateAction.setValue(MeetingCreationNavigateAction.NavigateToHome)
}

override fun onClickCreationMeeting() {
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HomeActivity 말고 MeetingsActivity로 네이밍 해주는 건 어떨까요?
만약 홈화면에 meeting 리스트가 아닌 다른 화면이 들어오도록 기획이 변경된다면, 새로운 HomeActivity를 생성하고 MeetingsActivity에 기존 HomeActivity 내용을 붙여넣는 매우 귀찮은 작업이 생길 것 같아요.
특정 화면을 홈화면이라고 명확하게 네이밍하기 보다는, 그 화면의 역할에 대해 네이밍해주는 것이 변경에 유연하다고 생각합니다!

Copy link
Contributor Author

@aprilgom aprilgom Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음.. 통일시에 헷갈려서 일부러 변경한 사양이긴 했는데, 저도 Meetings~처럼 명확한 게 좋다고 생각합니다.
MeetingCatalogsActivity는 어떨까요?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

�저는 MeetingsActivity가 직관적이라 더 취향이긴 합니다.. Catalog는 어떤 의미로 넣으셨는지도 궁금해요~!
네이밍 관련해서는 내일 오프라인으로 다같이 얘기해봐도 좋을 것 같아요.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그럽시다!

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.woowacourse.ody.presentation.intro
package com.woowacourse.ody.presentation.home

import android.Manifest
import android.app.AlertDialog
Expand All @@ -8,18 +8,36 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
import androidx.annotation.RequiresApi
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.woowacourse.ody.R
import com.woowacourse.ody.databinding.ActivityIntroBinding
import com.woowacourse.ody.databinding.ActivityHomeBinding
import com.woowacourse.ody.presentation.common.binding.BindingActivity
import com.woowacourse.ody.presentation.creation.MeetingCreationActivity
import com.woowacourse.ody.presentation.home.adapter.MeetingCatalogsAdapter
import com.woowacourse.ody.presentation.home.listener.HomeListener
import com.woowacourse.ody.presentation.invitecode.InviteCodeActivity

class IntroActivity : BindingActivity<ActivityIntroBinding>(R.layout.activity_intro) {
private val viewModel: IntroViewModel by viewModels()
import com.woowacourse.ody.presentation.room.log.NotificationLogActivity

class HomeActivity :
BindingActivity<ActivityHomeBinding>(
R.layout.activity_home,
),
HomeListener {
private val viewModel by viewModels<HomeViewModel> {
HomeViewModelFactory(
application.meetingRepository,
)
}
private val adapter by lazy {
MeetingCatalogsAdapter(
viewModel,
this,
)
Comment on lines +36 to +39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapter에 viewModel을 전달하기 보다, Listener interface로 추상화해서 그 Listener만 전달하면 어떨까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리스너로 고쳐주었습니다.

}

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -29,30 +47,46 @@ class IntroActivity : BindingActivity<ActivityIntroBinding>(R.layout.activity_in
requestPermissions()
}

override fun onResume() {
super.onResume()
viewModel.fetchMeetingCatalogs()
}

override fun initializeBinding() {
binding.listener = viewModel
binding.rvMeetingList.adapter = adapter
binding.listener = this
}

private fun initializeObserve() {
viewModel.navigateAction.observe(this) { navigateAction ->
when (navigateAction) {
is IntroNavigateAction.NavigateToMeetingInfo ->
navigateToMeetingInfoActivity()

is IntroNavigateAction.NavigateToInviteCode ->
navigateToInviteCodeActivity()
}
viewModel.meetingCatalogs.observe(this) {
adapter.submitList(it)
}
viewModel.isMeetingCatalogsEmpty.observe(this) {
binding.isCatalogsEmpty = it
}
}

private fun navigateToMeetingInfoActivity() {
startActivity(MeetingCreationActivity.getIntent(this))
override fun onFab() {
binding.cvMenuView.visibility = if (binding.fabHomeNavigator.isSelected) View.GONE else View.VISIBLE
binding.fabHomeNavigator.isSelected = !binding.fabHomeNavigator.isSelected
}

private fun navigateToInviteCodeActivity() {
override fun onJoinMeeting() {
startActivity(InviteCodeActivity.getIntent(this))
}

override fun onCreateMeeting() {
startActivity(MeetingCreationActivity.getIntent(this))
}

override fun navigateToMeetingRoom(meetingId: Long) {
startActivity(NotificationLogActivity.getIntent(this, meetingId))
}

override fun guideItemDisabled() {
showSnackBar(R.string.intro_notification_permission_required)
}

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
private fun requestPermissions() {
if (ContextCompat.checkSelfPermission(
Expand Down Expand Up @@ -148,6 +182,6 @@ class IntroActivity : BindingActivity<ActivityIntroBinding>(R.layout.activity_in
private const val PERMISSIONS_REQUEST_CODE = 1
private const val PERMISSION_REQUEST_CODE = 2

fun getIntent(context: Context): Intent = Intent(context, IntroActivity::class.java)
fun getIntent(context: Context): Intent = Intent(context, HomeActivity::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.woowacourse.ody.presentation.meetinglist
package com.woowacourse.ody.presentation.home

import android.widget.TextView
import androidx.databinding.BindingAdapter
Expand All @@ -18,16 +18,16 @@ fun TextView.showDateTime(dateTime: LocalDateTime) {
val dateString =
when {
isToday -> {
context.getString(R.string.intro_today)
context.getString(R.string.home_today)
}

isTomorrow -> {
context.getString(R.string.intro_tomorrow)
context.getString(R.string.home_tomorrow)
}

meetingDay <= today.plusDays(7) -> {
context.getString(
R.string.intro_post_tomorrow,
R.string.home_post_tomorrow,
(meetingDay.dayOfYear - today.dayOfYear).toString(),
)
}
Expand Down
Loading