From 0d1d75924706d1090bc80360eae953362a025439 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Sat, 16 Sep 2023 18:02:11 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[feat/myapge=5Fregistered]:=20Count=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=EB=A5=BC=20=EC=9C=84=ED=95=9C=20PagingResult?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/data/database/RestaurantMediator.kt | 2 + .../data/datasource/RestaurantDataSource.kt | 3 +- .../datasource/RestaurantDataSourceImpl.kt | 21 +++++--- .../repository/RestaurantRepositoryImpl.kt | 49 ++++++++++--------- .../org/gdsc/domain/model/PagingResult.kt | 8 +++ .../domain/repository/RestaurantRepository.kt | 3 +- .../usecase/GetRegisteredRestaurantUseCase.kt | 3 +- .../mypage/RegisteredRestaurantFragment.kt | 2 +- .../view/mypage/viewmodel/MyPageViewModel.kt | 5 +- 9 files changed, 60 insertions(+), 36 deletions(-) create mode 100644 domain/src/main/java/org/gdsc/domain/model/PagingResult.kt diff --git a/data/src/main/java/org/gdsc/data/database/RestaurantMediator.kt b/data/src/main/java/org/gdsc/data/database/RestaurantMediator.kt index 613a557a..ff8455d8 100644 --- a/data/src/main/java/org/gdsc/data/database/RestaurantMediator.kt +++ b/data/src/main/java/org/gdsc/data/database/RestaurantMediator.kt @@ -19,6 +19,7 @@ class RestaurantMediator( ): RemoteMediator() { private val userDao = db.restaurantDao() private var currentPageNumber = 0 + var totalElementsCount = 0 override suspend fun load( loadType: LoadType, @@ -51,6 +52,7 @@ class RestaurantMediator( val repos = response.data currentPageNumber = repos.page.currentPage + totalElementsCount = repos.page.totalElements val endOfPaginationReached = repos.page.pageLast if(repos.restaurants.isNotEmpty()) { db.withTransaction { diff --git a/data/src/main/java/org/gdsc/data/datasource/RestaurantDataSource.kt b/data/src/main/java/org/gdsc/data/datasource/RestaurantDataSource.kt index b79633fa..52cd1112 100644 --- a/data/src/main/java/org/gdsc/data/datasource/RestaurantDataSource.kt +++ b/data/src/main/java/org/gdsc/data/datasource/RestaurantDataSource.kt @@ -7,6 +7,7 @@ import org.gdsc.domain.DrinkPossibility import org.gdsc.domain.FoodCategory import org.gdsc.domain.SortType import org.gdsc.domain.model.Location +import org.gdsc.domain.model.PagingResult import org.gdsc.domain.model.RestaurantLocationInfo import org.gdsc.domain.model.request.ModifyRestaurantInfoRequest import org.gdsc.domain.model.request.RestaurantRegistrationRequest @@ -30,7 +31,7 @@ interface RestaurantDataSource { suspend fun getRestaurants( userId: Int, locationData: Location, sortType: SortType, foodCategory: FoodCategory, drinkPossibility: DrinkPossibility - ): Flow> + ): Flow> suspend fun putRestaurantInfo(putRestaurantInfoRequest: ModifyRestaurantInfoRequest): String diff --git a/data/src/main/java/org/gdsc/data/datasource/RestaurantDataSourceImpl.kt b/data/src/main/java/org/gdsc/data/datasource/RestaurantDataSourceImpl.kt index 6f4357c5..eef0e377 100644 --- a/data/src/main/java/org/gdsc/data/datasource/RestaurantDataSourceImpl.kt +++ b/data/src/main/java/org/gdsc/data/datasource/RestaurantDataSourceImpl.kt @@ -5,6 +5,7 @@ import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.PagingData import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map import okhttp3.RequestBody.Companion.toRequestBody import org.gdsc.data.database.RegisteredRestaurant import org.gdsc.data.database.RestaurantDatabase @@ -17,6 +18,7 @@ import org.gdsc.domain.RestaurantRegistrationState import org.gdsc.domain.SortType import org.gdsc.domain.model.Filter import org.gdsc.domain.model.Location +import org.gdsc.domain.model.PagingResult import org.gdsc.domain.model.RestaurantLocationInfo import org.gdsc.domain.model.request.ModifyRestaurantInfoRequest import org.gdsc.domain.model.request.RestaurantRegistrationRequest @@ -88,7 +90,7 @@ class RestaurantDataSourceImpl @Inject constructor( @OptIn(ExperimentalPagingApi::class) override suspend fun getRestaurants( userId: Int, locationData: Location, sortType: SortType, foodCategory: FoodCategory, drinkPossibility: DrinkPossibility - ): Flow> { + ): Flow> { val categoryFilter = when (foodCategory) { FoodCategory.INIT, FoodCategory.ETC -> null else -> foodCategory.text @@ -109,18 +111,19 @@ class RestaurantDataSourceImpl @Inject constructor( ) val restaurantSearchMapRequest = RestaurantSearchMapRequest(locationData, filter) + val mediator = RestaurantMediator( + userId = userId, + restaurantSearchMapRequest = restaurantSearchMapRequest, + db = db, + api = restaurantAPI, + ) return Pager( config = PagingConfig( pageSize = 20, enablePlaceholders = false ), - remoteMediator = RestaurantMediator( - userId = userId, - restaurantSearchMapRequest = restaurantSearchMapRequest, - db = db, - api = restaurantAPI, - ) + remoteMediator = mediator, ) { with(db.restaurantDao()) { when (sortType) { @@ -132,6 +135,10 @@ class RestaurantDataSourceImpl @Inject constructor( } }.flow + .map { data -> + val totalElementsCount = mediator.totalElementsCount + PagingResult(data, totalElementsCount) + } } override suspend fun putRestaurantInfo(putRestaurantInfoRequest: ModifyRestaurantInfoRequest): String { diff --git a/data/src/main/java/org/gdsc/data/repository/RestaurantRepositoryImpl.kt b/data/src/main/java/org/gdsc/data/repository/RestaurantRepositoryImpl.kt index 522a1608..7fdaaa21 100644 --- a/data/src/main/java/org/gdsc/data/repository/RestaurantRepositoryImpl.kt +++ b/data/src/main/java/org/gdsc/data/repository/RestaurantRepositoryImpl.kt @@ -9,6 +9,7 @@ import org.gdsc.domain.DrinkPossibility import org.gdsc.domain.FoodCategory import org.gdsc.domain.SortType import org.gdsc.domain.model.Location +import org.gdsc.domain.model.PagingResult import org.gdsc.domain.model.RegisteredRestaurant import org.gdsc.domain.model.RestaurantLocationInfo import org.gdsc.domain.model.request.ModifyRestaurantInfoRequest @@ -46,35 +47,37 @@ class RestaurantRepositoryImpl @Inject constructor( override suspend fun getRestaurants( userId: Int, locationData: Location, sortType: SortType, foodCategory: FoodCategory, drinkPossibility: DrinkPossibility - ): Flow> { + ): Flow> { return restaurantDataSource.getRestaurants( userId, locationData, sortType, foodCategory, drinkPossibility - ).map { pagingData -> - val pagingTemp = pagingData.map { restaurant -> - val restaurantTemp = RegisteredRestaurant( - id = restaurant.id, - name = restaurant.name, - placeUrl = restaurant.placeUrl, - phone = restaurant.phone, - address = restaurant.address, - roadAddress = restaurant.roadAddress, - x = restaurant.x, - y = restaurant.y, - restaurantImageUrl = restaurant.restaurantImageUrl, - introduce = restaurant.introduce, - category = restaurant.category, - userId = userId, - userNickName = restaurant.userNickName, - userProfileImageUrl = restaurant.userProfileImageUrl, - canDrinkLiquor = restaurant.canDrinkLiquor, - differenceInDistance = restaurant.differenceInDistance, - ) - restaurantTemp - } + ).map { result -> + + val pagingTemp = PagingResult( + result.data.map { restaurant -> + val restaurantTemp = RegisteredRestaurant( + id = restaurant.id, + name = restaurant.name, + placeUrl = restaurant.placeUrl, + phone = restaurant.phone, + address = restaurant.address, + roadAddress = restaurant.roadAddress, + x = restaurant.x, + y = restaurant.y, + restaurantImageUrl = restaurant.restaurantImageUrl, + introduce = restaurant.introduce, + category = restaurant.category, + userId = userId, + userNickName = restaurant.userNickName, + userProfileImageUrl = restaurant.userProfileImageUrl, + canDrinkLiquor = restaurant.canDrinkLiquor, + differenceInDistance = restaurant.differenceInDistance, + ) + restaurantTemp + }, result.totalElementsCount) pagingTemp } } diff --git a/domain/src/main/java/org/gdsc/domain/model/PagingResult.kt b/domain/src/main/java/org/gdsc/domain/model/PagingResult.kt new file mode 100644 index 00000000..b042069c --- /dev/null +++ b/domain/src/main/java/org/gdsc/domain/model/PagingResult.kt @@ -0,0 +1,8 @@ +package org.gdsc.domain.model + +import androidx.paging.PagingData + +data class PagingResult( + val data: PagingData, + val totalElementsCount: Int, +) diff --git a/domain/src/main/java/org/gdsc/domain/repository/RestaurantRepository.kt b/domain/src/main/java/org/gdsc/domain/repository/RestaurantRepository.kt index 599c9dc7..e1c5a6e9 100644 --- a/domain/src/main/java/org/gdsc/domain/repository/RestaurantRepository.kt +++ b/domain/src/main/java/org/gdsc/domain/repository/RestaurantRepository.kt @@ -6,6 +6,7 @@ import org.gdsc.domain.DrinkPossibility import org.gdsc.domain.FoodCategory import org.gdsc.domain.SortType import org.gdsc.domain.model.Location +import org.gdsc.domain.model.PagingResult import org.gdsc.domain.model.RegisteredRestaurant import org.gdsc.domain.model.RestaurantLocationInfo import org.gdsc.domain.model.request.ModifyRestaurantInfoRequest @@ -30,7 +31,7 @@ interface RestaurantRepository { suspend fun getRestaurants( userId: Int, locationData: Location, sortType: SortType, foodCategory: FoodCategory, drinkPossibility: DrinkPossibility - ): Flow> + ): Flow> suspend fun putRestaurantInfo(putRestaurantInfoRequest: ModifyRestaurantInfoRequest): String diff --git a/domain/src/main/java/org/gdsc/domain/usecase/GetRegisteredRestaurantUseCase.kt b/domain/src/main/java/org/gdsc/domain/usecase/GetRegisteredRestaurantUseCase.kt index de63d05f..7eaafc51 100644 --- a/domain/src/main/java/org/gdsc/domain/usecase/GetRegisteredRestaurantUseCase.kt +++ b/domain/src/main/java/org/gdsc/domain/usecase/GetRegisteredRestaurantUseCase.kt @@ -6,6 +6,7 @@ import org.gdsc.domain.DrinkPossibility import org.gdsc.domain.FoodCategory import org.gdsc.domain.SortType import org.gdsc.domain.model.Location +import org.gdsc.domain.model.PagingResult import org.gdsc.domain.model.RegisteredRestaurant import org.gdsc.domain.model.request.RestaurantSearchMapRequest import org.gdsc.domain.repository.RestaurantRepository @@ -16,7 +17,7 @@ class GetRegisteredRestaurantUseCase @Inject constructor( ) { suspend operator fun invoke( userId: Int, locationData: Location, sortType: SortType, foodCategory: FoodCategory, drinkPossibility: DrinkPossibility - ): Flow> { + ): Flow> { return restaurantRepository.getRestaurants(userId, locationData, sortType, foodCategory, drinkPossibility) } diff --git a/presentation/src/main/java/org/gdsc/presentation/view/mypage/RegisteredRestaurantFragment.kt b/presentation/src/main/java/org/gdsc/presentation/view/mypage/RegisteredRestaurantFragment.kt index cae7297e..4b999fa2 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/mypage/RegisteredRestaurantFragment.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/mypage/RegisteredRestaurantFragment.kt @@ -71,7 +71,7 @@ class RegisteredRestaurantFragment : Fragment() { id?.let { notNullId -> viewModel.registeredPagingData(notNullId).collectLatest { - myRestaurantAdapter.submitData(it) + myRestaurantAdapter.submitData(it.data) } } } diff --git a/presentation/src/main/java/org/gdsc/presentation/view/mypage/viewmodel/MyPageViewModel.kt b/presentation/src/main/java/org/gdsc/presentation/view/mypage/viewmodel/MyPageViewModel.kt index 7e0251e7..f223d3dc 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/mypage/viewmodel/MyPageViewModel.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/mypage/viewmodel/MyPageViewModel.kt @@ -26,6 +26,7 @@ import org.gdsc.domain.FoodCategory import org.gdsc.domain.SortType import org.gdsc.domain.model.Filter import org.gdsc.domain.model.Location +import org.gdsc.domain.model.PagingResult import org.gdsc.domain.model.RegisteredRestaurant import org.gdsc.domain.model.request.RestaurantSearchMapRequest import org.gdsc.domain.model.response.NicknameResponse @@ -217,8 +218,8 @@ class MyPageViewModel @Inject constructor( } } @OptIn(ExperimentalCoroutinesApi::class) - suspend fun registeredPagingData(userId: Int): Flow> { - val location = locationManager.getCurrentLocation() ?: return flowOf(PagingData.empty()) + suspend fun registeredPagingData(userId: Int): Flow> { + val location = locationManager.getCurrentLocation() ?: return flowOf(PagingResult(PagingData.empty(), 0)) val locationData = Location(location.longitude.toString(), location.latitude.toString()) return run { From 818bcc22bfc50b55ad3d90a7ebede3906b2c2546 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Sat, 16 Sep 2023 19:42:37 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[feat/mypage=5Fregistered]:=20Count=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20UI=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/gdsc/presentation/view/mypage/MyPageFragment.kt | 6 ++++++ .../view/mypage/RegisteredRestaurantFragment.kt | 1 + .../presentation/view/mypage/viewmodel/MyPageViewModel.kt | 7 +++++++ presentation/src/main/res/layout/fragment_my_page.xml | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/org/gdsc/presentation/view/mypage/MyPageFragment.kt b/presentation/src/main/java/org/gdsc/presentation/view/mypage/MyPageFragment.kt index 796ef068..66e385e7 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/mypage/MyPageFragment.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/mypage/MyPageFragment.kt @@ -83,6 +83,12 @@ class MyPageFragment : Fragment() { .into(binding.profileImage) } } + + repeatWhenUiStarted { + viewModel.registeredCountState.collect { + binding.registeredCountText.text = it.toString() + } + } } override fun onDestroyView() { diff --git a/presentation/src/main/java/org/gdsc/presentation/view/mypage/RegisteredRestaurantFragment.kt b/presentation/src/main/java/org/gdsc/presentation/view/mypage/RegisteredRestaurantFragment.kt index 4b999fa2..e7ff619a 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/mypage/RegisteredRestaurantFragment.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/mypage/RegisteredRestaurantFragment.kt @@ -71,6 +71,7 @@ class RegisteredRestaurantFragment : Fragment() { id?.let { notNullId -> viewModel.registeredPagingData(notNullId).collectLatest { + viewModel.updateRegisteredCount(it.totalElementsCount) myRestaurantAdapter.submitData(it.data) } } diff --git a/presentation/src/main/java/org/gdsc/presentation/view/mypage/viewmodel/MyPageViewModel.kt b/presentation/src/main/java/org/gdsc/presentation/view/mypage/viewmodel/MyPageViewModel.kt index f223d3dc..c29c6bf0 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/mypage/viewmodel/MyPageViewModel.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/mypage/viewmodel/MyPageViewModel.kt @@ -71,6 +71,9 @@ class MyPageViewModel @Inject constructor( private var _emailState = MutableStateFlow(String.Empty) val emailState = _emailState.asStateFlow() + private var _registeredCountState = MutableStateFlow(0) + val registeredCountState = _registeredCountState.asStateFlow() + private var _sortTypeState = MutableStateFlow(SortType.INIT) @@ -112,6 +115,10 @@ class MyPageViewModel @Inject constructor( } } + fun updateRegisteredCount(count: Int) { + _registeredCountState.value = count + } + fun setSortType(sortType: SortType) { _sortTypeState.value = sortType } diff --git a/presentation/src/main/res/layout/fragment_my_page.xml b/presentation/src/main/res/layout/fragment_my_page.xml index f1ff9120..d699fd61 100644 --- a/presentation/src/main/res/layout/fragment_my_page.xml +++ b/presentation/src/main/res/layout/fragment_my_page.xml @@ -68,8 +68,8 @@ android:layout_marginTop="8dp"/> Date: Sat, 16 Sep 2023 19:43:53 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[feat/mypage=5Fregistered]:=20NestedScrollC?= =?UTF-8?q?oordinatorLayout=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AppbarLayout 2개를 사용할 때 스크롤 이벤트를 유연하게 처리하기 위해 추가했습니다. --- .../custom/NestedScrollCoordinatorLayout.kt | 203 ++++++++++++++++++ .../layout/fragment_registered_restaurant.xml | 5 +- 2 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 presentation/src/main/java/org/gdsc/presentation/view/custom/NestedScrollCoordinatorLayout.kt diff --git a/presentation/src/main/java/org/gdsc/presentation/view/custom/NestedScrollCoordinatorLayout.kt b/presentation/src/main/java/org/gdsc/presentation/view/custom/NestedScrollCoordinatorLayout.kt new file mode 100644 index 00000000..3c38bb8e --- /dev/null +++ b/presentation/src/main/java/org/gdsc/presentation/view/custom/NestedScrollCoordinatorLayout.kt @@ -0,0 +1,203 @@ +package org.gdsc.presentation.view.custom + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import androidx.coordinatorlayout.widget.CoordinatorLayout +import androidx.core.view.NestedScrollingChild3 +import androidx.core.view.NestedScrollingChildHelper + +class NestedScrollCoordinatorLayout @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : CoordinatorLayout(context, attrs), NestedScrollingChild3 { + + private val helper = NestedScrollingChildHelper(this) + + init { + isNestedScrollingEnabled = true + } + + override fun isNestedScrollingEnabled(): Boolean = helper.isNestedScrollingEnabled + + override fun setNestedScrollingEnabled(enabled: Boolean) { + helper.isNestedScrollingEnabled = enabled + } + + override fun hasNestedScrollingParent(type: Int): Boolean = + helper.hasNestedScrollingParent(type) + + override fun hasNestedScrollingParent(): Boolean = helper.hasNestedScrollingParent() + + override fun onStartNestedScroll(child: View, target: View, axes: Int, type: Int): Boolean { + val superResult = super.onStartNestedScroll(child, target, axes, type) + return startNestedScroll(axes, type) || superResult + } + + override fun onStartNestedScroll(child: View, target: View, axes: Int): Boolean { + val superResult = super.onStartNestedScroll(child, target, axes) + return startNestedScroll(axes) || superResult + } + + override fun onNestedPreScroll(target: View, dx: Int, dy: Int, consumed: IntArray, type: Int) { + val superConsumed = intArrayOf(0, 0) + super.onNestedPreScroll(target, dx, dy, superConsumed, type) + val thisConsumed = intArrayOf(0, 0) + dispatchNestedPreScroll(dx, dy, consumed, null, type) + consumed[0] = superConsumed[0] + thisConsumed[0] + consumed[1] = superConsumed[1] + thisConsumed[1] + } + + override fun onNestedPreScroll(target: View, dx: Int, dy: Int, consumed: IntArray) { + val superConsumed = intArrayOf(0, 0) + super.onNestedPreScroll(target, dx, dy, superConsumed) + val thisConsumed = intArrayOf(0, 0) + dispatchNestedPreScroll(dx, dy, consumed, null) + consumed[0] = superConsumed[0] + thisConsumed[0] + consumed[1] = superConsumed[1] + thisConsumed[1] + } + + override fun onNestedScroll( + target: View, + dxConsumed: Int, + dyConsumed: Int, + dxUnconsumed: Int, + dyUnconsumed: Int, + type: Int, + consumed: IntArray + ) { + dispatchNestedScroll(dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, null, type) + super.onNestedScroll( + target, + dxConsumed, + dyConsumed, + dxUnconsumed, + dyUnconsumed, + type, + consumed + ) + } + + override fun onNestedScroll( + target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, + dyUnconsumed: Int, type: Int + ) { + super.onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type) + dispatchNestedScroll(dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, null, type) + } + + override fun onNestedScroll( + target: View, + dxConsumed: Int, + dyConsumed: Int, + dxUnconsumed: Int, + dyUnconsumed: Int + ) { + super.onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed) + dispatchNestedScroll(dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, null) + } + + override fun onStopNestedScroll(target: View, type: Int) { + super.onStopNestedScroll(target, type) + stopNestedScroll(type) + } + + override fun onStopNestedScroll(target: View) { + super.onStopNestedScroll(target) + stopNestedScroll() + } + + override fun onNestedPreFling(target: View, velocityX: Float, velocityY: Float): Boolean { + val superResult = super.onNestedPreFling(target, velocityX, velocityY) + return dispatchNestedPreFling(velocityX, velocityY) || superResult + } + + override fun onNestedFling( + target: View, + velocityX: Float, + velocityY: Float, + consumed: Boolean + ): Boolean { + val superResult = super.onNestedFling(target, velocityX, velocityY, consumed) + return dispatchNestedFling(velocityX, velocityY, consumed) || superResult + } + + override fun startNestedScroll(axes: Int, type: Int): Boolean = + helper.startNestedScroll(axes, type) + + override fun startNestedScroll(axes: Int): Boolean = helper.startNestedScroll(axes) + + override fun stopNestedScroll(type: Int) { + helper.stopNestedScroll(type) + } + + override fun stopNestedScroll() { + helper.stopNestedScroll() + } + + override fun dispatchNestedScroll( + dxConsumed: Int, + dyConsumed: Int, + dxUnconsumed: Int, + dyUnconsumed: Int, + offsetInWindow: IntArray?, + type: Int, + consumed: IntArray + ) { + helper.dispatchNestedScroll( + dxConsumed, + dyConsumed, + dxUnconsumed, + dyUnconsumed, + offsetInWindow, + type, + consumed + ) + } + + override fun dispatchNestedScroll( + dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, + offsetInWindow: IntArray?, type: Int + ): Boolean = helper.dispatchNestedScroll( + dxConsumed, + dyConsumed, + dxUnconsumed, + dyUnconsumed, + offsetInWindow, + type + ) + + override fun dispatchNestedScroll( + dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, + dyUnconsumed: Int, offsetInWindow: IntArray? + ): Boolean = helper.dispatchNestedScroll( + dxConsumed, + dyConsumed, + dxUnconsumed, + dyUnconsumed, + offsetInWindow + ) + + override fun dispatchNestedPreScroll( + dx: Int, dy: Int, consumed: IntArray?, + offsetInWindow: IntArray?, type: Int + ): Boolean = helper.dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow, type) + + override fun dispatchNestedPreScroll( + dx: Int, + dy: Int, + consumed: IntArray?, + offsetInWindow: IntArray? + ): Boolean = + helper.dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow) + + override fun dispatchNestedPreFling(velocityX: Float, velocityY: Float): Boolean = + helper.dispatchNestedPreFling(velocityX, velocityY) + + override fun dispatchNestedFling( + velocityX: Float, + velocityY: Float, + consumed: Boolean + ): Boolean = + helper.dispatchNestedFling(velocityX, velocityY, consumed) + +} \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_registered_restaurant.xml b/presentation/src/main/res/layout/fragment_registered_restaurant.xml index 6e74dd4b..3d8ed176 100644 --- a/presentation/src/main/res/layout/fragment_registered_restaurant.xml +++ b/presentation/src/main/res/layout/fragment_registered_restaurant.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file From b81442e11985e7176f6502fcfaa7f862895694c8 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Sat, 16 Sep 2023 20:32:18 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[feat/mypage=5Fregistered]:=20Stetho=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 5 +++++ app/src/main/java/org/gdsc/jmt/App.kt | 6 ++++++ data/build.gradle | 5 +++++ .../java/org/gdsc/data/di/NetworkModule.kt | 20 +++++++++++++++---- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d9e82184..eaa45425 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -68,4 +68,9 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + // Stetho + implementation 'com.facebook.stetho:stetho:1.6.0' + implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0' + implementation 'com.facebook.stetho:stetho-js-rhino:1.6.0' } diff --git a/app/src/main/java/org/gdsc/jmt/App.kt b/app/src/main/java/org/gdsc/jmt/App.kt index 7a9b5235..fe76d813 100644 --- a/app/src/main/java/org/gdsc/jmt/App.kt +++ b/app/src/main/java/org/gdsc/jmt/App.kt @@ -1,9 +1,15 @@ package org.gdsc.jmt import android.app.Application +import com.facebook.stetho.Stetho import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp class App: Application() { + override fun onCreate() { + super.onCreate() + + if (BuildConfig.DEBUG) Stetho.initializeWithDefaults(this) + } } \ No newline at end of file diff --git a/data/build.gradle b/data/build.gradle index 7822086a..36236aec 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -71,4 +71,9 @@ dependencies { implementation "androidx.room:room-ktx:2.5.0" implementation "androidx.room:room-paging:2.5.0" kapt "androidx.room:room-compiler:2.5.0" + + // Stetho + implementation 'com.facebook.stetho:stetho:1.6.0' + implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0' + implementation 'com.facebook.stetho:stetho-js-rhino:1.6.0' } \ No newline at end of file diff --git a/data/src/main/java/org/gdsc/data/di/NetworkModule.kt b/data/src/main/java/org/gdsc/data/di/NetworkModule.kt index da0c560e..887ea9f1 100644 --- a/data/src/main/java/org/gdsc/data/di/NetworkModule.kt +++ b/data/src/main/java/org/gdsc/data/di/NetworkModule.kt @@ -1,6 +1,7 @@ package org.gdsc.data.di import android.content.Context +import com.facebook.stetho.okhttp3.StethoInterceptor import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -8,6 +9,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor +import org.gdsc.data.BuildConfig import org.gdsc.data.network.AuthInterceptor import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory @@ -53,11 +55,21 @@ class NetworkModule { private val baseClientBuilder: OkHttpClient.Builder get() = run { val clientBuilder = OkHttpClient.Builder() - val loggingInterceptor = HttpLoggingInterceptor().apply { - level = HttpLoggingInterceptor.Level.BODY + + clientBuilder.apply { + if (BuildConfig.DEBUG) { + addInterceptor(HttpLoggingInterceptor().apply { + level = HttpLoggingInterceptor.Level.HEADERS + }) + + addInterceptor(HttpLoggingInterceptor().apply { + level = HttpLoggingInterceptor.Level.BODY + }) + + addNetworkInterceptor(StethoInterceptor()) + } } - return clientBuilder.addInterceptor(loggingInterceptor) + return clientBuilder } - } } \ No newline at end of file