diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 00000000..dc03034f
--- /dev/null
+++ b/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/discord.xml b/.idea/discord.xml
new file mode 100644
index 00000000..30bab2ab
--- /dev/null
+++ b/.idea/discord.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/data/api/ApiService.kt b/app/src/main/java/co/kr/bemyplan/data/api/ApiService.kt
index 3131064e..8868d9c4 100644
--- a/app/src/main/java/co/kr/bemyplan/data/api/ApiService.kt
+++ b/app/src/main/java/co/kr/bemyplan/data/api/ApiService.kt
@@ -13,16 +13,16 @@ object ApiService {
.build()
// 인기 여행일정 조회
- val homePopularService: HomePopularService = retrofit.create(HomePopularService::class.java)
+ //val homePopularService: HomePopularService = retrofit.create(HomePopularService::class.java)
// 구매 후 포스트 조회
val afterPostService: AfterPostService = retrofit.create(AfterPostService::class.java)
// 최신 여행 일정 조회
- val homeNewService: HomeNewService = retrofit.create(HomeNewService::class.java)
+ //val homeNewService: HomeNewService = retrofit.create(HomeNewService::class.java)
// 에디터 추천 여행 일정 조회
- val homeSuggestService: HomeSuggestService = retrofit.create(HomeSuggestService::class.java)
+ //val homeSuggestService: HomeSuggestService = retrofit.create(HomeSuggestService::class.java)
// 회원 탈퇴
val withdrawService: WithdrawService = retrofit.create(WithdrawService::class.java)
diff --git a/app/src/main/java/co/kr/bemyplan/data/api/HomeNewService.kt b/app/src/main/java/co/kr/bemyplan/data/api/HomeNewService.kt
index a8e08cab..520915f3 100644
--- a/app/src/main/java/co/kr/bemyplan/data/api/HomeNewService.kt
+++ b/app/src/main/java/co/kr/bemyplan/data/api/HomeNewService.kt
@@ -5,6 +5,6 @@ import retrofit2.Call
import retrofit2.http.GET
interface HomeNewService {
- @GET("/api/v1/post/new")
- fun getNewData(): Call
+ @GET("/v1/plans?size=10&sort=createdAt,desc")
+ suspend fun getNewData() : ResponseHomeData
}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/data/api/HomePopularService.kt b/app/src/main/java/co/kr/bemyplan/data/api/HomePopularService.kt
index cdba4e5f..ccf2fa5c 100644
--- a/app/src/main/java/co/kr/bemyplan/data/api/HomePopularService.kt
+++ b/app/src/main/java/co/kr/bemyplan/data/api/HomePopularService.kt
@@ -1,10 +1,10 @@
package co.kr.bemyplan.data.api
-import co.kr.bemyplan.data.entity.main.home.ResponseHomePopularData
+import co.kr.bemyplan.data.entity.main.home.ResponseHomeData
import retrofit2.Call
import retrofit2.http.GET
interface HomePopularService {
- @GET("/api/v1/post/popular")
- fun getPopularData(): Call
+ @GET("/v1/plans?size=10&sort=orderCnt,desc")
+ suspend fun getPopularData(): ResponseHomeData
}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/data/api/HomeSuggestService.kt b/app/src/main/java/co/kr/bemyplan/data/api/HomeSuggestService.kt
index 3e9295ec..6ce2cffa 100644
--- a/app/src/main/java/co/kr/bemyplan/data/api/HomeSuggestService.kt
+++ b/app/src/main/java/co/kr/bemyplan/data/api/HomeSuggestService.kt
@@ -5,6 +5,6 @@ import retrofit2.Call
import retrofit2.http.GET
interface HomeSuggestService {
- @GET("/api/v1/post/suggest")
- fun getSuggestData(): Call
+ @GET("/v1/plans/bemyplanPick?size=5&sort=id,desc")
+ suspend fun getSuggestData(): ResponseHomeData
}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/data/entity/main/home/ResponseHomeData.kt b/app/src/main/java/co/kr/bemyplan/data/entity/main/home/ResponseHomeData.kt
index 1dba9190..33e5f2a9 100644
--- a/app/src/main/java/co/kr/bemyplan/data/entity/main/home/ResponseHomeData.kt
+++ b/app/src/main/java/co/kr/bemyplan/data/entity/main/home/ResponseHomeData.kt
@@ -1,26 +1,14 @@
package co.kr.bemyplan.data.entity.main.home
-import com.google.gson.annotations.SerializedName
+import co.kr.bemyplan.domain.model.main.home.HomeDomainData
data class ResponseHomeData(
val data: ResponseHomeItems,
- val totalPage : Int
+ val message : String,
+ val resultCode : String
){
data class ResponseHomeItems(
- val items: List
- ){
- data class HomeData(
- @SerializedName("post_id")
- val postId: Int,
- val title: String,
- val author : String,
- @SerializedName("thumbnail_url")
- val thumbnailUrl: String,
- val price: Int,
- @SerializedName("is_purchased")
- val isPurchased : Boolean,
- @SerializedName("is_scraped")
- val isScraped : Boolean
- )
- }
+ val contents : List,
+ val nextCursor : Int
+ )
}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/data/entity/main/home/ResponseHomePopularData.kt b/app/src/main/java/co/kr/bemyplan/data/entity/main/home/ResponseHomePopularData.kt
deleted file mode 100644
index 54752687..00000000
--- a/app/src/main/java/co/kr/bemyplan/data/entity/main/home/ResponseHomePopularData.kt
+++ /dev/null
@@ -1,19 +0,0 @@
-package co.kr.bemyplan.data.entity.main.home
-
-import com.google.gson.annotations.SerializedName
-
-data class ResponseHomePopularData(
- val data : List
-){
- data class Data(
- @SerializedName("post_id")
- val postId : Int,
- val title : String,
- val author : String,
- val price : Int,
- @SerializedName("thumbnail_url")
- val thumbnailUrl : String,
- @SerializedName("is_purchased")
- val isPurchased : Boolean
- )
-}
diff --git a/app/src/main/java/co/kr/bemyplan/data/repository/main/home/HomeNewRepositoryImpl.kt b/app/src/main/java/co/kr/bemyplan/data/repository/main/home/HomeNewRepositoryImpl.kt
new file mode 100644
index 00000000..851f88c1
--- /dev/null
+++ b/app/src/main/java/co/kr/bemyplan/data/repository/main/home/HomeNewRepositoryImpl.kt
@@ -0,0 +1,19 @@
+package co.kr.bemyplan.data.repository.main.home
+
+import co.kr.bemyplan.data.api.HomeNewService
+import co.kr.bemyplan.domain.model.main.home.HomeDomainData
+import co.kr.bemyplan.domain.repository.HomeNewRepository
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.withContext
+import javax.inject.Inject
+
+class HomeNewRepositoryImpl @Inject constructor(
+ private val homeNewService : HomeNewService,
+ private val coroutineDispatcher: CoroutineDispatcher
+) : HomeNewRepository {
+ override suspend fun getHomeNewData(): List {
+ return withContext(coroutineDispatcher){
+ homeNewService.getNewData().data.contents
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/data/repository/main/home/HomePopularRepositoryImpl.kt b/app/src/main/java/co/kr/bemyplan/data/repository/main/home/HomePopularRepositoryImpl.kt
new file mode 100644
index 00000000..5677b9cf
--- /dev/null
+++ b/app/src/main/java/co/kr/bemyplan/data/repository/main/home/HomePopularRepositoryImpl.kt
@@ -0,0 +1,19 @@
+package co.kr.bemyplan.data.repository.main.home
+
+import co.kr.bemyplan.data.api.HomePopularService
+import co.kr.bemyplan.domain.model.main.home.HomeDomainData
+import co.kr.bemyplan.domain.repository.HomePopularRepository
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.withContext
+import javax.inject.Inject
+
+class HomePopularRepositoryImpl @Inject constructor(
+ private val homePopularService: HomePopularService,
+ private val coroutineDispatcher: CoroutineDispatcher
+) : HomePopularRepository {
+ override suspend fun getHomePopularData(): List {
+ return withContext(coroutineDispatcher){
+ homePopularService.getPopularData().data.contents
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/data/repository/main/home/HomeSuggestRepositoryImpl.kt b/app/src/main/java/co/kr/bemyplan/data/repository/main/home/HomeSuggestRepositoryImpl.kt
new file mode 100644
index 00000000..6d4b7913
--- /dev/null
+++ b/app/src/main/java/co/kr/bemyplan/data/repository/main/home/HomeSuggestRepositoryImpl.kt
@@ -0,0 +1,19 @@
+package co.kr.bemyplan.data.repository.main.home
+
+import co.kr.bemyplan.data.api.HomeSuggestService
+import co.kr.bemyplan.domain.model.main.home.HomeDomainData
+import co.kr.bemyplan.domain.repository.HomeSuggestRepository
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.withContext
+import javax.inject.Inject
+
+class HomeSuggestRepositoryImpl @Inject constructor(
+ private val homeSuggestService: HomeSuggestService,
+ private val coroutineDispatcher: CoroutineDispatcher
+) : HomeSuggestRepository {
+ override suspend fun getHomeSuggestData(): List {
+ return withContext(coroutineDispatcher){
+ homeSuggestService.getSuggestData().data.contents
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/data/repository/main/location/LocationRepositoryImpl.kt b/app/src/main/java/co/kr/bemyplan/data/repository/main/location/LocationRepositoryImpl.kt
index fc9fcd31..9baf4158 100644
--- a/app/src/main/java/co/kr/bemyplan/data/repository/main/location/LocationRepositoryImpl.kt
+++ b/app/src/main/java/co/kr/bemyplan/data/repository/main/location/LocationRepositoryImpl.kt
@@ -16,5 +16,4 @@ class LocationRepositoryImpl @Inject constructor(
locationservice.getLocation().data
}
}
-
}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/di/RepositoryModule.kt b/app/src/main/java/co/kr/bemyplan/di/RepositoryModule.kt
index 2a94bbac..a6217f99 100644
--- a/app/src/main/java/co/kr/bemyplan/di/RepositoryModule.kt
+++ b/app/src/main/java/co/kr/bemyplan/di/RepositoryModule.kt
@@ -7,6 +7,9 @@ import co.kr.bemyplan.data.repository.list.SuggestListRepositoryImpl
import co.kr.bemyplan.data.repository.list.UserPostListRepositoryImpl
import co.kr.bemyplan.data.repository.login.GoogleLoginRepositoryImpl
import co.kr.bemyplan.data.repository.login.LoginRepositoryImpl
+import co.kr.bemyplan.data.repository.main.home.HomeNewRepositoryImpl
+import co.kr.bemyplan.data.repository.main.home.HomePopularRepositoryImpl
+import co.kr.bemyplan.data.repository.main.home.HomeSuggestRepositoryImpl
import co.kr.bemyplan.data.repository.main.location.LocationRepositoryImpl
import co.kr.bemyplan.data.repository.main.myplan.MyPlanRepository
import co.kr.bemyplan.data.repository.main.myplan.MyPlanRepositoryImpl
@@ -142,6 +145,36 @@ object RepositoryModule {
@IoDispatcher coroutineDispatcher: CoroutineDispatcher
): PurchaseRepository = PurchaseRepositoryImpl(purchaseService, coroutineDispatcher)
+ //홈뷰 인기 일정
+ @ViewModelScoped
+ @Provides
+ fun provideHomePopularRepository(
+ homePopularService: HomePopularService,
+ @IoDispatcher coroutineDispatcher: CoroutineDispatcher
+ ) : HomePopularRepository{
+ return HomePopularRepositoryImpl(homePopularService, coroutineDispatcher)
+ }
+
+ //홈뷰 최신 일정
+ @ViewModelScoped
+ @Provides
+ fun provideHomeNewRepository(
+ homeNewService: HomeNewService,
+ @IoDispatcher coroutineDispatcher: CoroutineDispatcher
+ ) : HomeNewRepository{
+ return HomeNewRepositoryImpl(homeNewService, coroutineDispatcher)
+ }
+
+ //홈뷰 추천 일정
+ @ViewModelScoped
+ @Provides
+ fun provideHomeSuggestRepository(
+ homeSuggestService: HomeSuggestService,
+ @IoDispatcher coroutineDispatcher: CoroutineDispatcher
+ ) : HomeSuggestRepository{
+ return HomeSuggestRepositoryImpl(homeSuggestService, coroutineDispatcher)
+ }
+
// ?? 뭐지 왜 없는데 됐었지...?
// @ViewModelScoped
// @Provides
diff --git a/app/src/main/java/co/kr/bemyplan/di/ServiceModule.kt b/app/src/main/java/co/kr/bemyplan/di/ServiceModule.kt
index 63515170..e0572c67 100644
--- a/app/src/main/java/co/kr/bemyplan/di/ServiceModule.kt
+++ b/app/src/main/java/co/kr/bemyplan/di/ServiceModule.kt
@@ -99,4 +99,25 @@ object ServiceModule {
fun providePurchaseService(@BeMyPlanRetrofit retrofit: Retrofit): PurchaseService {
return retrofit.create(PurchaseService::class.java)
}
+
+ //홈뷰 인기 일정
+ @Singleton
+ @Provides
+ fun provideHomePopularService(@BeMyPlanRetrofit retrofit: Retrofit):HomePopularService{
+ return retrofit.create(HomePopularService::class.java)
+ }
+
+ //홈뷰 최신 일정
+ @Singleton
+ @Provides
+ fun provideHomeNewService(@BeMyPlanRetrofit retrofit: Retrofit):HomeNewService{
+ return retrofit.create(HomeNewService::class.java)
+ }
+
+ //홈뷰 추천 일정
+ @Singleton
+ @Provides
+ fun provideHomeSuggestService(@BeMyPlanRetrofit retrofit: Retrofit):HomeSuggestService{
+ return retrofit.create(HomeSuggestService::class.java)
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/domain/model/main/home/HomeDomainData.kt b/app/src/main/java/co/kr/bemyplan/domain/model/main/home/HomeDomainData.kt
new file mode 100644
index 00000000..07712b2e
--- /dev/null
+++ b/app/src/main/java/co/kr/bemyplan/domain/model/main/home/HomeDomainData.kt
@@ -0,0 +1,17 @@
+package co.kr.bemyplan.domain.model.main.home
+
+data class HomeDomainData(
+ val createdAt : String,
+ val orderStatus : Boolean,
+ val planId: Int,
+ val scrapStatus : Boolean,
+ val thumbnailUrl: String,
+ val title: String,
+ val updatedAt : String,
+ val user : UserData,
+){
+ data class UserData(
+ val nickname : String,
+ val userId : Int
+ )
+}
diff --git a/app/src/main/java/co/kr/bemyplan/domain/repository/HomeNewRepository.kt b/app/src/main/java/co/kr/bemyplan/domain/repository/HomeNewRepository.kt
new file mode 100644
index 00000000..f3c3e54e
--- /dev/null
+++ b/app/src/main/java/co/kr/bemyplan/domain/repository/HomeNewRepository.kt
@@ -0,0 +1,7 @@
+package co.kr.bemyplan.domain.repository
+
+import co.kr.bemyplan.domain.model.main.home.HomeDomainData
+
+interface HomeNewRepository {
+ suspend fun getHomeNewData():List
+}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/domain/repository/HomePopularRepository.kt b/app/src/main/java/co/kr/bemyplan/domain/repository/HomePopularRepository.kt
new file mode 100644
index 00000000..ab95ffb0
--- /dev/null
+++ b/app/src/main/java/co/kr/bemyplan/domain/repository/HomePopularRepository.kt
@@ -0,0 +1,7 @@
+package co.kr.bemyplan.domain.repository
+
+import co.kr.bemyplan.domain.model.main.home.HomeDomainData
+
+interface HomePopularRepository {
+ suspend fun getHomePopularData():List
+}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/domain/repository/HomeSuggestRepository.kt b/app/src/main/java/co/kr/bemyplan/domain/repository/HomeSuggestRepository.kt
new file mode 100644
index 00000000..0c3a9134
--- /dev/null
+++ b/app/src/main/java/co/kr/bemyplan/domain/repository/HomeSuggestRepository.kt
@@ -0,0 +1,7 @@
+package co.kr.bemyplan.domain.repository
+
+import co.kr.bemyplan.domain.model.main.home.HomeDomainData
+
+interface HomeSuggestRepository {
+ suspend fun getHomeSuggestData():List
+}
\ No newline at end of file
diff --git a/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeAdapter.kt b/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeAdapter.kt
index db14bcf0..d34a7680 100644
--- a/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeAdapter.kt
+++ b/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeAdapter.kt
@@ -4,29 +4,29 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
-import co.kr.bemyplan.data.entity.main.home.ResponseHomeData
import co.kr.bemyplan.databinding.ItemHomePlanBinding
+import co.kr.bemyplan.domain.model.main.home.HomeDomainData
import co.kr.bemyplan.util.clipTo
class HomeAdapter(
val beforePurchase: (Int, Boolean) -> Unit,
val afterPurchase: (Int) -> Unit) : RecyclerView.Adapter() {
- val planList = mutableListOf()
+ val planList = mutableListOf()
inner class HomeViewHolder(private val binding: ItemHomePlanBinding):RecyclerView.ViewHolder(binding.root){
- fun onBind(data: ResponseHomeData.ResponseHomeItems.HomeData){
+ fun onBind(data: HomeDomainData){
binding.homeItem = data
clipTo(binding.ivHomeCommon, data.thumbnailUrl)
clickItem(data)
}
- private fun clickItem(data: ResponseHomeData.ResponseHomeItems.HomeData) {
+ private fun clickItem(data: HomeDomainData) {
binding.root.setOnClickListener {
- if (data.isPurchased == true) {
- afterPurchase(data.postId)
+ if (data.orderStatus == true) {
+ afterPurchase(data.planId)
} else {
- beforePurchase(data.postId, data.isScraped)
+ beforePurchase(data.planId, data.scrapStatus)
}
}
}
diff --git a/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeFragment.kt b/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeFragment.kt
index dc18c315..b3d48f88 100644
--- a/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeFragment.kt
+++ b/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeFragment.kt
@@ -17,7 +17,9 @@ import co.kr.bemyplan.ui.purchase.after.AfterPurchaseActivity
import co.kr.bemyplan.ui.purchase.before.PurchaseActivity
import co.kr.bemyplan.util.ZoomOutPageTransformer
import com.github.rubensousa.gravitysnaphelper.GravitySnapHelper
+import dagger.hilt.android.AndroidEntryPoint
+@AndroidEntryPoint
class HomeFragment : Fragment() {
private lateinit var homeViewPagerAdapter: HomeViewPagerAdapter
@@ -33,8 +35,8 @@ class HomeFragment : Fragment() {
savedInstanceState: Bundle?
): View? {
_binding = FragmentHomeBinding.inflate(layoutInflater)
- initAdapterRecent()
- initAdapterEditor()
+ initAdapterNew()
+ initAdapterSuggest()
initAdapterPopular()
clickMore()
return binding.root
@@ -56,8 +58,8 @@ class HomeFragment : Fragment() {
super.onDestroyView()
}
- private fun initAdapterRecent() {
- homeViewModel.initNewNetwork()
+ private fun initAdapterNew() {
+ homeViewModel.getNewData()
recentAdapter = HomeAdapter(beforePurchase = { id: Int, scraped : Boolean ->
val intent = Intent(requireContext(), PurchaseActivity::class.java)
@@ -83,8 +85,8 @@ class HomeFragment : Fragment() {
recentAdapter.notifyDataSetChanged()
}
- private fun initAdapterEditor() {
- homeViewModel.initSuggestNetwork()
+ private fun initAdapterSuggest() {
+ homeViewModel.getSuggestData()
editorAdapter = HomeAdapter(beforePurchase = { id: Int, scraped : Boolean ->
val intent = Intent(requireContext(), PurchaseActivity::class.java)
@@ -107,7 +109,7 @@ class HomeFragment : Fragment() {
}
private fun initAdapterPopular() {
- homeViewModel.initPopularNetwork()
+ homeViewModel.getPopularData()
homeViewPagerAdapter = HomeViewPagerAdapter(beforePurchase = { id: Int, scraped : Boolean ->
val intent = Intent(requireContext(), PurchaseActivity::class.java)
diff --git a/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeViewModel.kt b/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeViewModel.kt
index 0c0ba57f..f7895532 100644
--- a/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeViewModel.kt
+++ b/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeViewModel.kt
@@ -5,22 +5,75 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import retrofit2.Call
import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
import co.kr.bemyplan.data.api.ApiService
import co.kr.bemyplan.data.entity.main.home.ResponseHomeData
-import co.kr.bemyplan.data.entity.main.home.ResponseHomePopularData
+import co.kr.bemyplan.domain.model.main.home.HomeDomainData
+import co.kr.bemyplan.domain.repository.HomeNewRepository
+import co.kr.bemyplan.domain.repository.HomePopularRepository
+import co.kr.bemyplan.domain.repository.HomeSuggestRepository
+import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.launch
import retrofit2.Callback
import retrofit2.Response
+import javax.inject.Inject
-class HomeViewModel: ViewModel() {
+@HiltViewModel
+class HomeViewModel @Inject constructor(
+ private val homePopularRepository: HomePopularRepository,
+ private val homeNewRepository: HomeNewRepository,
+ private val homeSuggestRepository: HomeSuggestRepository
+) : ViewModel() {
- private val _popular = MutableLiveData>()
- val popular : LiveData> get() = _popular
- private val _new = MutableLiveData>()
- val new : LiveData> get() = _new
- private val _suggest = MutableLiveData>()
- val suggest : LiveData> get() = _suggest
+ private val _popular = MutableLiveData>()
+ val popular : LiveData> get() = _popular
+ private val _new = MutableLiveData>()
+ val new : LiveData> get() = _new
+ private val _suggest = MutableLiveData>()
+ val suggest : LiveData> get() = _suggest
- fun initSuggestNetwork(){
+ fun getPopularData(){
+ viewModelScope.launch {
+ kotlin.runCatching {
+ homePopularRepository.getHomePopularData()
+ }.onSuccess { responsePopularData->
+ if(_popular.value != responsePopularData)
+ _popular.value = responsePopularData
+ }.onFailure { error ->
+ Log.d("ServerPopular", error.toString())
+ }
+ }
+ }
+
+ fun getNewData(){
+ viewModelScope.launch {
+ kotlin.runCatching {
+ homeNewRepository.getHomeNewData()
+ }.onSuccess { responseNewData->
+ if(_new.value != responseNewData)
+ _new.value = responseNewData
+ }.onFailure { error ->
+ Log.d("ServerNew", error.toString())
+ }
+ }
+ }
+
+ fun getSuggestData(){
+ viewModelScope.launch {
+ kotlin.runCatching {
+ homeSuggestRepository.getHomeSuggestData()
+ }.onSuccess { responseSuggestData->
+ if(_suggest.value != responseSuggestData)
+ _suggest.value = responseSuggestData
+ }.onFailure { error ->
+ Log.d("ServerSuggest", error.toString())
+ }
+ }
+ }
+
+
+
+ /*fun initSuggestNetwork(){
val call : Call = ApiService.homeSuggestService.getSuggestData()
call.enqueue(object:Callback{
override fun onResponse(
@@ -30,8 +83,8 @@ class HomeViewModel: ViewModel() {
if(response.isSuccessful){
val data = response.body()
if(data!=null){
- if(_suggest.value!=data.data.items)
- _suggest.value=data.data.items
+ if(_suggest.value!=data.data.contents)
+ _suggest.value=data.data.contents
Log.d("yongminSuggestServer", "추천일정서버통신성공!")
}else{Log.d("yongminSuggestServer", "추천일정서버통신실패1")}
}else{Log.d("yongminSuggestServer", "추천일정서버통신실패2")}
@@ -53,8 +106,8 @@ class HomeViewModel: ViewModel() {
if(response.isSuccessful){
val data = response.body()
if(data!=null){
- if(_new.value!=data.data.items)
- _new.value=data.data.items
+ if(_new.value!=data.data.contents)
+ _new.value=data.data.contents
Log.d("yongminNewServer", "최신일정서버통신성공!")
}else{Log.d("yongminNewServer", "최신일정서버통신실패1")}
}else{Log.d("yongminNewServer", "최신일정서버통신실패2")}
@@ -88,6 +141,6 @@ class HomeViewModel: ViewModel() {
Log.d("yongminServer", "서버통신실패3")
}
})
- }
+ }*/
}
diff --git a/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeViewPagerAdapter.kt b/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeViewPagerAdapter.kt
index 1fe8bbe8..cb045cd9 100644
--- a/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeViewPagerAdapter.kt
+++ b/app/src/main/java/co/kr/bemyplan/ui/main/home/HomeViewPagerAdapter.kt
@@ -1,15 +1,13 @@
package co.kr.bemyplan.ui.main.home
-import android.content.Intent
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import co.kr.bemyplan.R
-import co.kr.bemyplan.data.entity.main.home.ResponseHomePopularData
import co.kr.bemyplan.databinding.ItemPopularBinding
-import co.kr.bemyplan.ui.purchase.after.AfterPurchaseActivity
+import co.kr.bemyplan.domain.model.main.home.HomeDomainData
import co.kr.bemyplan.util.clipTo
class HomeViewPagerAdapter(
@@ -18,11 +16,11 @@ class HomeViewPagerAdapter(
) :
RecyclerView.Adapter() {
- val planList = mutableListOf()
+ val planList = mutableListOf()
inner class PagerViewHolder(private val binding: ItemPopularBinding) :
RecyclerView.ViewHolder(binding.root) {
- fun onBind(data: ResponseHomePopularData.Data) {
+ fun onBind(data: HomeDomainData) {
binding.popularityItem = data
Log.d("yongminPopularImage", "잘 들어오나")
@@ -31,12 +29,12 @@ class HomeViewPagerAdapter(
clickItem(data)
}
- private fun clickItem(data: ResponseHomePopularData.Data) {
+ private fun clickItem(data: HomeDomainData) {
binding.root.setOnClickListener {
- if (data.isPurchased == true) {
- afterPurchase(data.postId)
+ if (data.orderStatus == true) {
+ afterPurchase(data.planId)
} else {
- beforePurchase(data.postId, data.isPurchased)
+ beforePurchase(data.planId, data.orderStatus)
}
}
}
diff --git a/app/src/main/res/layout/item_home_plan.xml b/app/src/main/res/layout/item_home_plan.xml
index 22653906..c5efdfc6 100644
--- a/app/src/main/res/layout/item_home_plan.xml
+++ b/app/src/main/res/layout/item_home_plan.xml
@@ -5,7 +5,7 @@
+ type="co.kr.bemyplan.domain.model.main.home.HomeDomainData" />
+ type="co.kr.bemyplan.domain.model.main.home.HomeDomainData" />