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

[둘리] 1, 2단계 쇼핑 장바구니 제출합니다. #20

Merged
merged 52 commits into from
May 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d7cfbc7
docs: 기능 목록 작성
hyemdooly May 9, 2023
2584164
feat: Domain 모듈 생성
hyemdooly May 9, 2023
5ae38d7
feat: 상훔 목록을 관리하는 Repository Interface 생성
hyunji1203 May 9, 2023
d9c9fb4
feat: 장바구니를 관리하는 CartRepository Interface 생성
hyemdooly May 9, 2023
2676ad4
feat: 최근 본 상품 목록을 관리하는 Repository Interface 생성
hyunji1203 May 9, 2023
e65d164
feat: 상품 정보를 담는 Product, 가격을 담는 Price 생성
hyemdooly May 9, 2023
42ca12e
feat: 상품의 정보를 리턴하는 ProductMockRepository 구현
hyunji1203 May 9, 2023
25d3651
feat: ProductListActivity 이미지 제외한 화면 구성 완료
hyemdooly May 9, 2023
ccb8fc1
feat: 메인 색깔 변경
hyemdooly May 9, 2023
52e3bc5
feat: 액션 바에 장바구니 바로가기 메뉴 추가
hyunji1203 May 9, 2023
143e31c
feat: 장바구니 화면의 액션바 안의 백버튼을 누르면 뒤로 이동하는 기능 추가
hyunji1203 May 9, 2023
633ef00
feat: 상품 이미지 Glide 적용
hyemdooly May 9, 2023
1f24cee
refactor: 패키지 이동
hyemdooly May 9, 2023
8dc0249
refactor: ProductListActivity MVP 패턴 적용
hyunji1203 May 9, 2023
7cca774
refactor: 장바구니 아이템 구현
hyemdooly May 10, 2023
f45ba61
feat: 장바구니 리스트 뷰 구현
hyunji1203 May 10, 2023
b58de23
feat: 상품 상세 뷰 구현
hyemdooly May 10, 2023
964767b
feat: 장바구니 DataBase 생성 로직 구현
hyunji1203 May 10, 2023
c2fc7af
feat: CartDbRepository 구현
hyemdooly May 10, 2023
78d597e
feat: ProductList OnClick 추가, DB 적용
hyemdooly May 10, 2023
605c01c
feat: 상품 상세 페이지 액션 바에 뒤로가기 버튼 추가
hyunji1203 May 10, 2023
0aaecc9
refactor: MVP 패턴으로 변경
hyunji1203 May 10, 2023
a2eb1fe
feat: 최근 본 상품 리스트 추가
hyemdooly May 10, 2023
8da62a1
feat: 최근 본 상품 datebase 기능 추가
hyunji1203 May 10, 2023
9270d70
feat: CartProduct DB 적용, 삭제 기능 추가
hyemdooly May 10, 2023
3136470
refactor: find 리턴값 수정
hyemdooly May 11, 2023
3206da5
refactor: notifyItemRemoved 적용
hyemdooly May 11, 2023
b83401a
feat: 페이지네이션 구현 중
hyunji1203 May 11, 2023
f858baa
feat: 더보기 구현중
hyemdooly May 11, 2023
ea478c3
feat: 더보기 구현 완료
hyemdooly May 11, 2023
a143b22
feat: 카트 페이지네이션 구현 중
hyunji1203 May 11, 2023
3bf6ad5
test: ProductListPresenterTest 작성
hyemdooly May 11, 2023
315a8ce
refactor: ProductDetailPresenter cartRepository 추상화 적용
hyemdooly May 11, 2023
9599973
test: ProductDetailPresenter 테스트 추가
hyunji1203 May 11, 2023
8fd10a2
refactor: Pagination 적용중
hyemdooly May 11, 2023
08ccb68
refactor: Pagination 적용중
hyemdooly May 11, 2023
1330e9d
feat: Pagination Button onClick 수정
hyemdooly May 11, 2023
65cee56
fix: 페이지가 넘어가지 않는 오류 수정
hyemdooly May 12, 2023
ef8e6c9
refactor: onCreate 코드 함수 분리
hyemdooly May 12, 2023
bb1c417
refactor: 너무 긴 코드 개행
hyemdooly May 12, 2023
bf285df
refactor: 상수 선언
hyemdooly May 12, 2023
377f7b3
refactor: constraintLayout 자식 뷰 match_parent -> 0dp로 수정
hyemdooly May 12, 2023
11cfe23
refactor: xml formatting
hyemdooly May 12, 2023
4fbc614
refactor: asSequence 사용하여 map 호출 시간 단축
hyemdooly May 12, 2023
68d3fdb
refactor: Next, Prev Pagination 분리
hyemdooly May 13, 2023
5e57cd5
refactor: CartPageStatus 생성, CartAdapter 리팩터링
hyemdooly May 13, 2023
023a703
refactor: LayoutManager xml로 이동
hyemdooly May 13, 2023
d3a1f22
refactor: 상수 선언
hyemdooly May 13, 2023
41b0e02
refactor: CartAdapter에서 CartViewItem 사용하여 Items를 하나로 묶음
hyemdooly May 13, 2023
5eb3cfc
refactor: ProductListActivity 리사이클러뷰 리팩터링
hyemdooly May 13, 2023
6e8f667
test: package 이동, ProductListPresenterTest 수정, CartPresenterTest 작성
hyemdooly May 13, 2023
0b23bbd
refactor: 테스트 코드에서 whildcard import 수정
hyemdooly May 13, 2023
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
Prev Previous commit
Next Next commit
refactor: constraintLayout 자식 뷰 match_parent -> 0dp로 수정
  • Loading branch information
