-
Notifications
You must be signed in to change notification settings - Fork 48
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
[둘리] 2단계 재화 미션 제출합니다. #30
Merged
Merged
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
908f44b
feat: 서버 선택 액티비티 구현
hyemdooly 82842ac
refactor: ProductListActivity Retrofit, Domain에 Pagination 생성하여 리팩터링
hyemdooly b810530
refactor: Repository들 Retrofit으로 수정, RecentViewedDB 수정 및 리팩터링
hyemdooly 4d98c1c
refactor: ProductList 리팩터링
hyemdooly 2057624
refactor: ProductList, ProductDetail 리팩터링
hyemdooly 80935fb
refactor: Cart 리팩터링
hyemdooly 46cf174
refactor: Cart 스켈레톤 추가
hyemdooly d824e50
refactor: Product 스켈레톤 View로 요소 변경
hyemdooly 3f5b4de
refactor: Mypage 액티비티 생성
hyemdooly 60a207c
refactor: 카트에서 수정 후 백버튼 눌렀을 때 반영 안되는 버그 수정
hyemdooly a94c2ad
feat: Mypage Activity 구현
hyemdooly c2481fa
refactor: AppCompatButton -> Button 수정
hyemdooly 158c5ef
feat: OrderAcitvity View xml 구현
hyemdooly 4f0dab6
feat: CartActivity, OrderActivity 주문 기능 구현
hyemdooly 0a8e0cd
feat: OrderDetail, OrderHistory 구현
hyemdooly 007d3c0
refactor: databinding 리팩터링
hyemdooly 454da81
refactor: Log 삭제
hyemdooly 0973f31
refactor: ktlintFormat
hyemdooly 8c1c90a
refactor: onFailure시 실행할 콜백 함수 추가, 최근본 상품 서버별로 분리
hyemdooly 5cee35e
refactor: callback 대소문자 통일
hyemdooly bac916c
fix: CartPagination 버그 수정
hyemdooly 0b43a65
fix: CartPagination 버그 수정
hyemdooly 575beb5
refactor: 500 에러 대응
hyemdooly 9fcbe88
Merge remote-tracking branch 'origin/step2' into step2
hyemdooly 496197f
refactor: 사용하지 않는 함수 제거, products가 비었을 경우 대응
hyemdooly ba14236
refactor: 함수 중복 호출 제거, 사용하지 않는 import 제거
hyemdooly 79db6d7
refactor: 기존 Presenter Test 수정
hyemdooly 0391439
fix: 캐시 음수 안걸러지는 버그 수정
hyemdooly cf5243d
refactor: OrderPresenter 접근제어자 변경, 로그 삭제
hyemdooly 0ed0447
feat: OrderPresenter 테스트 작성
hyemdooly 69e74d8
feat: OrderHistoryPresenter 테스트 작성
hyemdooly 06bbd3a
feat: OrderDetailPresenter 테스트 작성
hyemdooly 454a11d
feat: 테스트를 위한 Fixture 작성
hyemdooly 5ed1a89
refactor: 로그 삭제
hyemdooly ae88747
refactor: 로그 삭제
hyemdooly 3908c3a
Merge remote-tracking branch 'origin/step2' into step2
hyemdooly c9e0bd1
refactor: Repository 반복 코드 삭제
hyemdooly 5f0ec65
refactor: failureCallback 삭제
hyemdooly f2af726
refactor: okhttp interceptor을 이용한 헤더 추가
hyemdooly b9e9c4f
refactor: adapter에서 데이터 변경을 notify하도록 수정
hyemdooly 3278cd7
refactor: adapter에서 데이터 변경을 notify하도록 수정
hyemdooly 7361d41
refactor: DataResult Class 생성하여 에러처리를 Presenter에서 하도록 수정
hyemdooly a65ef2e
Merge remote-tracking branch 'origin/step2' into step2
hyemdooly 45e5e39
refactor: UserAuthorization 수정
hyemdooly ac354f6
refactor: ProductListAdapter 업데이트 함수 DiffUtil 사용하여 리팩터링
hyemdooly a0a1d31
refactor: CartAdapter 업데이트 함수 DiffUtil 사용하여 리팩터링
hyemdooly 10b1b03
refactor: Product companion object 삭제
hyemdooly b680c33
refactor: 에러별로 다른 토스트 띄우도록 수정
hyemdooly ae57e08
refactor: retrofitService 네이밍 수정
hyemdooly f13fb24
refactor: response body값들이 null일 경우 처리
hyemdooly 71e8eab
refactor: DataSource - Repository 분리
hyemdooly c9c2644
refactor: 프레젠터 테스트 수정
hyemdooly b238322
refactor: ProductRemoteDataSourceTest 작성
hyemdooly 4332aaa
refactor: CartRemoteDataSourceTest 작성
hyemdooly 06bdf53
refactor: OrderRemoteDataSourceTest 작성
hyemdooly a148344
refactor: ProductRemoteDataSourceTest 로그 삭제
hyemdooly 36f7277
refactor: MypageRemoteDataSourceTest 작성
hyemdooly 00e847e
refactor: ktlintFormat
hyemdooly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: Mypage Activity 구현
- Loading branch information
commit a94c2ad0f92a9f091bb80a4f5a266bade3ab2146
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
app/src/main/java/woowacourse/shopping/data/repository/MypageRemoteRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package woowacourse.shopping.data.repository | ||
|
||
import retrofit2.Call | ||
import retrofit2.Response | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
import woowacourse.shopping.data.retrofit.MypageApi | ||
import woowacourse.shopping.domain.model.TotalCashDTO | ||
import woowacourse.shopping.domain.repository.MypageRepository | ||
|
||
class MypageRemoteRepository(baseUrl: String) : MypageRepository { | ||
private val retrofitService = Retrofit.Builder() | ||
.baseUrl(baseUrl) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.build() | ||
.create(MypageApi::class.java) | ||
|
||
override fun getCash(callback: (Int) -> Unit) { | ||
retrofitService.requestCash().enqueue(object : retrofit2.Callback<TotalCashDTO> { | ||
override fun onResponse(call: Call<TotalCashDTO>, response: Response<TotalCashDTO>) { | ||
response.body()?.let { | ||
callback(it.totalCash) | ||
} | ||
} | ||
|
||
override fun onFailure(call: Call<TotalCashDTO>, t: Throwable) { | ||
throw t | ||
} | ||
}) | ||
} | ||
|
||
override fun chargeCash(cash: Int, callback: (Int) -> Unit) { | ||
retrofitService.requestChargeCash(cash).enqueue(object : retrofit2.Callback<TotalCashDTO> { | ||
override fun onResponse(call: Call<TotalCashDTO>, response: Response<TotalCashDTO>) { | ||
response.body()?.let { | ||
callback(it.totalCash) | ||
} | ||
} | ||
|
||
override fun onFailure(call: Call<TotalCashDTO>, t: Throwable) { | ||
throw t | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/src/main/java/woowacourse/shopping/data/retrofit/MypageApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package woowacourse.shopping.data.retrofit | ||
|
||
import retrofit2.Call | ||
import retrofit2.http.* | ||
import woowacourse.shopping.domain.model.TotalCashDTO | ||
|
||
interface MypageApi { | ||
@Headers("Authorization: Basic ZG9vbHlAZG9vbHkuY29tOjEyMzQ=") | ||
@GET("/members/cash") | ||
fun requestCash(): Call<TotalCashDTO> | ||
|
||
@Headers("Authorization: Basic ZG9vbHlAZG9vbHkuY29tOjEyMzQ=") | ||
@POST("/members/cash") | ||
fun requestChargeCash(@Body cashToCharge: Int): Call<TotalCashDTO> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/src/main/java/woowacourse/shopping/view/mypage/MypageContract.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package woowacourse.shopping.view.mypage | ||
|
||
import androidx.lifecycle.LiveData | ||
|
||
interface MypageContract { | ||
interface Presenter { | ||
val cash: LiveData<Int> | ||
fun fetchCash() | ||
fun chargeCash(cash: Int) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/woowacourse/shopping/view/mypage/MypagePresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package woowacourse.shopping.view.mypage | ||
|
||
import android.util.Log | ||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import woowacourse.shopping.domain.repository.MypageRepository | ||
|
||
class MypagePresenter(private val mypageRepository: MypageRepository) : MypageContract.Presenter { | ||
private val _cash = MutableLiveData(0) | ||
override val cash: LiveData<Int> | ||
get() = _cash | ||
|
||
override fun fetchCash() { | ||
mypageRepository.getCash { | ||
Log.d("get", it.toString()) | ||
_cash.value = it | ||
} | ||
} | ||
|
||
override fun chargeCash(cash: Int) { | ||
mypageRepository.chargeCash(cash) { | ||
Log.d("post", it.toString()) | ||
_cash.value = it | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,62 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout> | ||
<data> | ||
<variable | ||
name="presenter" | ||
type="woowacourse.shopping.view.mypage.MypageContract.Presenter" /> | ||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="https://schemas.android.com/apk/res/android" | ||
xmlns:app="https://schemas.android.com/apk/res-auto" | ||
xmlns:tools="https://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".view.mypage.MypageActivity"> | ||
|
||
<TextView | ||
android:id="@+id/text_cash" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@{@string/cash_on_hand(presenter.cash)}" | ||
android:textColor="@color/black" | ||
android:textSize="22sp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="보유한 캐시 : 10,000 캐시" /> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
app:layout_constraintEnd_toEndOf="@id/text_cash" | ||
app:layout_constraintStart_toStartOf="@id/text_cash" | ||
app:layout_constraintTop_toBottomOf="@id/text_cash"> | ||
|
||
<EditText | ||
android:id="@+id/edit_cash" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:inputType="number" | ||
app:layout_constraintEnd_toStartOf="@id/btn_submit" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<Button | ||
android:id="@+id/btn_submit" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:backgroundTint="@color/mint" | ||
android:text="@string/charge" | ||
android:textSize="17sp" | ||
android:textStyle="bold" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@id/edit_cash" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
domain/src/main/java/woowacourse/shopping/domain/model/TotalCashDTO.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package woowacourse.shopping.domain.model | ||
|
||
data class TotalCashDTO(val totalCash: Int) |
6 changes: 6 additions & 0 deletions
6
domain/src/main/java/woowacourse/shopping/domain/repository/MypageRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package woowacourse.shopping.domain.repository | ||
|
||
interface MypageRepository { | ||
fun getCash(callback: (Int) -> Unit) | ||
fun chargeCash(cash: Int, callback: (Int) -> Unit) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
둘리님은 MVP패턴에서 LiveData를 사용해보니 어떠신거 같나요?
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.
MVP가 아닌 것 같습니다...🥲
LiveData가 편해서 사용하긴 했지만, interface에 LiveData 변수를 선언해야 View에서 사용할 수 있어서 MVP에 어긋난다고 느꼈습니다!
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.
추후에 mvvm패턴을 적용해보시면 장점을 느끼실수 있으실거예요! 👍