From a2d5ade591fb49fa40c611a0d8a513bf5f192075 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 10 Jul 2024 03:14:57 +0900 Subject: [PATCH 01/10] =?UTF-8?q?[FIX/#37]=20core=20=EB=AA=A8=EB=93=88=20?= =?UTF-8?q?=ED=8C=A8=ED=82=A4=EC=A7=80=EB=AA=85=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/co/orange/core/base/BaseActivity.kt | 4 +-- .../co/orange/core/base/BaseBottomSheet.kt | 2 +- .../java/co/orange/core/base/BaseDialog.kt | 2 +- .../java/co/orange/core/base/BaseFragment.kt | 2 +- .../co/orange/core/extension/StringExt.kt | 2 +- .../java/co/orange/core/extension/UriExt.kt | 2 +- .../presentation/auth/login/LoginActivity.kt | 4 +-- .../auth/signup/MobileBottomSheet.kt | 4 +-- .../auth/signup/SignUpActivity.kt | 8 ++--- .../auth/signup/TermBottomSheet.kt | 4 +-- .../auth/submit/SubmitActivity.kt | 4 +-- .../buy/confirm/BuyConfirmActivity.kt | 20 ++++++------ .../buy/finished/BuyFinishedActivity.kt | 31 ++++++++++--------- .../presentation/buy/info/BuyInfoActivity.kt | 31 ++++++++++--------- .../presentation/buy/push/BuyPushActivity.kt | 18 +++++------ .../presentation/detail/DetailActivity.kt | 26 ++++++++-------- .../presentation/detail/OptionBottomSheet.kt | 6 ++-- .../orange/presentation/main/MainActivity.kt | 6 ++-- .../main/home/HomeBannerViewHolder.kt | 2 +- .../presentation/main/home/HomeFragment.kt | 8 ++--- .../main/home/SellProductDialog.kt | 4 +-- .../main/profile/ProfileFragment.kt | 4 +-- .../presentation/search/SearchActivity.kt | 6 ++-- .../presentation/search/SearchItemAdapter.kt | 2 +- .../sell/confirm/SellConfirmActivity.kt | 6 ++-- .../sell/finished/SellFinishedActivity.kt | 6 ++-- .../sell/info/SellInfoActivity.kt | 8 ++--- .../sell/push/SellPushActivity.kt | 4 +-- .../presentation/setting/SettingActivity.kt | 4 +-- .../setting/account/AccountActivity.kt | 4 +-- .../presentation/setting/bank/BankActivity.kt | 4 +-- .../setting/delivery/DeliveryActivity.kt | 6 ++-- 32 files changed, 122 insertions(+), 122 deletions(-) diff --git a/core/src/main/java/co/orange/core/base/BaseActivity.kt b/core/src/main/java/co/orange/core/base/BaseActivity.kt index 34232d0a..02447332 100644 --- a/core/src/main/java/co/orange/core/base/BaseActivity.kt +++ b/core/src/main/java/co/orange/core/base/BaseActivity.kt @@ -1,4 +1,4 @@ -package kr.genti.core.base +package co.orange.core.base import android.graphics.Rect import android.os.Bundle @@ -8,7 +8,7 @@ import androidx.annotation.LayoutRes import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import androidx.databinding.ViewDataBinding -import kr.genti.core.extension.hideKeyboard +import co.orange.core.extension.hideKeyboard abstract class BaseActivity( @LayoutRes private val layoutResId: Int, diff --git a/core/src/main/java/co/orange/core/base/BaseBottomSheet.kt b/core/src/main/java/co/orange/core/base/BaseBottomSheet.kt index fbab6e6d..1160d561 100644 --- a/core/src/main/java/co/orange/core/base/BaseBottomSheet.kt +++ b/core/src/main/java/co/orange/core/base/BaseBottomSheet.kt @@ -1,4 +1,4 @@ -package kr.genti.core.base +package co.orange.core.base import android.os.Bundle import android.view.LayoutInflater diff --git a/core/src/main/java/co/orange/core/base/BaseDialog.kt b/core/src/main/java/co/orange/core/base/BaseDialog.kt index cad653b0..353067c8 100644 --- a/core/src/main/java/co/orange/core/base/BaseDialog.kt +++ b/core/src/main/java/co/orange/core/base/BaseDialog.kt @@ -1,4 +1,4 @@ -package kr.genti.core.base +package co.orange.core.base import android.os.Bundle import android.view.LayoutInflater diff --git a/core/src/main/java/co/orange/core/base/BaseFragment.kt b/core/src/main/java/co/orange/core/base/BaseFragment.kt index 9ec600e3..1b1b2f6b 100644 --- a/core/src/main/java/co/orange/core/base/BaseFragment.kt +++ b/core/src/main/java/co/orange/core/base/BaseFragment.kt @@ -1,4 +1,4 @@ -package kr.genti.core.base +package co.orange.core.base import android.os.Bundle import android.view.LayoutInflater diff --git a/core/src/main/java/co/orange/core/extension/StringExt.kt b/core/src/main/java/co/orange/core/extension/StringExt.kt index c884a886..57beaf5b 100644 --- a/core/src/main/java/co/orange/core/extension/StringExt.kt +++ b/core/src/main/java/co/orange/core/extension/StringExt.kt @@ -1,4 +1,4 @@ -package kr.genti.core.extension +package co.orange.core.extension import java.text.BreakIterator diff --git a/core/src/main/java/co/orange/core/extension/UriExt.kt b/core/src/main/java/co/orange/core/extension/UriExt.kt index a1a9b8e3..b09bd4a5 100644 --- a/core/src/main/java/co/orange/core/extension/UriExt.kt +++ b/core/src/main/java/co/orange/core/extension/UriExt.kt @@ -1,4 +1,4 @@ -package kr.genti.core.extension +package co.orange.core.extension import android.content.ContentResolver import android.net.Uri diff --git a/presentation/src/main/java/co/orange/presentation/auth/login/LoginActivity.kt b/presentation/src/main/java/co/orange/presentation/auth/login/LoginActivity.kt index c6f58e32..19aae02b 100644 --- a/presentation/src/main/java/co/orange/presentation/auth/login/LoginActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/auth/login/LoginActivity.kt @@ -3,10 +3,10 @@ package co.orange.presentation.auth.login import android.content.Intent import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.setOnSingleClickListener import co.orange.presentation.auth.signup.SignUpActivity import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityLoginBinding diff --git a/presentation/src/main/java/co/orange/presentation/auth/signup/MobileBottomSheet.kt b/presentation/src/main/java/co/orange/presentation/auth/signup/MobileBottomSheet.kt index 8a152171..aace0449 100644 --- a/presentation/src/main/java/co/orange/presentation/auth/signup/MobileBottomSheet.kt +++ b/presentation/src/main/java/co/orange/presentation/auth/signup/MobileBottomSheet.kt @@ -3,9 +3,9 @@ package co.orange.presentation.auth.signup import android.os.Bundle import android.view.View import androidx.fragment.app.activityViewModels +import co.orange.core.base.BaseBottomSheet +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.enums.MobileType -import kr.genti.core.base.BaseBottomSheet -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.BottomSheetMobileBinding diff --git a/presentation/src/main/java/co/orange/presentation/auth/signup/SignUpActivity.kt b/presentation/src/main/java/co/orange/presentation/auth/signup/SignUpActivity.kt index 04c6e81d..2fae3c21 100644 --- a/presentation/src/main/java/co/orange/presentation/auth/signup/SignUpActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/auth/signup/SignUpActivity.kt @@ -2,11 +2,11 @@ package co.orange.presentation.auth.signup import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.hideKeyboard +import co.orange.core.extension.initFocusWithKeyboard +import co.orange.core.extension.setOnSingleClickListener import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.hideKeyboard -import kr.genti.core.extension.initFocusWithKeyboard -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivitySignUpBinding diff --git a/presentation/src/main/java/co/orange/presentation/auth/signup/TermBottomSheet.kt b/presentation/src/main/java/co/orange/presentation/auth/signup/TermBottomSheet.kt index 3a61e024..fec6ab3b 100644 --- a/presentation/src/main/java/co/orange/presentation/auth/signup/TermBottomSheet.kt +++ b/presentation/src/main/java/co/orange/presentation/auth/signup/TermBottomSheet.kt @@ -4,9 +4,9 @@ import android.content.Intent import android.os.Bundle import android.view.View import androidx.fragment.app.activityViewModels +import co.orange.core.base.BaseBottomSheet +import co.orange.core.extension.setOnSingleClickListener import co.orange.presentation.auth.submit.SubmitActivity -import kr.genti.core.base.BaseBottomSheet -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.BottomSheetTermBinding diff --git a/presentation/src/main/java/co/orange/presentation/auth/submit/SubmitActivity.kt b/presentation/src/main/java/co/orange/presentation/auth/submit/SubmitActivity.kt index 39d228aa..23757379 100644 --- a/presentation/src/main/java/co/orange/presentation/auth/submit/SubmitActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/auth/submit/SubmitActivity.kt @@ -1,9 +1,9 @@ package co.orange.presentation.auth.submit import android.os.Bundle +import co.orange.core.base.BaseActivity +import co.orange.core.extension.setOnSingleClickListener import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivitySubmitBinding diff --git a/presentation/src/main/java/co/orange/presentation/buy/confirm/BuyConfirmActivity.kt b/presentation/src/main/java/co/orange/presentation/buy/confirm/BuyConfirmActivity.kt index 1d248cf3..35afbce9 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/confirm/BuyConfirmActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/confirm/BuyConfirmActivity.kt @@ -4,13 +4,13 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.setNumberForm +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.BuyInfoModel import co.orange.presentation.buy.push.BuyPushActivity import coil.load import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.setNumberForm -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityBuyConfirmBinding @@ -39,7 +39,7 @@ class BuyConfirmActivity : BaseActivity(R.layout.acti } private fun initTermBtnListener() { - //TODO + // TODO binding.btnTermAll.setOnSingleClickListener { } binding.btnTermFirst.setOnSingleClickListener { } binding.btnTermSecond.setOnSingleClickListener { } @@ -73,16 +73,16 @@ class BuyConfirmActivity : BaseActivity(R.layout.acti } } - companion object { private const val EXTRA_PRODUCT_ID = "EXTRA_PRODUCT_ID" @JvmStatic fun createIntent( context: Context, - productId: Long - ): Intent = Intent(context, BuyConfirmActivity::class.java).apply { - putExtra(EXTRA_PRODUCT_ID, productId) - } + productId: Long, + ): Intent = + Intent(context, BuyConfirmActivity::class.java).apply { + putExtra(EXTRA_PRODUCT_ID, productId) + } } -} \ No newline at end of file +} diff --git a/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedActivity.kt b/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedActivity.kt index 6fd501bf..f6722e8e 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedActivity.kt @@ -4,15 +4,15 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.breakLines +import co.orange.core.extension.setNumberForm +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.BuyDetailModel import co.orange.presentation.buy.info.BuyInfoActivity import co.orange.presentation.main.MainActivity import coil.load import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.breakLines -import kr.genti.core.extension.setNumberForm -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityBuyFinishedBinding @@ -63,11 +63,12 @@ class BuyFinishedActivity : tvFinishedItemName.text = item.productName tvFinishedItemPrice.text = item.originPrice.setNumberForm() tvFinishedDeliveryName.text = item.addressInfo[0].recipient - tvFinishedDeliveryAddress.text = getString( - R.string.address_format, - item.addressInfo[0].zipCode, - item.addressInfo[0].address - ).breakLines() + tvFinishedDeliveryAddress.text = + getString( + R.string.address_format, + item.addressInfo[0].zipCode, + item.addressInfo[0].address, + ).breakLines() tvFinishedDeliveryPhone.text = item.addressInfo[0].phone tvFinishedTransactionMethod.text = item.paymentInfo[0].method tvFinishedTransactionDate.text = item.paymentInfo[0].completedAt @@ -78,16 +79,16 @@ class BuyFinishedActivity : } } - companion object { private const val EXTRA_PRODUCT_ID = "EXTRA_PRODUCT_ID" @JvmStatic fun createIntent( context: Context, - productId: Long - ): Intent = Intent(context, BuyFinishedActivity::class.java).apply { - putExtra(EXTRA_PRODUCT_ID, productId) - } + productId: Long, + ): Intent = + Intent(context, BuyFinishedActivity::class.java).apply { + putExtra(EXTRA_PRODUCT_ID, productId) + } } -} \ No newline at end of file +} diff --git a/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoActivity.kt b/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoActivity.kt index 5e2b0fe4..f4a67c05 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoActivity.kt @@ -4,13 +4,13 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.breakLines +import co.orange.core.extension.setNumberForm +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.BuyDetailModel import coil.load import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.breakLines -import kr.genti.core.extension.setNumberForm -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityBuyInfoBinding @@ -49,11 +49,12 @@ class BuyInfoActivity : tvInfoProductPrice.text = item.originPrice.setNumberForm() tvInfoSellerNickname.text = item.sellerNickname tvInfoDeliveryName.text = item.addressInfo[0].recipient - tvInfoDeliveryAddress.text = getString( - R.string.address_format, - item.addressInfo[0].zipCode, - item.addressInfo[0].address - ).breakLines() + tvInfoDeliveryAddress.text = + getString( + R.string.address_format, + item.addressInfo[0].zipCode, + item.addressInfo[0].address, + ).breakLines() tvInfoDeliveryPhone.text = item.addressInfo[0].phone tvInfoTransactionMethod.text = item.paymentInfo[0].method tvInfoTransactionDate.text = item.paymentInfo[0].completedAt @@ -65,16 +66,16 @@ class BuyInfoActivity : } } - companion object { private const val EXTRA_PRODUCT_ID = "EXTRA_PRODUCT_ID" @JvmStatic fun createIntent( context: Context, - productId: Long - ): Intent = Intent(context, BuyInfoActivity::class.java).apply { - putExtra(EXTRA_PRODUCT_ID, productId) - } + productId: Long, + ): Intent = + Intent(context, BuyInfoActivity::class.java).apply { + putExtra(EXTRA_PRODUCT_ID, productId) + } } -} \ No newline at end of file +} diff --git a/presentation/src/main/java/co/orange/presentation/buy/push/BuyPushActivity.kt b/presentation/src/main/java/co/orange/presentation/buy/push/BuyPushActivity.kt index 52e2096c..a3f2d211 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/push/BuyPushActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/push/BuyPushActivity.kt @@ -3,16 +3,15 @@ package co.orange.presentation.buy.push import android.content.Context import android.content.Intent import android.os.Bundle +import co.orange.core.base.BaseActivity +import co.orange.core.extension.setOnSingleClickListener import co.orange.presentation.buy.finished.BuyFinishedActivity import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityPushBinding @AndroidEntryPoint class BuyPushActivity : BaseActivity(R.layout.activity_push) { - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -39,13 +38,11 @@ class BuyPushActivity : BaseActivity(R.layout.activity_push } } - private fun navigateToFinishedActivity() { - val productId = intent.getLongExtra(EXTRA_PRODUCT_ID,-1) + val productId = intent.getLongExtra(EXTRA_PRODUCT_ID, -1) BuyFinishedActivity.createIntent(this, productId).apply { startActivity(this) } - } companion object { @@ -55,8 +52,9 @@ class BuyPushActivity : BaseActivity(R.layout.activity_push fun createIntent( context: Context, productId: Long, - ): Intent = Intent(context, BuyPushActivity::class.java).apply { - putExtra(EXTRA_PRODUCT_ID, productId) - } + ): Intent = + Intent(context, BuyPushActivity::class.java).apply { + putExtra(EXTRA_PRODUCT_ID, productId) + } } -} \ No newline at end of file +} diff --git a/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt b/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt index 968b05f8..6b8bb98e 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt @@ -7,14 +7,14 @@ import android.net.Uri import android.os.Bundle import androidx.activity.viewModels import androidx.core.view.isVisible +import co.orange.core.base.BaseActivity +import co.orange.core.extension.breakLines +import co.orange.core.extension.setNumberForm +import co.orange.core.extension.setOnSingleClickListener +import co.orange.core.extension.setOverThousand import co.orange.domain.entity.response.ProductDetailModel import coil.load import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.breakLines -import kr.genti.core.extension.setNumberForm -import kr.genti.core.extension.setOnSingleClickListener -import kr.genti.core.extension.setOverThousand import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityDetailBinding @@ -33,7 +33,6 @@ class DetailActivity : BaseActivity(R.layout.activity_det initPurchaseBtnListener() getIntentInfo() setProduct(viewModel.mockProduct) - } private fun initBackBtnListener() { @@ -112,11 +111,12 @@ class DetailActivity : BaseActivity(R.layout.activity_det productUrl: String, originPrice: Int, salePrice: Int, - ): Intent = Intent(context, DetailActivity::class.java).apply { - putExtra(EXTRA_PRODUCT_ID, productId) - putExtra(EXTRA_PRODUCT_URL, productUrl) - putExtra(EXTRA_ORIGIN_PRICE, originPrice) - putExtra(EXTRA_SALE_PRICE, salePrice) - } + ): Intent = + Intent(context, DetailActivity::class.java).apply { + putExtra(EXTRA_PRODUCT_ID, productId) + putExtra(EXTRA_PRODUCT_URL, productUrl) + putExtra(EXTRA_ORIGIN_PRICE, originPrice) + putExtra(EXTRA_SALE_PRICE, salePrice) + } } -} \ No newline at end of file +} diff --git a/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt b/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt index 34843a24..0ae7c411 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt @@ -5,10 +5,10 @@ import android.net.Uri import android.os.Bundle import android.view.View import androidx.fragment.app.activityViewModels +import co.orange.core.base.BaseBottomSheet +import co.orange.core.extension.setOnSingleClickListener +import co.orange.core.extension.setOverThousand import co.orange.presentation.buy.confirm.BuyConfirmActivity -import kr.genti.core.base.BaseBottomSheet -import kr.genti.core.extension.setOnSingleClickListener -import kr.genti.core.extension.setOverThousand import kr.genti.presentation.R import kr.genti.presentation.databinding.BottomSheetOptionBinding diff --git a/presentation/src/main/java/co/orange/presentation/main/MainActivity.kt b/presentation/src/main/java/co/orange/presentation/main/MainActivity.kt index d4a83b38..208f0881 100644 --- a/presentation/src/main/java/co/orange/presentation/main/MainActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/main/MainActivity.kt @@ -4,11 +4,11 @@ import android.os.Bundle import androidx.fragment.app.Fragment import androidx.fragment.app.commit import androidx.fragment.app.replace +import co.orange.core.base.BaseActivity +import co.orange.core.extension.colorOf import co.orange.presentation.main.home.HomeFragment import co.orange.presentation.main.profile.ProfileFragment import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.colorOf import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityMainBinding @@ -56,4 +56,4 @@ class MainActivity : BaseActivity(R.layout.activity_main) { private fun setNavigationBarBlack() { this.window.navigationBarColor = colorOf(R.color.black) } -} \ No newline at end of file +} diff --git a/presentation/src/main/java/co/orange/presentation/main/home/HomeBannerViewHolder.kt b/presentation/src/main/java/co/orange/presentation/main/home/HomeBannerViewHolder.kt index 2e1fdcdf..e66e9f61 100644 --- a/presentation/src/main/java/co/orange/presentation/main/home/HomeBannerViewHolder.kt +++ b/presentation/src/main/java/co/orange/presentation/main/home/HomeBannerViewHolder.kt @@ -1,7 +1,7 @@ package co.orange.presentation.main.home import androidx.recyclerview.widget.RecyclerView -import kr.genti.core.extension.setOnSingleClickListener +import co.orange.core.extension.setOnSingleClickListener import kr.genti.presentation.databinding.ItemHomeBannerBinding class HomeBannerViewHolder( diff --git a/presentation/src/main/java/co/orange/presentation/main/home/HomeFragment.kt b/presentation/src/main/java/co/orange/presentation/main/home/HomeFragment.kt index cdf22b80..1a3138e1 100644 --- a/presentation/src/main/java/co/orange/presentation/main/home/HomeFragment.kt +++ b/presentation/src/main/java/co/orange/presentation/main/home/HomeFragment.kt @@ -10,6 +10,10 @@ import androidx.fragment.app.activityViewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.GridLayoutManager +import co.orange.core.base.BaseFragment +import co.orange.core.extension.dpToPx +import co.orange.core.extension.initOnBackPressedListener +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.ProductModel import co.orange.presentation.auth.login.LoginActivity import co.orange.presentation.detail.DetailActivity @@ -18,10 +22,6 @@ import co.orange.presentation.search.SearchActivity import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import kr.genti.core.base.BaseFragment -import kr.genti.core.extension.dpToPx -import kr.genti.core.extension.initOnBackPressedListener -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.FragmentHomeBinding diff --git a/presentation/src/main/java/co/orange/presentation/main/home/SellProductDialog.kt b/presentation/src/main/java/co/orange/presentation/main/home/SellProductDialog.kt index d2ea2236..cfb399a9 100644 --- a/presentation/src/main/java/co/orange/presentation/main/home/SellProductDialog.kt +++ b/presentation/src/main/java/co/orange/presentation/main/home/SellProductDialog.kt @@ -4,10 +4,10 @@ import android.os.Bundle import android.view.View import android.view.WindowManager import androidx.fragment.app.activityViewModels +import co.orange.core.base.BaseDialog +import co.orange.core.extension.setOnSingleClickListener import co.orange.presentation.sell.confirm.SellConfirmActivity import coil.load -import kr.genti.core.base.BaseDialog -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.DialogSellProductBinding diff --git a/presentation/src/main/java/co/orange/presentation/main/profile/ProfileFragment.kt b/presentation/src/main/java/co/orange/presentation/main/profile/ProfileFragment.kt index 8b508e5e..8f0d222c 100644 --- a/presentation/src/main/java/co/orange/presentation/main/profile/ProfileFragment.kt +++ b/presentation/src/main/java/co/orange/presentation/main/profile/ProfileFragment.kt @@ -4,10 +4,10 @@ import android.content.Intent import android.os.Bundle import android.view.View import androidx.core.view.isVisible +import co.orange.core.base.BaseFragment +import co.orange.core.extension.setOnSingleClickListener import co.orange.presentation.setting.SettingActivity import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseFragment -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.FragmentProfileBinding diff --git a/presentation/src/main/java/co/orange/presentation/search/SearchActivity.kt b/presentation/src/main/java/co/orange/presentation/search/SearchActivity.kt index 4d08e238..f5c1e279 100644 --- a/presentation/src/main/java/co/orange/presentation/search/SearchActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/search/SearchActivity.kt @@ -5,15 +5,15 @@ import androidx.activity.viewModels import androidx.core.view.isVisible import androidx.core.widget.doAfterTextChanged import androidx.lifecycle.lifecycleScope +import co.orange.core.base.BaseActivity +import co.orange.core.extension.initFocusWithKeyboard +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.ProductModel import co.orange.presentation.detail.DetailActivity import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.launch -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.initFocusWithKeyboard -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivitySearchBinding diff --git a/presentation/src/main/java/co/orange/presentation/search/SearchItemAdapter.kt b/presentation/src/main/java/co/orange/presentation/search/SearchItemAdapter.kt index 7f762d17..8ddc3849 100644 --- a/presentation/src/main/java/co/orange/presentation/search/SearchItemAdapter.kt +++ b/presentation/src/main/java/co/orange/presentation/search/SearchItemAdapter.kt @@ -3,8 +3,8 @@ package co.orange.presentation.search import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.ListAdapter +import co.orange.core.util.ItemDiffCallback import co.orange.domain.entity.response.ProductModel -import kr.genti.core.util.ItemDiffCallback import kr.genti.presentation.databinding.ItemSearchProductBinding class SearchItemAdapter( diff --git a/presentation/src/main/java/co/orange/presentation/sell/confirm/SellConfirmActivity.kt b/presentation/src/main/java/co/orange/presentation/sell/confirm/SellConfirmActivity.kt index 70b375be..dbde2836 100644 --- a/presentation/src/main/java/co/orange/presentation/sell/confirm/SellConfirmActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/sell/confirm/SellConfirmActivity.kt @@ -4,13 +4,13 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.setNumberForm +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.SellProductModel import co.orange.presentation.sell.push.SellPushActivity import coil.load import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.setNumberForm -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivitySellConfirmBinding diff --git a/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedActivity.kt b/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedActivity.kt index 7ad652d2..d0791fa2 100644 --- a/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedActivity.kt @@ -4,14 +4,14 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.setNumberForm +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.SellInfoModel import co.orange.presentation.main.MainActivity import co.orange.presentation.sell.info.SellInfoActivity import coil.load import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.setNumberForm -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivitySellFinishedBinding diff --git a/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoActivity.kt b/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoActivity.kt index 6ec732b0..5b796d56 100644 --- a/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoActivity.kt @@ -4,13 +4,13 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.breakLines +import co.orange.core.extension.setNumberForm +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.SellDetailModel import coil.load import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.breakLines -import kr.genti.core.extension.setNumberForm -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivitySellInfoBinding diff --git a/presentation/src/main/java/co/orange/presentation/sell/push/SellPushActivity.kt b/presentation/src/main/java/co/orange/presentation/sell/push/SellPushActivity.kt index e8dbfd8d..26412dcf 100644 --- a/presentation/src/main/java/co/orange/presentation/sell/push/SellPushActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/sell/push/SellPushActivity.kt @@ -3,10 +3,10 @@ package co.orange.presentation.sell.push import android.content.Context import android.content.Intent import android.os.Bundle +import co.orange.core.base.BaseActivity +import co.orange.core.extension.setOnSingleClickListener import co.orange.presentation.sell.finished.SellFinishedActivity import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityPushBinding diff --git a/presentation/src/main/java/co/orange/presentation/setting/SettingActivity.kt b/presentation/src/main/java/co/orange/presentation/setting/SettingActivity.kt index 88ecbf27..f01e0a50 100644 --- a/presentation/src/main/java/co/orange/presentation/setting/SettingActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/setting/SettingActivity.kt @@ -3,13 +3,13 @@ package co.orange.presentation.setting import android.content.Intent import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.SettingModel import co.orange.presentation.setting.account.AccountActivity import co.orange.presentation.setting.bank.BankActivity import co.orange.presentation.setting.delivery.DeliveryActivity import dagger.hilt.android.AndroidEntryPoint -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivitySettingBinding diff --git a/presentation/src/main/java/co/orange/presentation/setting/account/AccountActivity.kt b/presentation/src/main/java/co/orange/presentation/setting/account/AccountActivity.kt index bf5aa849..09aa69c9 100644 --- a/presentation/src/main/java/co/orange/presentation/setting/account/AccountActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/setting/account/AccountActivity.kt @@ -2,8 +2,8 @@ package co.orange.presentation.setting.account import android.os.Bundle import androidx.activity.viewModels -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.setOnSingleClickListener +import co.orange.core.base.BaseActivity +import co.orange.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityAccountBinding diff --git a/presentation/src/main/java/co/orange/presentation/setting/bank/BankActivity.kt b/presentation/src/main/java/co/orange/presentation/setting/bank/BankActivity.kt index b7c37082..3cdb4161 100644 --- a/presentation/src/main/java/co/orange/presentation/setting/bank/BankActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/setting/bank/BankActivity.kt @@ -2,9 +2,9 @@ package co.orange.presentation.setting.bank import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.AccountModel -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityBankBinding diff --git a/presentation/src/main/java/co/orange/presentation/setting/delivery/DeliveryActivity.kt b/presentation/src/main/java/co/orange/presentation/setting/delivery/DeliveryActivity.kt index 1fee9ce3..aabade47 100644 --- a/presentation/src/main/java/co/orange/presentation/setting/delivery/DeliveryActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/setting/delivery/DeliveryActivity.kt @@ -2,10 +2,10 @@ package co.orange.presentation.setting.delivery import android.os.Bundle import androidx.activity.viewModels +import co.orange.core.base.BaseActivity +import co.orange.core.extension.breakLines +import co.orange.core.extension.setOnSingleClickListener import co.orange.domain.entity.response.AddressInfoModel -import kr.genti.core.base.BaseActivity -import kr.genti.core.extension.breakLines -import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityDeliveryBinding From 708f486a3f4540de6c90c400e6b63595553f25b2 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 10 Jul 2024 03:15:04 +0900 Subject: [PATCH 02/10] =?UTF-8?q?[FIX/#37]=20core=20=EB=AA=A8=EB=93=88=20?= =?UTF-8?q?=ED=8C=A8=ED=82=A4=EC=A7=80=EB=AA=85=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../co/orange/core/extension/ActivityExt.kt | 2 +- .../co/orange/core/extension/ContextExt.kt | 2 +- .../co/orange/core/extension/FragmentExt.kt | 2 +- .../java/co/orange/core/extension/IntExt.kt | 4 +-- .../co/orange/core/extension/IntentExt.kt | 2 +- .../java/co/orange/core/extension/ViewExt.kt | 2 +- .../java/co/orange/core/state/EnumUiState.kt | 2 +- .../main/java/co/orange/core/state/UiState.kt | 2 +- .../co/orange/core/util/ItemDiffCallback.kt | 2 +- .../core/util/RVItemFirstLastDecoration.kt | 2 +- .../orange/core/util/RvItemLastDecoration.kt | 2 +- .../presentation/detail/OptionAdapter.kt | 24 ++++++++++------- .../detail/OptionDetailAdapter.kt | 26 ++++++++++++------- .../presentation/main/home/HomeAdapter.kt | 4 +-- .../main/home/HomeProductViewHolder.kt | 11 ++++---- .../search/SearchItemViewHolder.kt | 8 +++--- .../presentation/search/SearchWordAdapter.kt | 24 ++++++++++------- .../search/SearchWordViewHolder.kt | 2 +- 18 files changed, 70 insertions(+), 53 deletions(-) diff --git a/core/src/main/java/co/orange/core/extension/ActivityExt.kt b/core/src/main/java/co/orange/core/extension/ActivityExt.kt index adf1ae95..80b1b3f3 100644 --- a/core/src/main/java/co/orange/core/extension/ActivityExt.kt +++ b/core/src/main/java/co/orange/core/extension/ActivityExt.kt @@ -1,4 +1,4 @@ -package kr.genti.core.extension +package co.orange.core.extension import android.app.Activity import android.content.Context diff --git a/core/src/main/java/co/orange/core/extension/ContextExt.kt b/core/src/main/java/co/orange/core/extension/ContextExt.kt index fd29b12d..aa8e38df 100644 --- a/core/src/main/java/co/orange/core/extension/ContextExt.kt +++ b/core/src/main/java/co/orange/core/extension/ContextExt.kt @@ -1,4 +1,4 @@ -package kr.genti.core.extension +package co.orange.core.extension import android.app.Activity import android.content.Context diff --git a/core/src/main/java/co/orange/core/extension/FragmentExt.kt b/core/src/main/java/co/orange/core/extension/FragmentExt.kt index d1f35a44..cdd8478c 100644 --- a/core/src/main/java/co/orange/core/extension/FragmentExt.kt +++ b/core/src/main/java/co/orange/core/extension/FragmentExt.kt @@ -1,4 +1,4 @@ -package kr.genti.core.extension +package co.orange.core.extension import android.view.View import android.widget.Toast diff --git a/core/src/main/java/co/orange/core/extension/IntExt.kt b/core/src/main/java/co/orange/core/extension/IntExt.kt index 0bc75369..0d46e5fc 100644 --- a/core/src/main/java/co/orange/core/extension/IntExt.kt +++ b/core/src/main/java/co/orange/core/extension/IntExt.kt @@ -1,4 +1,4 @@ -package kr.genti.core.extension +package co.orange.core.extension import android.content.Context import android.util.TypedValue @@ -19,4 +19,4 @@ fun Int.setOverThousand(): String = this.toString() } else { "999+" - } \ No newline at end of file + } diff --git a/core/src/main/java/co/orange/core/extension/IntentExt.kt b/core/src/main/java/co/orange/core/extension/IntentExt.kt index c79ad1c0..eb204b76 100644 --- a/core/src/main/java/co/orange/core/extension/IntentExt.kt +++ b/core/src/main/java/co/orange/core/extension/IntentExt.kt @@ -1,4 +1,4 @@ -package kr.genti.core.extension +package co.orange.core.extension import android.content.Intent import android.os.Build diff --git a/core/src/main/java/co/orange/core/extension/ViewExt.kt b/core/src/main/java/co/orange/core/extension/ViewExt.kt index 3489fab3..a90a7281 100644 --- a/core/src/main/java/co/orange/core/extension/ViewExt.kt +++ b/core/src/main/java/co/orange/core/extension/ViewExt.kt @@ -1,4 +1,4 @@ -package kr.genti.core.extension +package co.orange.core.extension import android.view.View diff --git a/core/src/main/java/co/orange/core/state/EnumUiState.kt b/core/src/main/java/co/orange/core/state/EnumUiState.kt index 822b4f6d..31f0a15f 100644 --- a/core/src/main/java/co/orange/core/state/EnumUiState.kt +++ b/core/src/main/java/co/orange/core/state/EnumUiState.kt @@ -1,4 +1,4 @@ -package kr.genti.core.state +package co.orange.core.state enum class EnumUiState { LOADING, diff --git a/core/src/main/java/co/orange/core/state/UiState.kt b/core/src/main/java/co/orange/core/state/UiState.kt index 813ff035..98842a32 100644 --- a/core/src/main/java/co/orange/core/state/UiState.kt +++ b/core/src/main/java/co/orange/core/state/UiState.kt @@ -1,4 +1,4 @@ -package kr.genti.core.state +package co.orange.core.state sealed interface UiState { object Empty : UiState diff --git a/core/src/main/java/co/orange/core/util/ItemDiffCallback.kt b/core/src/main/java/co/orange/core/util/ItemDiffCallback.kt index b3eae0c6..5a9c5bfd 100644 --- a/core/src/main/java/co/orange/core/util/ItemDiffCallback.kt +++ b/core/src/main/java/co/orange/core/util/ItemDiffCallback.kt @@ -1,4 +1,4 @@ -package kr.genti.core.util +package co.orange.core.util import androidx.recyclerview.widget.DiffUtil diff --git a/core/src/main/java/co/orange/core/util/RVItemFirstLastDecoration.kt b/core/src/main/java/co/orange/core/util/RVItemFirstLastDecoration.kt index 0d6b85e9..8c9bb093 100644 --- a/core/src/main/java/co/orange/core/util/RVItemFirstLastDecoration.kt +++ b/core/src/main/java/co/orange/core/util/RVItemFirstLastDecoration.kt @@ -1,4 +1,4 @@ -package kr.genti.core.util +package co.orange.core.util import android.graphics.Rect import android.view.View diff --git a/core/src/main/java/co/orange/core/util/RvItemLastDecoration.kt b/core/src/main/java/co/orange/core/util/RvItemLastDecoration.kt index f25e37b6..b0f2467c 100644 --- a/core/src/main/java/co/orange/core/util/RvItemLastDecoration.kt +++ b/core/src/main/java/co/orange/core/util/RvItemLastDecoration.kt @@ -1,4 +1,4 @@ -package kr.genti.core.util +package co.orange.core.util import android.content.Context import android.graphics.Rect diff --git a/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt b/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt index a02abf9b..d142eb19 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt @@ -3,22 +3,27 @@ package co.orange.presentation.detail import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.ListAdapter +import co.orange.core.util.ItemDiffCallback import co.orange.domain.entity.response.OptionModel -import kr.genti.core.util.ItemDiffCallback import kr.genti.presentation.databinding.ItemOptionBinding class OptionAdapter( private val itemClick: (Int, Long, Long) -> Unit, ) : ListAdapter(diffUtil) { - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OptionViewHolder { + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int, + ): OptionViewHolder { val inflater by lazy { LayoutInflater.from(parent.context) } val binding: ItemOptionBinding = ItemOptionBinding.inflate(inflater, parent, false) return OptionViewHolder(binding, itemClick) } - override fun onBindViewHolder(holder: OptionViewHolder, position: Int) { + override fun onBindViewHolder( + holder: OptionViewHolder, + position: Int, + ) { val item = getItem(position) ?: return holder.onBind(item, position) } @@ -30,9 +35,10 @@ class OptionAdapter( } companion object { - private val diffUtil = ItemDiffCallback( - onItemsTheSame = { old, new -> old.optionId == new.optionId }, - onContentsTheSame = { old, new -> old == new }, - ) + private val diffUtil = + ItemDiffCallback( + onItemsTheSame = { old, new -> old.optionId == new.optionId }, + onContentsTheSame = { old, new -> old == new }, + ) } -} \ No newline at end of file +} diff --git a/presentation/src/main/java/co/orange/presentation/detail/OptionDetailAdapter.kt b/presentation/src/main/java/co/orange/presentation/detail/OptionDetailAdapter.kt index fd4c7e0d..3b96dfc6 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/OptionDetailAdapter.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/OptionDetailAdapter.kt @@ -3,25 +3,30 @@ package co.orange.presentation.detail import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.ListAdapter +import co.orange.core.extension.setOnSingleClickListener +import co.orange.core.util.ItemDiffCallback import co.orange.domain.entity.response.OptionModel.OptionDetailModel -import kr.genti.core.extension.setOnSingleClickListener -import kr.genti.core.util.ItemDiffCallback import kr.genti.presentation.databinding.ItemOptionDetailBinding class OptionDetailAdapter( private val itemClick: (Long) -> Unit, ) : ListAdapter(diffUtil) { - private var selectedPosition = -1 - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OptionDetailViewHolder { + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int, + ): OptionDetailViewHolder { val inflater by lazy { LayoutInflater.from(parent.context) } val binding: ItemOptionDetailBinding = ItemOptionDetailBinding.inflate(inflater, parent, false) return OptionDetailViewHolder(binding) } - override fun onBindViewHolder(holder: OptionDetailViewHolder, position: Int) { + override fun onBindViewHolder( + holder: OptionDetailViewHolder, + position: Int, + ) { val item = getItem(position) ?: return holder.binding.root.setOnSingleClickListener { selectedPosition = holder.getAdapterPosition() @@ -39,9 +44,10 @@ class OptionDetailAdapter( } companion object { - private val diffUtil = ItemDiffCallback( - onItemsTheSame = { old, new -> old.optionDetailId == new.optionDetailId }, - onContentsTheSame = { old, new -> old == new }, - ) + private val diffUtil = + ItemDiffCallback( + onItemsTheSame = { old, new -> old.optionDetailId == new.optionDetailId }, + onContentsTheSame = { old, new -> old == new }, + ) } -} \ No newline at end of file +} diff --git a/presentation/src/main/java/co/orange/presentation/main/home/HomeAdapter.kt b/presentation/src/main/java/co/orange/presentation/main/home/HomeAdapter.kt index 3d9e48f2..c39797b9 100644 --- a/presentation/src/main/java/co/orange/presentation/main/home/HomeAdapter.kt +++ b/presentation/src/main/java/co/orange/presentation/main/home/HomeAdapter.kt @@ -4,8 +4,8 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView +import co.orange.core.util.ItemDiffCallback import co.orange.domain.entity.response.ProductModel -import kr.genti.core.util.ItemDiffCallback import kr.genti.presentation.R import kr.genti.presentation.databinding.ItemHomeBannerBinding import kr.genti.presentation.databinding.ItemHomeProductBinding @@ -27,7 +27,7 @@ class HomeAdapter( VIEW_TYPE_BANNER -> HomeBannerViewHolder( ItemHomeBannerBinding.inflate(inflater, parent, false), - bannerClick + bannerClick, ) VIEW_TYPE_PRODUCT -> diff --git a/presentation/src/main/java/co/orange/presentation/main/home/HomeProductViewHolder.kt b/presentation/src/main/java/co/orange/presentation/main/home/HomeProductViewHolder.kt index 776c2ad7..d78b24fa 100644 --- a/presentation/src/main/java/co/orange/presentation/main/home/HomeProductViewHolder.kt +++ b/presentation/src/main/java/co/orange/presentation/main/home/HomeProductViewHolder.kt @@ -2,12 +2,12 @@ package co.orange.presentation.main.home import android.graphics.Paint import androidx.recyclerview.widget.RecyclerView +import co.orange.core.extension.breakLines +import co.orange.core.extension.setNumberForm +import co.orange.core.extension.setOnSingleClickListener +import co.orange.core.extension.setOverThousand import co.orange.domain.entity.response.ProductModel import coil.load -import kr.genti.core.extension.breakLines -import kr.genti.core.extension.setNumberForm -import kr.genti.core.extension.setOnSingleClickListener -import kr.genti.core.extension.setOverThousand import kr.genti.presentation.databinding.ItemHomeProductBinding class HomeProductViewHolder( @@ -30,7 +30,6 @@ class HomeProductViewHolder( } tvHomeItemNowPrice.text = item.salePrice.setNumberForm() tvHomeItemLike.text = item.interestCount.setOverThousand() - } } -} \ No newline at end of file +} diff --git a/presentation/src/main/java/co/orange/presentation/search/SearchItemViewHolder.kt b/presentation/src/main/java/co/orange/presentation/search/SearchItemViewHolder.kt index fa14d7da..90ea3717 100644 --- a/presentation/src/main/java/co/orange/presentation/search/SearchItemViewHolder.kt +++ b/presentation/src/main/java/co/orange/presentation/search/SearchItemViewHolder.kt @@ -2,12 +2,12 @@ package co.orange.presentation.search import android.graphics.Paint import androidx.recyclerview.widget.RecyclerView +import co.orange.core.extension.breakLines +import co.orange.core.extension.setNumberForm +import co.orange.core.extension.setOnSingleClickListener +import co.orange.core.extension.setOverThousand import co.orange.domain.entity.response.ProductModel import coil.load -import kr.genti.core.extension.breakLines -import kr.genti.core.extension.setNumberForm -import kr.genti.core.extension.setOnSingleClickListener -import kr.genti.core.extension.setOverThousand import kr.genti.presentation.databinding.ItemSearchProductBinding class SearchItemViewHolder( diff --git a/presentation/src/main/java/co/orange/presentation/search/SearchWordAdapter.kt b/presentation/src/main/java/co/orange/presentation/search/SearchWordAdapter.kt index fd2f87b9..0814d820 100644 --- a/presentation/src/main/java/co/orange/presentation/search/SearchWordAdapter.kt +++ b/presentation/src/main/java/co/orange/presentation/search/SearchWordAdapter.kt @@ -3,21 +3,26 @@ package co.orange.presentation.search import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.ListAdapter -import kr.genti.core.util.ItemDiffCallback +import co.orange.core.util.ItemDiffCallback import kr.genti.presentation.databinding.ItemSearchWordBinding class SearchWordAdapter( private val keywordClick: (String) -> (Unit), ) : ListAdapter(diffUtil) { - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchWordViewHolder { + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int, + ): SearchWordViewHolder { val inflater by lazy { LayoutInflater.from(parent.context) } val binding: ItemSearchWordBinding = ItemSearchWordBinding.inflate(inflater, parent, false) return SearchWordViewHolder(binding, keywordClick) } - override fun onBindViewHolder(holder: SearchWordViewHolder, position: Int) { + override fun onBindViewHolder( + holder: SearchWordViewHolder, + position: Int, + ) { val item = getItem(position) ?: return holder.onBind(item) } @@ -29,9 +34,10 @@ class SearchWordAdapter( } companion object { - private val diffUtil = ItemDiffCallback( - onItemsTheSame = { old, new -> old.length == new.length }, - onContentsTheSame = { old, new -> old == new }, - ) + private val diffUtil = + ItemDiffCallback( + onItemsTheSame = { old, new -> old.length == new.length }, + onContentsTheSame = { old, new -> old == new }, + ) } -} \ No newline at end of file +} diff --git a/presentation/src/main/java/co/orange/presentation/search/SearchWordViewHolder.kt b/presentation/src/main/java/co/orange/presentation/search/SearchWordViewHolder.kt index 331afdae..b3976c27 100644 --- a/presentation/src/main/java/co/orange/presentation/search/SearchWordViewHolder.kt +++ b/presentation/src/main/java/co/orange/presentation/search/SearchWordViewHolder.kt @@ -1,7 +1,7 @@ package co.orange.presentation.search import androidx.recyclerview.widget.RecyclerView -import kr.genti.core.extension.setOnSingleClickListener +import co.orange.core.extension.setOnSingleClickListener import kr.genti.presentation.databinding.ItemSearchWordBinding class SearchWordViewHolder( From 50331319c4c33fabdd05fe9e294601fe8f21185b Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 10 Jul 2024 03:33:59 +0900 Subject: [PATCH 03/10] =?UTF-8?q?[ADD/#37]=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=9E=AC=EB=B0=9C=EA=B8=89=20domain=20=EB=AA=A8=EB=93=88=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../orange/domain/entity/request/TokenRequestModel.kt | 5 +++++ .../orange/domain/entity/response/AuthTokenModel.kt | 7 +++++++ .../co/orange/domain/repository/AuthRepository.kt | 11 +++++++++++ 3 files changed, 23 insertions(+) create mode 100644 domain/src/main/kotlin/co/orange/domain/entity/request/TokenRequestModel.kt create mode 100644 domain/src/main/kotlin/co/orange/domain/entity/response/AuthTokenModel.kt create mode 100644 domain/src/main/kotlin/co/orange/domain/repository/AuthRepository.kt diff --git a/domain/src/main/kotlin/co/orange/domain/entity/request/TokenRequestModel.kt b/domain/src/main/kotlin/co/orange/domain/entity/request/TokenRequestModel.kt new file mode 100644 index 00000000..4edfb4af --- /dev/null +++ b/domain/src/main/kotlin/co/orange/domain/entity/request/TokenRequestModel.kt @@ -0,0 +1,5 @@ +package co.orange.domain.entity.request + +data class TokenRequestModel( + val userId: Long, +) diff --git a/domain/src/main/kotlin/co/orange/domain/entity/response/AuthTokenModel.kt b/domain/src/main/kotlin/co/orange/domain/entity/response/AuthTokenModel.kt new file mode 100644 index 00000000..f7aecc08 --- /dev/null +++ b/domain/src/main/kotlin/co/orange/domain/entity/response/AuthTokenModel.kt @@ -0,0 +1,7 @@ +package co.orange.domain.entity.response + +data class AuthTokenModel( + val accessToken: String, + val refreshToken: String, + val userId: Long, +) diff --git a/domain/src/main/kotlin/co/orange/domain/repository/AuthRepository.kt b/domain/src/main/kotlin/co/orange/domain/repository/AuthRepository.kt new file mode 100644 index 00000000..7a3cc63e --- /dev/null +++ b/domain/src/main/kotlin/co/orange/domain/repository/AuthRepository.kt @@ -0,0 +1,11 @@ +package co.orange.domain.repository + +import co.orange.domain.entity.request.TokenRequestModel +import co.orange.domain.entity.response.AuthTokenModel + +interface AuthRepository { + suspend fun postReissueTokens( + authorization: String, + request: TokenRequestModel, + ): Result +} From b7ca501983599b94b66eb08837b85d4787a21c40 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 10 Jul 2024 03:34:17 +0900 Subject: [PATCH 04/10] =?UTF-8?q?[ADD/#37]=20BaseResopnse=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/co/orange/data/dto/BaseResponse.kt | 18 ++++++++++++++++++ .../co/orange/data/dto/NonDataBaseResponse.kt | 14 ++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 data/src/main/java/co/orange/data/dto/BaseResponse.kt create mode 100644 data/src/main/java/co/orange/data/dto/NonDataBaseResponse.kt diff --git a/data/src/main/java/co/orange/data/dto/BaseResponse.kt b/data/src/main/java/co/orange/data/dto/BaseResponse.kt new file mode 100644 index 00000000..dbb732e4 --- /dev/null +++ b/data/src/main/java/co/orange/data/dto/BaseResponse.kt @@ -0,0 +1,18 @@ +package co.orange.data.dto + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class BaseResponse( + @SerialName("success") + val success: Boolean, + @SerialName("response") + val response: T, + @SerialName("code") + val code: String, + @SerialName("message") + val message: String, + @SerialName("status") + val status: Int, +) diff --git a/data/src/main/java/co/orange/data/dto/NonDataBaseResponse.kt b/data/src/main/java/co/orange/data/dto/NonDataBaseResponse.kt new file mode 100644 index 00000000..60876e19 --- /dev/null +++ b/data/src/main/java/co/orange/data/dto/NonDataBaseResponse.kt @@ -0,0 +1,14 @@ +package co.orange.data.dto + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class NonDataBaseResponse( + @SerialName("success") + val success: Boolean, + @SerialName("errorCode") + val errorCode: String?, + @SerialName("errorMessage") + val errorMessage: String?, +) From c63beb12b69d570e3c819c96d5bdec4fbcb7ed86 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 10 Jul 2024 03:34:32 +0900 Subject: [PATCH 05/10] =?UTF-8?q?[ADD/#37]=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=9E=AC=EB=B0=9C=EA=B8=89=20data=20=EB=AA=A8=EB=93=88=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../orange/data/dataSource/AuthDataSource.kt | 12 +++++++++ .../data/dto/request/TokenRequestDto.kt | 15 +++++++++++ .../orange/data/dto/response/AuthTokenDto.kt | 17 +++++++++++++ .../data/repositoryImpl/AuthRepositoryImpl.kt | 25 +++++++++++++++++++ .../co/orange/data/service/AuthService.kt | 17 +++++++++++++ 5 files changed, 86 insertions(+) create mode 100644 data/src/main/java/co/orange/data/dataSource/AuthDataSource.kt create mode 100644 data/src/main/java/co/orange/data/dto/request/TokenRequestDto.kt create mode 100644 data/src/main/java/co/orange/data/dto/response/AuthTokenDto.kt create mode 100644 data/src/main/java/co/orange/data/repositoryImpl/AuthRepositoryImpl.kt create mode 100644 data/src/main/java/co/orange/data/service/AuthService.kt diff --git a/data/src/main/java/co/orange/data/dataSource/AuthDataSource.kt b/data/src/main/java/co/orange/data/dataSource/AuthDataSource.kt new file mode 100644 index 00000000..5dc97fac --- /dev/null +++ b/data/src/main/java/co/orange/data/dataSource/AuthDataSource.kt @@ -0,0 +1,12 @@ +package co.orange.data.dataSource + +import co.orange.data.dto.BaseResponse +import co.orange.data.dto.request.TokenRequestDto +import co.orange.data.dto.response.AuthTokenDto + +interface AuthDataSource { + suspend fun postReissueTokens( + authorization: String, + request: TokenRequestDto, + ): BaseResponse +} diff --git a/data/src/main/java/co/orange/data/dto/request/TokenRequestDto.kt b/data/src/main/java/co/orange/data/dto/request/TokenRequestDto.kt new file mode 100644 index 00000000..02e5f9fa --- /dev/null +++ b/data/src/main/java/co/orange/data/dto/request/TokenRequestDto.kt @@ -0,0 +1,15 @@ +package co.orange.data.dto.request + +import co.orange.domain.entity.request.TokenRequestModel +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class TokenRequestDto( + @SerialName("userId") + val userId: Long, +) { + companion object { + fun TokenRequestModel.toDto() = TokenRequestDto(userId) + } +} diff --git a/data/src/main/java/co/orange/data/dto/response/AuthTokenDto.kt b/data/src/main/java/co/orange/data/dto/response/AuthTokenDto.kt new file mode 100644 index 00000000..96e1413d --- /dev/null +++ b/data/src/main/java/co/orange/data/dto/response/AuthTokenDto.kt @@ -0,0 +1,17 @@ +package co.orange.data.dto.response + +import co.orange.domain.entity.response.AuthTokenModel +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class AuthTokenDto( + @SerialName("accessToken") + val accessToken: String, + @SerialName("refreshToken") + val refreshToken: String, + @SerialName("userId") + val userId: Long, +) { + fun toModel() = AuthTokenModel(accessToken = accessToken, refreshToken = refreshToken, userId = userId) +} diff --git a/data/src/main/java/co/orange/data/repositoryImpl/AuthRepositoryImpl.kt b/data/src/main/java/co/orange/data/repositoryImpl/AuthRepositoryImpl.kt new file mode 100644 index 00000000..84d6876d --- /dev/null +++ b/data/src/main/java/co/orange/data/repositoryImpl/AuthRepositoryImpl.kt @@ -0,0 +1,25 @@ +package co.orange.data.repositoryImpl + +import co.orange.data.dataSource.AuthDataSource +import co.orange.data.dto.request.TokenRequestDto.Companion.toDto +import co.orange.domain.entity.request.TokenRequestModel +import co.orange.domain.entity.response.AuthTokenModel +import co.orange.domain.repository.AuthRepository +import javax.inject.Inject + +class AuthRepositoryImpl + @Inject + constructor( + private val authDataSource: AuthDataSource, + ) : AuthRepository { + override suspend fun postReissueTokens( + authorization: String, + request: TokenRequestModel, + ): Result = + runCatching { + authDataSource.postReissueTokens( + authorization, + request.toDto(), + ).response.toModel() + } + } diff --git a/data/src/main/java/co/orange/data/service/AuthService.kt b/data/src/main/java/co/orange/data/service/AuthService.kt new file mode 100644 index 00000000..30b367e6 --- /dev/null +++ b/data/src/main/java/co/orange/data/service/AuthService.kt @@ -0,0 +1,17 @@ +package co.orange.data.service + +import co.orange.data.dto.BaseResponse +import co.orange.data.dto.request.TokenRequestDto +import co.orange.data.dto.response.AuthTokenDto +import retrofit2.http.Body +import retrofit2.http.Header +import retrofit2.http.POST + +interface AuthService { + // TODO: 서버 나오면 수정 + @POST("api/users/reissue") + suspend fun postReissueTokens( + @Header("Authorization") authorization: String, + @Body request: TokenRequestDto, + ): BaseResponse +} From 448cbb6f36091dc616dc8a2bfc5fffd647077612 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 10 Jul 2024 03:35:03 +0900 Subject: [PATCH 06/10] =?UTF-8?q?[ADD/#37]=20SharedPreference=20data=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/kotlin/Versions.kt | 4 +-- .../data/dataSourceImpl/AuthDataSourceImpl.kt | 19 +++++++++++ .../co/orange/data/local/UserSharedPref.kt | 9 +++++ .../orange/data/local/UserSharedPrefImpl.kt | 33 +++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 data/src/main/java/co/orange/data/dataSourceImpl/AuthDataSourceImpl.kt create mode 100644 data/src/main/java/co/orange/data/local/UserSharedPref.kt create mode 100644 data/src/main/java/co/orange/data/local/UserSharedPrefImpl.kt diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 3c0014f5..532c17d8 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -35,9 +35,9 @@ object Versions { const val circleIndicatorVersion = "2.1.6" const val shimmerVersion = "0.5.0" const val junitVersion = "4.13.2" - const val espressoVersion = "3.3.0" + const val espressoVersion = "3.5.1" const val androidTestVersion = "1.1.2" val javaVersion = JavaVersion.VERSION_17 const val jvmVersion = "17" -} \ No newline at end of file +} diff --git a/data/src/main/java/co/orange/data/dataSourceImpl/AuthDataSourceImpl.kt b/data/src/main/java/co/orange/data/dataSourceImpl/AuthDataSourceImpl.kt new file mode 100644 index 00000000..77ffec5c --- /dev/null +++ b/data/src/main/java/co/orange/data/dataSourceImpl/AuthDataSourceImpl.kt @@ -0,0 +1,19 @@ +package co.orange.data.dataSourceImpl + +import co.orange.data.dataSource.AuthDataSource +import co.orange.data.dto.BaseResponse +import co.orange.data.dto.request.TokenRequestDto +import co.orange.data.dto.response.AuthTokenDto +import co.orange.data.service.AuthService +import javax.inject.Inject + +data class AuthDataSourceImpl + @Inject + constructor( + private val authService: AuthService, + ) : AuthDataSource { + override suspend fun postReissueTokens( + authorization: String, + request: TokenRequestDto, + ): BaseResponse = authService.postReissueTokens(authorization, request) + } diff --git a/data/src/main/java/co/orange/data/local/UserSharedPref.kt b/data/src/main/java/co/orange/data/local/UserSharedPref.kt new file mode 100644 index 00000000..6577cf66 --- /dev/null +++ b/data/src/main/java/co/orange/data/local/UserSharedPref.kt @@ -0,0 +1,9 @@ +package co.orange.data.local + +interface UserSharedPref { + var accessToken: String + var refreshToken: String + var userId: Long + + fun clearInfo() +} diff --git a/data/src/main/java/co/orange/data/local/UserSharedPrefImpl.kt b/data/src/main/java/co/orange/data/local/UserSharedPrefImpl.kt new file mode 100644 index 00000000..23362473 --- /dev/null +++ b/data/src/main/java/co/orange/data/local/UserSharedPrefImpl.kt @@ -0,0 +1,33 @@ +package co.orange.data.local + +import android.content.SharedPreferences +import androidx.core.content.edit +import javax.inject.Inject + +class UserSharedPrefImpl + @Inject + constructor( + private val dataStore: SharedPreferences, + ) : UserSharedPref { + override var accessToken: String + get() = dataStore.getString(ACCESS_TOKEN, "").orEmpty() + set(value) = dataStore.edit { putString(ACCESS_TOKEN, value) } + + override var refreshToken: String + get() = dataStore.getString(REFRESH_TOKEN, "").orEmpty() + set(value) = dataStore.edit { putString(REFRESH_TOKEN, value) } + + override var userId: Long + get() = dataStore.getLong(USER_ID, 0L) + set(value) = dataStore.edit { putLong(USER_ID, value) } + + override fun clearInfo() { + dataStore.edit().clear().apply() + } + + companion object { + private const val ACCESS_TOKEN = "ACCESS_TOKEN" + private const val REFRESH_TOKEN = "REFRESH_TOKEN" + private const val USER_ID = "USER_ID" + } + } From 6ebe551334c16616dbc3e54b794388343b1bdaf8 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 10 Jul 2024 03:35:14 +0900 Subject: [PATCH 07/10] =?UTF-8?q?[ADD/#37]=20AuthInterceptor=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../co/orange/ddanzi/di/AuthInterceptor.kt | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 app/src/main/java/co/orange/ddanzi/di/AuthInterceptor.kt diff --git a/app/src/main/java/co/orange/ddanzi/di/AuthInterceptor.kt b/app/src/main/java/co/orange/ddanzi/di/AuthInterceptor.kt new file mode 100644 index 00000000..ab98b721 --- /dev/null +++ b/app/src/main/java/co/orange/ddanzi/di/AuthInterceptor.kt @@ -0,0 +1,90 @@ +package co.orange.ddanzi.di + +import android.content.Context +import android.content.Intent +import android.os.Handler +import android.os.Looper +import co.orange.core.extension.toast +import co.orange.data.local.UserSharedPref +import co.orange.domain.entity.request.TokenRequestModel +import co.orange.domain.repository.AuthRepository +import co.orange.presentation.auth.login.LoginActivity +import dagger.hilt.android.qualifiers.ApplicationContext +import kotlinx.coroutines.runBlocking +import okhttp3.Interceptor +import okhttp3.Request +import okhttp3.Response +import timber.log.Timber +import javax.inject.Inject + +class AuthInterceptor + @Inject + constructor( + private val authRepository: AuthRepository, + private val sharedPref: UserSharedPref, + @ApplicationContext private val context: Context, + ) : Interceptor { + override fun intercept(chain: Interceptor.Chain): Response { + val originalRequest = chain.request() + + Timber.d("GET ACCESS TOKEN : ${sharedPref.accessToken}") + + val authRequest = + if (sharedPref.accessToken.isNotBlank()) { + originalRequest.newBuilder().newAuthBuilder().build() + } else { + originalRequest + } + + val response = chain.proceed(authRequest) + + when (response.code) { + CODE_TOKEN_EXPIRED -> { + try { + runBlocking { + authRepository.postReissueTokens( + sharedPref.refreshToken, + TokenRequestModel(sharedPref.userId), + ) + }.onSuccess { data -> + sharedPref.apply { + accessToken = data.accessToken + refreshToken = data.refreshToken + userId = data.userId + } + + response.close() + + val newRequest = + authRequest.newBuilder().removeHeader(AUTHORIZATION).newAuthBuilder() + .build() + + return chain.proceed(newRequest) + } + } catch (t: Throwable) { + Timber.d(t.message) + } + + sharedPref.clearInfo() + + Handler(Looper.getMainLooper()).post { + context.toast(TOKEN_EXPIRED_ERROR) + Intent(context, LoginActivity::class.java).apply { + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) + context.startActivity(this) + } + } + } + } + return response + } + + private fun Request.Builder.newAuthBuilder() = this.addHeader(AUTHORIZATION, "$BEARER ${sharedPref.accessToken}") + + companion object { + private const val CODE_TOKEN_EXPIRED = 401 + private const val TOKEN_EXPIRED_ERROR = "토큰이 만료되었어요\n다시 로그인 해주세요" + private const val BEARER = "Bearer" + private const val AUTHORIZATION = "Authorization" + } + } From 9f4f9e266daa0c0d602861f218d9f8d9339a128e Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 10 Jul 2024 03:35:25 +0900 Subject: [PATCH 08/10] =?UTF-8?q?[ADD/#37]=20=EC=84=9C=EB=B2=84=ED=86=B5?= =?UTF-8?q?=EC=8B=A0=20=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../co/orange/ddanzi/di/DataSourceModule.kt | 17 +++++++++++++++++ .../co/orange/ddanzi/di/RepositoryModule.kt | 17 +++++++++++++++++ .../java/co/orange/ddanzi/di/ServiceModule.kt | 19 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 app/src/main/java/co/orange/ddanzi/di/DataSourceModule.kt create mode 100644 app/src/main/java/co/orange/ddanzi/di/RepositoryModule.kt create mode 100644 app/src/main/java/co/orange/ddanzi/di/ServiceModule.kt diff --git a/app/src/main/java/co/orange/ddanzi/di/DataSourceModule.kt b/app/src/main/java/co/orange/ddanzi/di/DataSourceModule.kt new file mode 100644 index 00000000..ff476a64 --- /dev/null +++ b/app/src/main/java/co/orange/ddanzi/di/DataSourceModule.kt @@ -0,0 +1,17 @@ +package co.orange.ddanzi.di + +import co.orange.data.dataSource.AuthDataSource +import co.orange.data.dataSourceImpl.AuthDataSourceImpl +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object DataSourceModule { + @Provides + @Singleton + fun provideAuthDataSource(authDataSourceImpl: AuthDataSourceImpl): AuthDataSource = authDataSourceImpl +} diff --git a/app/src/main/java/co/orange/ddanzi/di/RepositoryModule.kt b/app/src/main/java/co/orange/ddanzi/di/RepositoryModule.kt new file mode 100644 index 00000000..9cabf0b9 --- /dev/null +++ b/app/src/main/java/co/orange/ddanzi/di/RepositoryModule.kt @@ -0,0 +1,17 @@ +package co.orange.ddanzi.di + +import co.orange.data.repositoryImpl.AuthRepositoryImpl +import co.orange.domain.repository.AuthRepository +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object RepositoryModule { + @Provides + @Singleton + fun provideAuthRepository(authRepositoryImpl: AuthRepositoryImpl): AuthRepository = authRepositoryImpl +} diff --git a/app/src/main/java/co/orange/ddanzi/di/ServiceModule.kt b/app/src/main/java/co/orange/ddanzi/di/ServiceModule.kt new file mode 100644 index 00000000..057e3353 --- /dev/null +++ b/app/src/main/java/co/orange/ddanzi/di/ServiceModule.kt @@ -0,0 +1,19 @@ +package co.orange.ddanzi.di + +import co.orange.data.service.AuthService +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import retrofit2.Retrofit +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object ServiceModule { + @Provides + @Singleton + fun provideAuthService( + @RetrofitQualifier.NOTOKEN retrofit: Retrofit, + ): AuthService = retrofit.create(AuthService::class.java) +} From 1654e8e65bc437b8d28ee0c558cbe75fff27fafd Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 10 Jul 2024 03:35:41 +0900 Subject: [PATCH 09/10] =?UTF-8?q?[ADD/#37]=20SharedPref=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../co/orange/ddanzi/di/SharedPrefModule.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/src/main/java/co/orange/ddanzi/di/SharedPrefModule.kt diff --git a/app/src/main/java/co/orange/ddanzi/di/SharedPrefModule.kt b/app/src/main/java/co/orange/ddanzi/di/SharedPrefModule.kt new file mode 100644 index 00000000..6a8d437b --- /dev/null +++ b/app/src/main/java/co/orange/ddanzi/di/SharedPrefModule.kt @@ -0,0 +1,26 @@ +package co.orange.ddanzi.di + +import android.content.Context +import android.content.SharedPreferences +import co.orange.data.local.UserSharedPref +import co.orange.data.local.UserSharedPrefImpl +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object SharedPrefModule { + @Provides + @Singleton + fun provideSharedPreferences( + @ApplicationContext context: Context, + ): SharedPreferences = context.getSharedPreferences(context.packageName, Context.MODE_PRIVATE) + + @Provides + @Singleton + fun provideSharedPref(sharedPrefImpl: UserSharedPrefImpl): UserSharedPref = sharedPrefImpl +} From 08a340a5c392b3f199a2bb7b7bd7f17173011a9d Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 10 Jul 2024 03:35:54 +0900 Subject: [PATCH 10/10] =?UTF-8?q?[ADD/#37]=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=ED=97=A4=EB=8D=94=EB=B3=84=20Retrofit=20=EA=B0=9D=EC=B2=B4=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../co/orange/ddanzi/di/RetrofitModule.kt | 112 ++++++++++++++++++ .../co/orange/ddanzi/di/RetrofitQualifier.kt | 13 ++ 2 files changed, 125 insertions(+) create mode 100644 app/src/main/java/co/orange/ddanzi/di/RetrofitModule.kt create mode 100644 app/src/main/java/co/orange/ddanzi/di/RetrofitQualifier.kt diff --git a/app/src/main/java/co/orange/ddanzi/di/RetrofitModule.kt b/app/src/main/java/co/orange/ddanzi/di/RetrofitModule.kt new file mode 100644 index 00000000..8f082a45 --- /dev/null +++ b/app/src/main/java/co/orange/ddanzi/di/RetrofitModule.kt @@ -0,0 +1,112 @@ +package co.orange.ddanzi.di + +import co.orange.core.extension.isJsonArray +import co.orange.core.extension.isJsonObject +import co.orange.ddanzi.BuildConfig.BASE_URL +import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import kotlinx.serialization.json.Json +import okhttp3.Interceptor +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor +import org.json.JSONArray +import org.json.JSONObject +import retrofit2.Converter +import retrofit2.Retrofit +import timber.log.Timber +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object RetrofitModule { + private const val APPLICATION_JSON = "application/json" + + @Provides + @Singleton + fun provideJson(): Json = + Json { + ignoreUnknownKeys = true + prettyPrint = true + } + + @Provides + @Singleton + fun provideJsonConverter(json: Json): Converter.Factory = + json.asConverterFactory( + APPLICATION_JSON.toMediaType(), + ) + + @Provides + @Singleton + fun provideHttpLoggingInterceptor(): Interceptor = + HttpLoggingInterceptor { message -> + when { + message.isJsonObject() -> + Timber.tag("okhttp").d(JSONObject(message).toString(4)) + + message.isJsonArray() -> + Timber.tag("okhttp").d(JSONArray(message).toString(4)) + + else -> { + Timber.tag("okhttp").d("CONNECTION INFO -> $message") + } + } + }.apply { + level = HttpLoggingInterceptor.Level.BODY + } + + @Provides + @Singleton + @RetrofitQualifier.JWT + fun provideAuthInterceptor(authInterceptor: AuthInterceptor): Interceptor = authInterceptor + + @Provides + @Singleton + @RetrofitQualifier.JWT + fun provideJWTOkHttpClient( + loggingInterceptor: Interceptor, + @RetrofitQualifier.JWT authInterceptor: Interceptor, + ): OkHttpClient = + OkHttpClient.Builder() + .addInterceptor(loggingInterceptor) + .addInterceptor(authInterceptor) + .build() + + @Provides + @Singleton + @RetrofitQualifier.NOTOKEN + fun provideReissueOkHttpClient(loggingInterceptor: Interceptor): OkHttpClient = + OkHttpClient.Builder() + .addInterceptor(loggingInterceptor) + .build() + + @Provides + @Singleton + @RetrofitQualifier.JWT + fun provideJWTRetrofit( + @RetrofitQualifier.JWT client: OkHttpClient, + factory: Converter.Factory, + ): Retrofit = + Retrofit.Builder() + .baseUrl(BASE_URL) + .client(client) + .addConverterFactory(factory) + .build() + + @Provides + @Singleton + @RetrofitQualifier.NOTOKEN + fun provideReissueRetrofit( + @RetrofitQualifier.NOTOKEN client: OkHttpClient, + factory: Converter.Factory, + ): Retrofit = + Retrofit.Builder() + .baseUrl(BASE_URL) + .client(client) + .addConverterFactory(factory) + .build() +} diff --git a/app/src/main/java/co/orange/ddanzi/di/RetrofitQualifier.kt b/app/src/main/java/co/orange/ddanzi/di/RetrofitQualifier.kt new file mode 100644 index 00000000..b7fc3adc --- /dev/null +++ b/app/src/main/java/co/orange/ddanzi/di/RetrofitQualifier.kt @@ -0,0 +1,13 @@ +package co.orange.ddanzi.di + +import javax.inject.Qualifier + +object RetrofitQualifier { + @Qualifier + @Retention(AnnotationRetention.BINARY) + annotation class JWT + + @Qualifier + @Retention(AnnotationRetention.BINARY) + annotation class NOTOKEN +}