hyemdooly committed May 12, 2023
commit 377f7b30b21e1de74afb176d3d29322cb048542e
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_cart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_cart"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
13 changes: 8 additions & 5 deletions app/src/main/res/layout/activity_product_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

<ImageView
android:id="@+id/img_product"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:src="@drawable/cart" />

<TextView
Expand All @@ -37,14 +38,15 @@
app:layout_constraintTop_toBottomOf="@id/img_product"
tools:text="동원참치" />

<androidx.constraintlayout.widget.ConstraintLayout
<View
android:id="@+id/line_gray"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="13dp"
android:background="@color/gray"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_product_name" />
app:layout_constraintTop_toBottomOf="@id/text_product_name"
app:layout_constraintEnd_toEndOf="parent"/>

<TextView
android:id="@+id/text_price_label"
Expand All @@ -71,7 +73,7 @@

<androidx.appcompat.widget.AppCompatButton

Choose a reason for hiding this comment

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

AppCompatButton과 Button의 차이점은 무엇일까요?

Copy link
Author

@hyemdooly hyemdooly May 13, 2023

Choose a reason for hiding this comment

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

Button을 사용하면 background 속성이 적용되지 않아 AppCompatButton을 사용했습니다.
AppCompatButton 코드를 직접 뜯어봤을 때

Allows dynamic tint of its background via the background tint methods in androidx.core.view.ViewCompat.
Allows setting of the background tint using R.attr.backgroundTint and R.attr.backgroundTintMode.
Allows setting of the font family using android.R.attr.fontFamily

문구를 확인할 수 있었습니다!
background의 색상을 설정할 수 있고 R.attr.fontFamily를 사용한 font family 설정도 허용됩니다!

Copy link

@BeokBeok BeokBeok May 13, 2023

Choose a reason for hiding this comment

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

AppCompatButton 코드까지 직접 뜯어서 보시고 좋습니다. 👍

