-
Notifications
You must be signed in to change notification settings - Fork 1
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 연동 #17
Changes from 9 commits
c3bb64d
cd1949f
80ff6fc
6fff3aa
cec51a9
c6d9ae9
0a4d74a
ca2e2e2
3c9b904
667eee8
4632e78
113e1b0
57ca887
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.sopt.tabling.data.service | ||
|
||
import org.sopt.tabling.data.model.response.ResponsePopularStoreDto | ||
import retrofit2.http.GET | ||
|
||
interface PopularStoreService { | ||
@GET("/shops") | ||
suspend fun getPopularStore(): ResponsePopularStoreDto | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ package org.sopt.tabling.presentation.store | |
|
||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import androidx.lifecycle.Observer | ||
import org.sopt.tabling.R | ||
import org.sopt.tabling.databinding.ActivityPopularStoreBinding | ||
import org.sopt.tabling.util.binding.BindingActivity | ||
|
@@ -16,7 +15,7 @@ class PopularStoreActivity : | |
super.onCreate(savedInstanceState) | ||
binding.storeViewModel = storeViewModel | ||
|
||
storeViewModel.setDummyList() | ||
storeViewModel.getPopularStoreList() | ||
initAdapter() | ||
setPopularStoreList() | ||
} | ||
|
@@ -27,11 +26,8 @@ class PopularStoreActivity : | |
} | ||
|
||
private fun setPopularStoreList() { | ||
storeViewModel.popularStoreList.observe( | ||
this, | ||
Observer { storeList -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 옵저버 패턴 이런 식으루 쓰는 거구남,, 세미나 듣고 오빠 코드로 복습하구 ~~ 좋으네요 |
||
popularStoreAdapter.setStoreList(storeList) | ||
} | ||
) | ||
storeViewModel.popularStoreList.observe(this) { storeList -> | ||
popularStoreAdapter.setStoreList(storeList) | ||
} | ||
Comment on lines
+29
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 셈나도 안 왔으면서 옵저버 패턴 벌써 잘 하는 거 진짜 체고야 ㅠ |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,81 +2,24 @@ package org.sopt.tabling.presentation.store | |
|
||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import kotlinx.coroutines.launch | ||
import org.sopt.tabling.data.ServicePool | ||
import org.sopt.tabling.data.model.response.ResponsePopularStoreDto | ||
import timber.log.Timber | ||
|
||
class StoreViewModel : ViewModel() { | ||
private val _popularStoreList = MutableLiveData<List<ResponsePopularStoreDto.StoreData>>() | ||
val popularStoreList = _popularStoreList | ||
|
||
fun setDummyList() { | ||
_popularStoreList.value = listOf( | ||
ResponsePopularStoreDto.StoreData( | ||
1, | ||
"파이브가이즈 여의도", | ||
3.0, | ||
64, | ||
"양식", | ||
"여의도동", | ||
4753, | ||
14, | ||
"https://github-production-user-asset-6210df.s3.amazonaws.com/67463603/284251896-4d2f58ad-11c6-466a-828a-bd4290e064e9.png" | ||
), | ||
ResponsePopularStoreDto.StoreData( | ||
2, | ||
"파이브가이즈 여의도", | ||
3.0, | ||
64, | ||
"양식", | ||
"여의도동", | ||
4753, | ||
14, | ||
"https://github-production-user-asset-6210df.s3.amazonaws.com/67463603/284251896-4d2f58ad-11c6-466a-828a-bd4290e064e9.png" | ||
), | ||
ResponsePopularStoreDto.StoreData( | ||
3, | ||
"청화옥 방이점", | ||
2.0, | ||
300, | ||
"양식", | ||
"방이동", | ||
1083, | ||
0, | ||
"https://github-production-user-asset-6210df.s3.amazonaws.com/67463603/284251896-4d2f58ad-11c6-466a-828a-bd4290e064e9.png" | ||
), | ||
ResponsePopularStoreDto.StoreData( | ||
4, | ||
"청화옥 사당직영점", | ||
5.0, | ||
300, | ||
"양식", | ||
"사당동", | ||
852, | ||
0, | ||
"https://github-production-user-asset-6210df.s3.amazonaws.com/67463603/284251896-4d2f58ad-11c6-466a-828a-bd4290e064e9.png" | ||
), | ||
|
||
ResponsePopularStoreDto.StoreData( | ||
5, | ||
"청화옥 양재점", | ||
4.0, | ||
300, | ||
"양식", | ||
"양재동", | ||
773, | ||
1, | ||
"https://github-production-user-asset-6210df.s3.amazonaws.com/67463603/284251896-4d2f58ad-11c6-466a-828a-bd4290e064e9.png" | ||
), | ||
ResponsePopularStoreDto.StoreData( | ||
6, | ||
"아라네 부대찌개 여의도점", | ||
3.0, | ||
300, | ||
"양식", | ||
"여의도동", | ||
631, | ||
0, | ||
"https://github-production-user-asset-6210df.s3.amazonaws.com/67463603/284251896-4d2f58ad-11c6-466a-828a-bd4290e064e9.png" | ||
), | ||
) | ||
fun getPopularStoreList() { | ||
viewModelScope.launch { | ||
val response = runCatching { ServicePool.popularStoreService.getPopularStore() } | ||
response.onSuccess { data -> | ||
_popularStoreList.value = data.storeData.sortedBy { it.shopId } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 정렬까지 야무지네용 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오와!!!! 정렬 어케 할지 고민했는데 이런 식으루 하면 되는구나 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 자.. 자... 자동정렬을 애용합시다! |
||
}.onFailure { | ||
Timber.tag("API").d("error") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Timber 누가 알려줬서 ㅠ 미쳐따 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ㅋㅎㅋㅎ Log 쓰니깐 친절하게 Timber 쓰라고 알려주더라구요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Timber 사실 tag 없어두 되지롱 ㅋㅋ 저는 tag 없이 그냥 쓰는 편입니당 |
||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 60인데 6이라 되어있어용 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 맞아요 확인하느라 그렇게 했었어요 ㅠㅠ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/white" /> | ||
|
||
<stroke | ||
android:width="0.4dp" | ||
android:color="@color/gray_200" /> | ||
|
||
<corners android:radius="6dp" /> | ||
</shape> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요기 왜 Response 형태가 아닌가요?? 그래두 상관없는건가여,,? 세미나 때 배운 내용은 꼭 Response<> 안에 담던데ㅜ,ㅜ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call을 하기 위해서 사용하는건데 저는 enqueue를 사용하지 않고 코루틴으로 해보니깐 Call이 필요가 없더라구요!