Skip to content

Commit

Permalink
[둘리] 1, 2단계 쇼핑 장바구니 제출합니다. (#20)
Browse files Browse the repository at this point in the history
* docs: 기능 목록 작성

* feat: Domain 모듈 생성

* feat: 상훔 목록을 관리하는 Repository Interface 생성

* feat: 장바구니를 관리하는 CartRepository Interface 생성

* feat: 최근 본 상품 목록을 관리하는 Repository Interface 생성

* feat: 상품 정보를 담는 Product, 가격을 담는 Price 생성

* feat: 상품의 정보를 리턴하는 ProductMockRepository 구현

* feat: ProductListActivity 이미지 제외한 화면 구성 완료

* feat: 메인 색깔 변경

* feat: 액션 바에 장바구니 바로가기 메뉴 추가

* feat: 장바구니 화면의 액션바 안의 백버튼을 누르면 뒤로 이동하는 기능 추가

* feat: 상품 이미지 Glide 적용

* refactor: 패키지 이동

* refactor: ProductListActivity MVP 패턴 적용

* refactor: 장바구니 아이템 구현

* feat: 장바구니 리스트 뷰 구현

* feat: 상품 상세 뷰 구현

* feat: 장바구니 DataBase 생성 로직 구현

* feat: CartDbRepository 구현

* feat: ProductList OnClick 추가, DB 적용

* feat: 상품 상세 페이지 액션 바에 뒤로가기 버튼 추가

* refactor: MVP 패턴으로 변경

* feat: 최근 본 상품 리스트 추가

* feat: 최근 본 상품 datebase 기능 추가

* feat: CartProduct DB 적용, 삭제 기능 추가

* refactor: find 리턴값 수정

* refactor: notifyItemRemoved 적용

* feat: 페이지네이션 구현 중

* feat: 더보기 구현중

* feat: 더보기 구현 완료

* feat: 카트 페이지네이션 구현 중

* test: ProductListPresenterTest 작성

* refactor: ProductDetailPresenter cartRepository 추상화 적용

* test: ProductDetailPresenter 테스트 추가

* refactor: Pagination 적용중

* refactor: Pagination 적용중

* feat: Pagination Button onClick 수정

* fix: 페이지가 넘어가지 않는 오류 수정

* refactor: onCreate 코드 함수 분리

* refactor: 너무 긴 코드 개행

* refactor: 상수 선언

* refactor: constraintLayout 자식 뷰 match_parent -> 0dp로 수정

* refactor: xml formatting

* refactor: asSequence 사용하여 map 호출 시간 단축

* refactor: Next, Prev Pagination 분리

* refactor: CartPageStatus 생성, CartAdapter 리팩터링

* refactor: LayoutManager xml로 이동

* refactor: 상수 선언

* refactor: CartAdapter에서 CartViewItem 사용하여 Items를 하나로 묶음

* refactor: ProductListActivity 리사이클러뷰 리팩터링

* test: package 이동, ProductListPresenterTest 수정, CartPresenterTest 작성

* refactor: 테스트 코드에서 whildcard import 수정

---------

Co-authored-by: hyunji1203 <[email protected]>
  • Loading branch information
hyemdooly and hyunji1203 committed May 14, 2023
1 parent 186fb7f commit a2c85ac
Show file tree
Hide file tree
Showing 79 changed files with 2,811 additions and 24 deletions.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# android-shopping-cart
# android-shopping-cart
## Domain
### ProductRepository
- [ ] 상품 목록을 가져올 수 있다.
### CartRepository
- [ ] 장바구니의 상품 목록을 가져올 수 있다.
- [ ] 장바구니에 상품을 추가할 수 있다.
- [ ] 장바구니에 상품을 삭제할 수 있다.
### RecentViewedRepository
- [ ] 사용자가 상품의 상세 정보를 조회하면 목록에 추가한다.
- [ ] 만약 10개가 넘어갔을 경우 가장 오래 된 상품을 삭제한다.
- [ ] 최근 본 상품 목록을 가져올 수 있다.
### Product
- name : 이름
- imageUrl : 이미지 URL
- price : 가격
### Price
- price : 가격
## View
- [ ] 앱이 종료돼도 최근 본 상품 목록과 장바구니 데이터는 유지돼야 한다.
### ProductListActivity
- [ ] 상품을 클릭하면 상품 상세로 이동한다.
- [ ] 최근 본 상품이 있는 경우 상품 목록 상단에서 10개까지 확인할 수 있다.
- [X] 툴바 안의 카트 버튼을 누르면 장바구니로 이동한다.
### ProductDetailActivity
- [ ] 사용자는 상품을 장바구니에 추가할 수 있다.
### CartActivity
- [ ] 장바구니에서 원하는 상품을 삭제할 수 있다.
- [X] 툴바 안의 백버튼을 누르면 뒤로 이동한다.

11 changes: 10 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-parcelize")
}

android {
Expand All @@ -22,7 +23,7 @@ android {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)
}
}
Expand All @@ -33,14 +34,22 @@ android {
kotlinOptions {
jvmTarget = "11"
}

buildFeatures {
dataBinding = true
viewBinding = true
}
}

dependencies {
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.6.0")
implementation("com.google.android.material:material:1.7.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation(project(mapOf("path" to ":domain")))
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
implementation("com.github.bumptech.glide:glide:4.15.1")
testImplementation("io.mockk:mockk:1.13.5")
}
11 changes: 10 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http:https://schemas.android.com/apk/res/android"
xmlns:tools="http:https://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -12,7 +14,14 @@
android:theme="@style/Theme.Shopping"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".view.productdetail.ProductDetailActivity"
android:exported="false" />
<activity
android:name=".view.cart.CartActivity"
android:exported="false"
android:label="Cart" />
<activity
android:name=".view.productlist.ProductListActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/java/woowacourse/shopping/MainActivity.kt

This file was deleted.

38 changes: 38 additions & 0 deletions app/src/main/java/woowacourse/shopping/data/CartDbRepository.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package woowacourse.shopping.data

import android.content.Context
import woowacourse.shopping.data.db.CartDBHelper
import woowacourse.shopping.domain.CartProduct
import woowacourse.shopping.domain.CartRepository

class CartDbRepository(context: Context) : CartRepository {
private val dbHelper = CartDBHelper(context)
override fun findAll(): List<CartProduct> {
return dbHelper.selectAll()
}

private fun find(id: Int): CartProduct? {
return dbHelper.selectWhereId(id)
}

override fun add(id: Int, count: Int) {
val cardProduct = find(id)
if (cardProduct != null) {
dbHelper.update(id, count + cardProduct.count)
return
}
dbHelper.insert(id, count)
}

override fun remove(id: Int) {
dbHelper.remove(id)
}

override fun findRange(mark: Int, rangeSize: Int): List<CartProduct> {
return dbHelper.selectRange(mark, rangeSize)
}

override fun isExistByMark(mark: Int): Boolean {
return dbHelper.getSize(mark)
}
}
Loading

0 comments on commit a2c85ac

Please sign in to comment.