diff --git a/app/src/main/java/com/lighthouse/di/DataModule.kt b/app/src/main/java/com/lighthouse/di/DataModule.kt index 9b1a88ca3..c4260e9b3 100644 --- a/app/src/main/java/com/lighthouse/di/DataModule.kt +++ b/app/src/main/java/com/lighthouse/di/DataModule.kt @@ -4,8 +4,6 @@ import com.lighthouse.datasource.auth.AuthDataSource import com.lighthouse.datasource.auth.AuthDataSourceImpl import com.lighthouse.datasource.brand.BrandLocalDataSource import com.lighthouse.datasource.brand.BrandLocalDataSourceImpl -import com.lighthouse.datasource.brand.BrandRemoteDataSource -import com.lighthouse.datasource.brand.BrandRemoteDataSourceImpl import com.lighthouse.datasource.gallery.GalleryImageLocalSource import com.lighthouse.datasource.gallery.GalleryImageLocalSourceImpl import com.lighthouse.datasource.gifticon.GifticonLocalDataSource @@ -42,12 +40,6 @@ abstract class DataModule { source: AuthDataSourceImpl ): AuthDataSource - @Binds - @Singleton - abstract fun bindBrandRemoteDataSource( - source: BrandRemoteDataSourceImpl - ): BrandRemoteDataSource - @Binds @Singleton abstract fun bindBrandLocalDataSource( diff --git a/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt b/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt index d4db46899..fe4e92e38 100644 --- a/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt +++ b/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt @@ -3,14 +3,12 @@ package com.lighthouse.repository import com.lighthouse.beep.model.brand.BrandPlaceInfo import com.lighthouse.beep.model.location.Dms import com.lighthouse.datasource.brand.BrandLocalDataSource -import com.lighthouse.datasource.brand.BrandRemoteDataSource import com.lighthouse.domain.repository.BrandRepository -import com.lighthouse.mapper.toDomain -import com.lighthouse.model.BeepErrorData +import com.lighthouse.repository.brand.BrandRemoteRepository import javax.inject.Inject class BrandRepositoryImpl @Inject constructor( - private val brandRemoteSource: BrandRemoteDataSource, + private val brandRemoteRepository: BrandRemoteRepository, private val brandLocalSource: BrandLocalDataSource ) : BrandRepository { @@ -19,11 +17,18 @@ class BrandRepositoryImpl @Inject constructor( x: Dms, y: Dms, size: Int - ): Result> = brandLocalSource.getBrands(x, y, brandName).mapCatching { it.toDomain() } - .recoverCatching { - getRemoteSourceData(brandName, x, y, size).getOrDefault(emptyList()) - brandLocalSource.getBrands(x, y, brandName).mapCatching { it.toDomain() }.getOrDefault(emptyList()) - } + ): Result> = Result.success(listOf()) + +// override suspend fun getBrandPlaceInfo( +// brandName: String, +// x: Dms, +// y: Dms, +// size: Int +// ): Result> = brandLocalSource.getBrands(x, y, brandName).mapCatching { it.toDomain() } +// .recoverCatching { +// getRemoteSourceData(brandName, x, y, size).getOrDefault(emptyList()) +// brandLocalSource.getBrands(x, y, brandName).mapCatching { it.toDomain() }.getOrDefault(emptyList()) +// } private suspend fun getRemoteSourceData( brandName: String, @@ -31,14 +36,12 @@ class BrandRepositoryImpl @Inject constructor( y: Dms, size: Int ): Result> { - val result = brandRemoteSource.getBrandPlaceInfo(brandName, x, y, size).mapCatching { it.toDomain(brandName) } - val exception = result.exceptionOrNull() - - return if (exception is BeepErrorData) { - Result.failure(exception.toDomain()) - } else { - result.onSuccess { brandLocalSource.insertBrands(it, x, y, brandName) } + val result = brandRemoteRepository.getBrandPlaceInfo(brandName, x, y, size) + val list = result.getOrNull() + if (list != null) { + brandLocalSource.insertBrands(list, x, y, brandName) } + return result } override suspend fun removeExpirationBrands() { diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/CashCardGifticonInfoFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/CashCardGifticonInfoFragment.kt index e689a4e85..f14dbf519 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/CashCardGifticonInfoFragment.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/CashCardGifticonInfoFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.View import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels +import com.lighthouse.common.geography.Geography import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.FragmentCashCardGifticonInfoBinding import com.lighthouse.presentation.ui.common.viewBindings @@ -16,7 +17,7 @@ class CashCardGifticonInfoFragment : Fragment(R.layout.fragment_cash_card_giftic super.onViewCreated(view, savedInstanceState) binding.vm = viewModel - binding.geo = com.lighthouse.common.utils.geography.Geography(requireContext()) + binding.geo = Geography(requireContext()) binding.lifecycleOwner = viewLifecycleOwner binding.ctfBalance.addOnValueListener { viewModel.editBalance(it) diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/StandardGifticonInfoFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/StandardGifticonInfoFragment.kt index 48f36d243..b414dc143 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/StandardGifticonInfoFragment.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/StandardGifticonInfoFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.View import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels +import com.lighthouse.common.geography.Geography import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.FragmentStandardGifticonInfoBinding import com.lighthouse.presentation.ui.common.viewBindings @@ -15,7 +16,7 @@ class StandardGifticonInfoFragment : Fragment(R.layout.fragment_standard_giftico override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding.vm = viewModel - binding.geo = com.lighthouse.common.utils.geography.Geography(requireContext()) + binding.geo = Geography(requireContext()) binding.lifecycleOwner = viewLifecycleOwner } } diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/dialog/UsageHistoryAdapter.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/dialog/UsageHistoryAdapter.kt index d2b4086e4..6fb4b1786 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/dialog/UsageHistoryAdapter.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/dialog/UsageHistoryAdapter.kt @@ -6,7 +6,7 @@ import androidx.databinding.DataBindingUtil import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.lighthouse.beep.model.user.UsageHistory -import com.lighthouse.common.utils.geography.Geography +import com.lighthouse.common.geography.Geography import com.lighthouse.presentation.R import com.lighthouse.presentation.adapter.BindableListAdapter import com.lighthouse.presentation.databinding.ItemUsageHistoryBinding diff --git a/presentation/src/main/res/layout/fragment_cash_card_gifticon_info.xml b/presentation/src/main/res/layout/fragment_cash_card_gifticon_info.xml index 7c1e28e5d..f3eb34de1 100644 --- a/presentation/src/main/res/layout/fragment_cash_card_gifticon_info.xml +++ b/presentation/src/main/res/layout/fragment_cash_card_gifticon_info.xml @@ -11,7 +11,7 @@ + type="com.lighthouse.common.geography.Geography" /> + type="com.lighthouse.common.geography.Geography" /> + type="com.lighthouse.common.geography.Geography" />