앞으로 개발하시다보면 보시게 될 AppCompat 은 Application Compatibility의 약자로, "앱 호환성"을 의미합니다.
안드로이드는 OS 버전별로 API가 Deprecated 되기도 하며, API가 변경되기도 합니다.
그렇기에 개발자가 직접 버전 분기 코드를 작성해서 구현을 해줘야하는 번거로움이 있었습니다.
아마 영화극장 미션을 하시면서 보셨을 거에요.

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
            // 권한 요청 거부한 경우
            } else {
                requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
            }
        } else {
             // 안드로이드 12 이하는 Notification에 관한 권한 필요 없음
        }

매번 버전마다 분기처리를 해줘야하는 번거로움을 줄이기 위해, 구글에서 AppCompat 이라는 라이브러리를 지원하기 시작했습니다.
해서, AppCompat을 사용하면 버전분기코드를 작성하지 않아도 내부에서 알아서 버전별로 분기처리를 해주게 되었습니다.

정리하면, AppCompat은 호환성과 관련되어있기 때문에, 아쉽게도 둘리가 수정한 방향은 살짝 빗나갔다고 볼 수 있습니다. 😅

추가로, 구글이 머테리얼 디자인 컴포넌트(MDC)를 적용하게 되면서 background 속성으로 색상 변경을 허용하지 않게 되었으며, background가 아닌 backgroundTint 속성을 적용하면 색상이 변경될 것입니다.

Copy link
Author

Choose a reason for hiding this comment

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

이런 이유로 Compat이 이름에 붙었던거군요!
말씀하신대로 Button에서 backgroundTint를 사용하면 색상이 변경되는 것을 확인했는데요, 그렇다면 지금 디자인처럼 테두리가 있는 버튼일 경우에는 별도의 drawable을 만들어서 AppCompatButton을 사용해야하는 것인가요?
내부에서 분기처리 해주는 AppCompatButton이 Button보다 좋다고 말할 수 있나요?

Choose a reason for hiding this comment

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

지금 디자인처럼 테두리가 있는 버튼일 경우에는 별도의 drawable을 만들어서 AppCompatButton을 사용해야하는 것인가요?

A. 네 맞습니다.

내부에서 분기처리 해주는 AppCompatButton이 Button보다 좋다고 말할 수 있나요?

A. 좋은 질문이에요!
Activity의 코드를 보시면, AppCompatActivity 라는 것을 상속받을거에요.
AppCompatActivity를 상속받게 되면, View를 Inflate하는 과정에서 제일 먼저 AppComatXXX를 사용하도록 구현되어 있어요.
그래서, AppCompatButton이 아닌 Button을 사용해도, 내부적으로는 AppCompatButton을 사용합니다. 😄

Copy link
Author

Choose a reason for hiding this comment

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

그렇군요..! 안드로이드의 세계는 알아야할 것이 참 많네요ㅎㅎ 감사합니다!!😄

android:id="@+id/btn_put_in_cart"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/mint"
android:text="@string/put_in_cart"
Expand All @@ -80,6 +82,7 @@
android:textStyle="bold"
android:onClick="@{()->presenter.putInCart(product)}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_product_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/grid_products"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/item_cart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="15dp"
android:layout_margin="15dp"
android:background="@drawable/back_rounded"
android:paddingHorizontal="13dp"
android:paddingVertical="26dp">
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/res/layout/item_recent_viewed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,34 @@
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="20dp"
android:layout_marginStart="20dp"
android:layout_margin="20dp"
android:text="@string/recent_viewed_product"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/black"
/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_recent_viewed"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:orientation="horizontal"
tools:listitem="@layout/item_recent_viewed_product"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_recent_viewed_product"
android:paddingHorizontal="16dp"
android:clipToPadding="false"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"

<View
android:layout_width="0dp"
android:layout_height="5dp"
android:background="@color/product_list_divider"
app:layout_constraintBottom_toBottomOf="parent" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_recent_viewed_product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<TextView
android:id="@+id/text_name"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="6dp"
Expand Down