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 연동 #17

Merged
merged 13 commits into from
Nov 29, 2023
15 changes: 6 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,26 @@
android:theme="@style/Theme.TablingAndroid"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".presentation.store.PopularStoreActivity"
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />

<activity
android:name=".presentation.queue.QueueDetailsActivity"
android:name=".presentation.store.PopularStoreActivity"
android:exported="true"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".presentation.queue.QueueDetailsActivity"
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".presentation.waiting.WaitingDetailActivity"
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
</application>

</manifest>
3 changes: 2 additions & 1 deletion app/src/main/java/org/sopt/tabling/data/ApiFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.sopt.tabling.BuildConfig
import org.sopt.tabling.data.service.PopularStoreService
import retrofit2.Retrofit

object ApiFactory {
Expand All @@ -27,5 +28,5 @@ object ApiFactory {
}

object ServicePool {
// TODO
val popularStoreService = ApiFactory.create<PopularStoreService>()
}
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
Copy link
Contributor

Choose a reason for hiding this comment

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

요기 왜 Response 형태가 아닌가요?? 그래두 상관없는건가여,,? 세미나 때 배운 내용은 꼭 Response<> 안에 담던데ㅜ,ㅜ

Copy link
Member Author

Choose a reason for hiding this comment

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

Call을 하기 위해서 사용하는건데 저는 enqueue를 사용하지 않고 코루틴으로 해보니깐 Call이 필요가 없더라구요!

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,7 +15,7 @@ class PopularStoreActivity :
super.onCreate(savedInstanceState)
binding.storeViewModel = storeViewModel

storeViewModel.setDummyList()
storeViewModel.getPopularStoreList()
initAdapter()
setPopularStoreList()
}
Expand All @@ -27,11 +26,8 @@ class PopularStoreActivity :
}

private fun setPopularStoreList() {
storeViewModel.popularStoreList.observe(
this,
Observer { storeList ->
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

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
Expand Up @@ -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 }
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.

오와!!!! 정렬 어케 할지 고민했는데 이런 식으루 하면 되는구나
난 이용예정 이용완료 스트링으로 오는데 어케 정렬하지

Copy link
Member Author

@Doreminwoo Doreminwoo Nov 28, 2023

Choose a reason for hiding this comment

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

자.. 자... 자동정렬을 애용합시다!
이 정렬이 아니고 sorted였군요 ㅋㅋㅋㅋㅋㅋ
구글과 챗지피티에 검색하면 다 나옵니다!

}.onFailure {
Timber.tag("API").d("error")
Copy link
Contributor

Choose a reason for hiding this comment

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

Timber 누가 알려줬서 ㅠ 미쳐따

Copy link
Member Author

Choose a reason for hiding this comment

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

ㅋㅎㅋㅎ Log 쓰니깐 친절하게 Timber 쓰라고 알려주더라구요

Copy link
Contributor

Choose a reason for hiding this comment

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

Timber 사실 tag 없어두 되지롱 ㅋㅋ 저는 tag 없이 그냥 쓰는 편입니당

}
}
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/shape_gray_200_6.xml
Copy link
Contributor

Choose a reason for hiding this comment

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

60인데 6이라 되어있어용

Copy link
Member 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
@@ -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>
13 changes: 8 additions & 5 deletions app/src/main/res/layout/activity_popular_store.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<com.google.android.material.chip.ChipGroup
android:id="@+id/cg_popular_store_area"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:singleLine="true"
app:singleSelection="true">
Expand Down Expand Up @@ -130,6 +130,7 @@
android:layout_marginTop="16dp"
android:text="@string/popular_store_avg_personnel"
android:textAppearance="@style/TextAppearance.Caption1.SemiBold"
android:textColor="@color/gray_400"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_popular_store_horizontal_1dp" />

Expand All @@ -139,6 +140,7 @@
android:layout_height="wrap_content"
android:text="@string/popular_store_standard"
android:textAppearance="@style/TextAppearance.Caption1.Regular"
android:textColor="@color/gray_400"
app:layout_constraintBottom_toBottomOf="@id/tv_popular_store_avg_people_number"
app:layout_constraintStart_toEndOf="@id/tv_popular_store_avg_people_number"
app:layout_constraintTop_toTopOf="@id/tv_popular_store_avg_people_number" />
Expand All @@ -162,20 +164,21 @@
android:layout_marginStart="2dp"
android:text="@string/popular_store_BEST"
android:textAppearance="@style/TextAppearance.Body1.SemiBold"
android:textColor="@color/gray_800"
app:layout_constraintBottom_toBottomOf="@id/tv_popular_store_area"
app:layout_constraintStart_toEndOf="@id/tv_popular_store_area"
app:layout_constraintTop_toTopOf="@id/tv_popular_store_area" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_popular_store"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_height="0dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="16dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_popular_store_area"
tools:listitem="@layout/item_popular_store" />

Expand Down
13 changes: 9 additions & 4 deletions app/src/main/res/layout/item_popular_store.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,26 @@

<TextView
android:id="@+id/tv_popular_store_number"
android:layout_width="0dp"
android:layout_width="18dp"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:gravity="center"
android:text="@{String.valueOf(storeData.shopId)}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toBottomOf="@id/iv_popular_store"
app:layout_constraintEnd_toStartOf="@id/iv_popular_store"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/iv_popular_store"
tools:text="1" />
tools:text="10" />

<ImageView
android:id="@+id/iv_popular_store"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_marginStart="12dp"
android:layout_marginStart="4dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/shape_gray_200_6"
android:clipToOutline="true"
android:scaleType="centerCrop"
app:image="@{storeData.profilePhotoUrl}"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,15 @@
<style name="Style.Material3.Chip.Suggestion.Waiting.Item" parent="Widget.Material3.Chip.Style">
<item name="android:textAppearance">@style/TextAppearance.Caption2</item>
<item name="chipStrokeColor">@android:color/transparent</item>
<item name="chipCornerRadius">4dp</item>
<item name="android:checkable">false</item>
<item name="android:paddingVertical">2dp</item>
<item name="chipMinTouchTargetSize">0dp</item>
<item name="chipMinHeight">2dp</item>
<item name="chipStartPadding">5dp</item>
<item name="chipEndPadding">5dp</item>
<item name="textStartPadding">0dp</item>
<item name="textEndPadding">0dp</item>
</style>

<style name="Widget.Material3.Chip.Style.Radius95" parent="Widget.Material3.Chip.Style">
Expand Down
Loading