diff --git a/app/src/main/java/com/sopt/carrot/presentation/home/.gitkeep b/app/src/main/java/com/sopt/carrot/presentation/home/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/src/main/java/com/sopt/carrot/presentation/home/FullJobAdapter.kt b/app/src/main/java/com/sopt/carrot/presentation/home/FullJobAdapter.kt index 41b51ef..a2699ea 100644 --- a/app/src/main/java/com/sopt/carrot/presentation/home/FullJobAdapter.kt +++ b/app/src/main/java/com/sopt/carrot/presentation/home/FullJobAdapter.kt @@ -6,6 +6,7 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide +import com.sopt.carrot.R import com.sopt.carrot.data.home.ResponseFullListDto import com.sopt.carrot.databinding.ItemHomeFullJobBinding @@ -18,7 +19,8 @@ class FullJobAdapter(state: Int) : fun onBind(data: ResponseFullListDto.Detail.Post) { with(binding) { - Glide.with(root).load(data.image).into(ivItemHomeFullJobImg) + //사진이 로딩 중 이면 test1 사진 로딩 에러면 test2 + Glide.with(root).load(data.image).placeholder(R.drawable.img_test_1).error(R.drawable.img_test_2).into(ivItemHomeFullJobImg) tvItemHomeFullJobTitle.text = data.title tvItemHomeFullJobTitle.text = data.title tvItemHomeFullJobSalary.text = "시급 " + data.hourlyWage.toString() + "만원" @@ -52,9 +54,9 @@ class FullJobAdapter(state: Int) : override fun getItemCount(): Int { return if (recyclerViewDivision == 1) { - 3 + 3 //알바 필터 리스트는 아이템 3개만 } else { - super.getItemCount() + super.getItemCount() //알바 전체 리스트는 데이터 받은거 모두 } } diff --git a/app/src/main/java/com/sopt/carrot/presentation/home/HomeActivity.kt b/app/src/main/java/com/sopt/carrot/presentation/home/HomeActivity.kt index a9987f2..7c578c6 100644 --- a/app/src/main/java/com/sopt/carrot/presentation/home/HomeActivity.kt +++ b/app/src/main/java/com/sopt/carrot/presentation/home/HomeActivity.kt @@ -20,23 +20,25 @@ class HomeActivity : AppCompatActivity() { super.onCreate(savedInstanceState) binding = ActivityHomeBinding.inflate(layoutInflater) setContentView(binding.root) - observeRecommend() - observeSelect() - observeFull() + setRecommendView() + setSelectView() + setFullView() setTodayPopularityJobAdapter() pressShuffleButton() } - private fun observeRecommend() { + //알바 추천 리스트 조회 서버 통신 함수 + private fun setRecommendView() { viewModelRecommended.getRecommendedJob( jobDataCount, binding.rvHomeRecommend, message = { str -> toast(str) }) } - private fun observeSelect() { + //알바 리스트 조회 서버 통신 함수(3개만 뽑아서) + private fun setSelectView() { viewModelList.getFullJob( jobDataCount, binding.rvHomeSelectList, message = { str -> toast(str) }, 1 @@ -44,7 +46,8 @@ class HomeActivity : AppCompatActivity() { } - private fun observeFull() { + //알바 리스트 조회 서버 통신 함수(전체) + private fun setFullView() { viewModelList.getFullJob( jobDataCount, binding.rvHomeFull, message = { str -> toast(str) }, 2 @@ -53,6 +56,7 @@ class HomeActivity : AppCompatActivity() { } + //오늘의 인기 알바 리사이클러뷰 어댑터 연결 함수 private fun setTodayPopularityJobAdapter() { adapter = TodayPopularityJobAdapter() binding.rvHomeTodayPopularity.adapter = adapter @@ -60,6 +64,7 @@ class HomeActivity : AppCompatActivity() { } + //알바 추천 리스트 셔플 함수 private fun pressShuffleButton() { binding.btnHomeShuffle.setOnClickListener { viewModelRecommended.shuffleRecommendedJob( diff --git a/app/src/main/java/com/sopt/carrot/presentation/home/RecommendedJobAdapter.kt b/app/src/main/java/com/sopt/carrot/presentation/home/RecommendedJobAdapter.kt index ded3d36..a4ced5a 100644 --- a/app/src/main/java/com/sopt/carrot/presentation/home/RecommendedJobAdapter.kt +++ b/app/src/main/java/com/sopt/carrot/presentation/home/RecommendedJobAdapter.kt @@ -6,6 +6,7 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide +import com.sopt.carrot.R import com.sopt.carrot.data.home.ResponseRecommendDto import com.sopt.carrot.databinding.ItemHomeRecommendedJobBinding @@ -19,8 +20,11 @@ class RecommendedJobAdapter() : RecyclerView.ViewHolder(binding.root) { fun onBind(data: ResponseRecommendDto.Detail.Post) { + with(binding) { - Glide.with(root).load(data.image).into(ivItemHomeRecommendedJobImg) + //사진이 로딩 중 이면 test1 사진 로딩 에러면 test2 + Glide.with(root).load(data.image).placeholder(R.drawable.img_test_1) + .error(R.drawable.img_test_2).into(ivItemHomeRecommendedJobImg) tvItemHomeRecommendedJobTitle.text = data.title tvItemHomeRecommendedJobSalary.text = "월급 " + data.monthlyWage.toString() + "만원" } @@ -49,9 +53,12 @@ class RecommendedJobAdapter() : } } - override fun getItemCount(): Int = 4 + override fun getItemCount(): Int = 4 //추천 알바 리스트는 아이템 4개만 - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecommendedJobAdapterViewHolder { + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int + ): RecommendedJobAdapterViewHolder { val binding = ItemHomeRecommendedJobBinding.inflate( LayoutInflater.from(parent.context), parent, diff --git a/app/src/main/java/com/sopt/carrot/presentation/home/RecommendedViewModel.kt b/app/src/main/java/com/sopt/carrot/presentation/home/RecommendedViewModel.kt index 16a15f6..f9b1266 100644 --- a/app/src/main/java/com/sopt/carrot/presentation/home/RecommendedViewModel.kt +++ b/app/src/main/java/com/sopt/carrot/presentation/home/RecommendedViewModel.kt @@ -30,6 +30,7 @@ class RecommendedViewModel : ViewModel() { } + //데이터 섞어서 불러오기(셔플) fun shuffleRecommendedJob(size: Long, recyclerView: RecyclerView, message: (String) -> Unit) { ApiPool.recommendService.getRecommendJobList(1, size).enqueueUtil( onSuccess = {