Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#32 #36

Merged
merged 9 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data class GuideResponse(
val id : String,
val title : String,
val subTitle : String,
val contents : String,
val images : List<String>,
val tumbNail : String
val content : String,
//val images : List<String>,
//val thumbnail : String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.appzam.nobar_android.data.remote.response

data class IngredientResponse(
//val id : String,
val name : String,
val enName : String,
/*val proof : Int,
val category : String*/
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package org.sopt.appzam.nobar_android.data.remote.response
data class NobarRecipeResponse(
val id : String,
val title : String,
val recipe : String
val recipe : String,
val color : Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import org.sopt.appzam.nobar_android.data.remote.response.common.IngredientDetai
import org.sopt.appzam.nobar_android.data.remote.response.common.SkillModel

data class RecipeResponse(
val id : String,
//val id : String,
val name : String,
/*val enName : String,
val version : List<String>,
val enName : String,
val base : BaseModel,
val proof : Int,
val skill : SkillModel,
val glass : GlassModel,
val ingredients : List<IngredientDetailModel>,
val steps : List<String>,
val defaultRecipe : String,
val proofIcon : String*/
//val ingredients : List<IngredientDetailModel>,
//val steps : List<String>,
//val defaultRecipe : String?,
//val proofIcon : String
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.sopt.appzam.nobar_android.data.remote.response

import org.sopt.appzam.nobar_android.data.remote.response.common.IngredientResponse
import org.sopt.appzam.nobar_android.data.remote.response.common.RecommendModel

data class SearchKeywordsResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package org.sopt.appzam.nobar_android.data.remote.response.common
data class BaseModel(
val id : String,
val name : String,
val url : String
//val url : String
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.sopt.appzam.nobar_android.data.remote.response.GuideResponse
import org.sopt.appzam.nobar_android.databinding.ItemHomeGuideBinding

class GuideAdapter : ListAdapter<GuideResponse, GuideAdapter.GuideViewHolder>(guideDiffUtil) {
private val guideList = mutableListOf<GuideResponse>()

class GuideViewHolder(private val binding: ItemHomeGuideBinding) :
RecyclerView.ViewHolder(binding.root) {
Expand All @@ -25,7 +24,7 @@ class GuideAdapter : ListAdapter<GuideResponse, GuideAdapter.GuideViewHolder>(gu
}

override fun onBindViewHolder(holder: GuideViewHolder, position: Int) {
holder.onBind(guideList[position])
holder.onBind(getItem(position))
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@ import androidx.core.content.ContextCompat
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.viewModels
import org.sopt.appzam.nobar_android.R
import org.sopt.appzam.nobar_android.data.remote.response.GuideResponse
import org.sopt.appzam.nobar_android.data.remote.response.NobarRecipeResponse
import org.sopt.appzam.nobar_android.data.remote.response.RecipeResponse
import org.sopt.appzam.nobar_android.data.remote.response.common.BaseModel
import org.sopt.appzam.nobar_android.data.remote.response.common.GlassModel
import org.sopt.appzam.nobar_android.data.remote.response.common.SkillModel
import org.sopt.appzam.nobar_android.databinding.FragmentHomeBinding
import org.sopt.appzam.nobar_android.presentation.base.BaseFragment
import org.sopt.appzam.nobar_android.presentation.main.mypage.adapter.MyLaterRecipeAdapter
import org.sopt.appzam.nobar_android.util.ItemDecoration
import kotlin.random.Random

class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
private lateinit var nobarRecipeAdapter: NobarRecipeAdapter
private lateinit var guideAdapter : GuideAdapter
private lateinit var laterRecipeAdapter: LaterRecipeAdapter
private val homeViewModel by viewModels<HomeViewModel>()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
Expand All @@ -35,33 +43,59 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.recyclerToDoRecipe.addItemDecoration(
/*binding.recyclerToDoRecipe.addItemDecoration(
ItemDecoration(
R.dimen.margin8,
R.dimen.margin8,
R.dimen.margin4,
R.dimen.margin9,
2
)
)
)*/

laterAdapter()
initAdapter()
guideAdapter()
scrollChange()
}


private fun onRefresh() {
binding.layoutRefresh.setOnRefreshListener {
Handler(Looper.getMainLooper()).postDelayed({
binding.layoutMain.setBackgroundColor(
ContextCompat.getColor(
context!!,
R.color.black
)
)
laterAdapter()
guideAdapter()
initAdapter()
binding.layoutRefresh.isRefreshing = false
}, 1000)
}
}

private fun laterAdapter(){
val laterRecipeList = listOf(
RecipeResponse("dd안d","ssso",BaseModel("dkd","s"),1,SkillModel("d","sd"), GlassModel("dsa","s")),
RecipeResponse("안sd","sos",BaseModel("dkd","s"),1,SkillModel("d","sd"), GlassModel("dsa","s")),
RecipeResponse("sd안","sdso",BaseModel("dkd","s"),1,SkillModel("d","sd"), GlassModel("dsa","s")),
RecipeResponse("안df","sddo",BaseModel("dkd","s"),1,SkillModel("d","sd"), GlassModel("dsa","s"))
)
laterRecipeAdapter = LaterRecipeAdapter()
binding.recyclerToDoRecipe.adapter = laterRecipeAdapter
laterRecipeAdapter.submitList(laterRecipeList)
}

private fun guideAdapter(){
//home - guide
val guideList = listOf(
GuideResponse("1","3we","sdf","칵테일 좀 마셔봤니? 칵테일 용어 정복하기"),
GuideResponse("1","3we","sdf","어떤 잔에 마셔야 더 간지나는 홈텐딩이 될까?"),
GuideResponse("1","3we","sdf","칵테일 좀 마셔봤니? 칵테일 용어 정복하기"),
GuideResponse("1","3we","sdf","칵테일 좀 마셔봤니? 칵테일 용어 정복하기"),
GuideResponse("1","3we","sdf","어떤 잔에 마셔야 더 간지나는 홈텐딩이 될까?")
)

guideAdapter = GuideAdapter()
binding.recyclerGuide.adapter = guideAdapter
guideAdapter.submitList(guideList)

}
private fun initAdapter() {
val randomIntList = mutableListOf<Int>()
randomIntList.clear()
Expand All @@ -76,11 +110,11 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
}

var nobarRecipeList = listOf(
NobarRecipeResponse("1213", "블루하와이 마셔봤니? 편의점에서 간편하게 재료 겟!", "sdjfkds"),
NobarRecipeResponse("122", "디자이너를 힘들게 하는 긴 이름 스트로베리 레몬 그라스 어쩌구", "sd22jfkds"),
NobarRecipeResponse("1121", "연인과 함께 마셔봐 섹시 마일드", "안녕하세요"),
NobarRecipeResponse("11", "집에 남은 소주 어떻게 하려고? 그래서 준비했어 소주 라떼", "s하앙른일s"),
NobarRecipeResponse("111", "모히또에서 몰디브 한 잔 에서 그 모히또", "sdjfkdsㅁㄴㄹㄴㅇㅁㄹㄴ")
NobarRecipeResponse("1213", "블루하와이 마셔봤니? 편의점에서 간편하게 재료 겟!", "sdjfkds", 0),
NobarRecipeResponse("122", "디자이너를 힘들게 하는 긴 이름 스트로베리 레몬 그라스 어쩌구", "sd22jfkds", 1),
NobarRecipeResponse("1121", "연인과 함께 마셔봐 섹시 마일드", "안녕하세요", 2),
NobarRecipeResponse("11", "집에 남은 소주 어떻게 하려고? 그래서 준비했어 소주 라떼", "s하앙른일s", 3),
NobarRecipeResponse("111", "모히또에서 몰디브 한 잔에서 그 모히또", "sdjfkdsㅁㄴㄹㄴㅇㅁㄹㄴ", 4)
)
nobarRecipeAdapter = NobarRecipeAdapter(randomIntList)
binding.recyclerNobarRecipe.adapter = nobarRecipeAdapter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
package org.sopt.appzam.nobar_android.presentation.main.home

import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import org.sopt.appzam.nobar_android.data.remote.response.IngredientResponse
import org.sopt.appzam.nobar_android.data.remote.response.RecipeResponse
import org.sopt.appzam.nobar_android.databinding.ItemHomeLaterRecipeBinding
import org.sopt.appzam.nobar_android.databinding.ItemSearchResultBinding

class LaterRecipeAdapter :
ListAdapter<RecipeResponse, LaterRecipeAdapter.LaterRecipeViewHolder>(LaterRecipeComparator()) {
private val laterRecipeList = mutableListOf<RecipeResponse>()

class LaterRecipeViewHolder(private val binding: ItemHomeLaterRecipeBinding) :
class LaterRecipeViewHolder(private val binding: ItemSearchResultBinding) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(data: RecipeResponse) {
binding.laterRecipeItem = data
binding.searchResultItem = data
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LaterRecipeViewHolder {
val binding =
ItemHomeLaterRecipeBinding.inflate(LayoutInflater.from(parent.context), parent, false)
ItemSearchResultBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return LaterRecipeViewHolder(binding)
}

override fun onBindViewHolder(holder: LaterRecipeViewHolder, position: Int) {
holder.onBind(laterRecipeList[position])
Log.d("sflksdj",position.toString())
holder.onBind(getItem(position))
}


class LaterRecipeComparator : DiffUtil.ItemCallback<RecipeResponse>() {
override fun areItemsTheSame(
oldItem: RecipeResponse,
newItem: RecipeResponse
): Boolean =
oldItem == newItem
oldItem.name == newItem.name

override fun areContentsTheSame(
oldItem: RecipeResponse,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.sopt.appzam.nobar_android.presentation.main.home

import android.content.Context
import android.content.res.ColorStateList
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
Expand Down Expand Up @@ -39,6 +37,7 @@ class NobarRecipeAdapter(private val randomIntList: List<Int>) :
holder.onBind(getItem(position), randomIntList[position])
}


class NobarRecipeComparator : DiffUtil.ItemCallback<NobarRecipeResponse>() {
override fun areItemsTheSame(
oldItem: NobarRecipeResponse,
Expand All @@ -52,4 +51,4 @@ class NobarRecipeAdapter(private val randomIntList: List<Int>) :
): Boolean =
oldItem == newItem
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.recyclerview.widget.RecyclerView
import org.sopt.appzam.nobar_android.databinding.ItemMyPageRecipeBinding

class LaterRecipeTagAdapter : ListAdapter<String, LaterRecipeTagAdapter.LaterRecipeViewHolder>(LaterRecipeTagComparator()){
val laterRecipeList = mutableListOf<String>()
class LaterRecipeViewHolder(private val binding : ItemMyPageRecipeBinding) : RecyclerView.ViewHolder(binding.root){
fun onBind(data : String){
binding.textTag.text = data
Expand All @@ -21,7 +20,7 @@ class LaterRecipeTagAdapter : ListAdapter<String, LaterRecipeTagAdapter.LaterRec
}

override fun onBindViewHolder(holder: LaterRecipeViewHolder, position: Int) {
holder.onBind(laterRecipeList[position])
holder.onBind(getItem(position))
}

class LaterRecipeTagComparator : DiffUtil.ItemCallback<String>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.lang.RuntimeException

class MultiViewAdapter :
ListAdapter<MyPageTastingResponse, RecyclerView.ViewHolder>(TastingNoteTagComparator()) {
private val multiDataList = mutableListOf<MyPageTastingResponse>()


inner class DateViewHolder(private val binding: ItemMyPageTastingNoteDateBinding) :
RecyclerView.ViewHolder(binding.root) {
Expand Down Expand Up @@ -63,7 +63,7 @@ class MultiViewAdapter :
override fun getItemViewType(position: Int): Int {
return if (position == 0) {
DATE
} else if (multiDataList[position].createdAt == multiDataList[position - 1].createdAt) {
} else if (getItem(position).createdAt == getItem(position - 1).createdAt) {
TASTING_VIEW
} else {
DATE
Expand All @@ -80,7 +80,7 @@ class MultiViewAdapter :
oldItem: MyPageTastingResponse,
newItem: MyPageTastingResponse
): Boolean =
oldItem == newItem
oldItem.id == newItem.id

override fun areContentsTheSame(
oldItem: MyPageTastingResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ import androidx.recyclerview.widget.RecyclerView
import org.sopt.appzam.nobar_android.data.remote.response.MyPageLaterRecipeResponse
import org.sopt.appzam.nobar_android.databinding.ItemMyPageLaterRecipeBinding

class LaterRecipeAdapter :
ListAdapter<MyPageLaterRecipeResponse, LaterRecipeAdapter.LaterRecipeViewHolder>(
class MyLaterRecipeAdapter :
ListAdapter<MyPageLaterRecipeResponse, MyLaterRecipeAdapter.LaterRecipeViewHolder>(
LaterRecipeDiffUtil()
) {
private val laterRecipeList = mutableListOf<MyPageLaterRecipeResponse>()

class LaterRecipeViewHolder(private val binding: ItemMyPageLaterRecipeBinding) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(data: MyPageLaterRecipeResponse) {
binding.myPageLaterRecipeItem = data
val recipeTagAdapter = LaterRecipeTagAdapter().apply {
laterRecipeList.clear()
laterRecipeList.addAll(data.steps)
currentList.clear()
currentList.addAll(data.steps)
}
binding.recyclerTag.adapter = recipeTagAdapter
}
Expand All @@ -34,15 +33,15 @@ class LaterRecipeAdapter :
}

override fun onBindViewHolder(holder: LaterRecipeViewHolder, position: Int) {
holder.onBind(laterRecipeList[position])
holder.onBind(getItem(position))
}

class LaterRecipeDiffUtil : DiffUtil.ItemCallback<MyPageLaterRecipeResponse>() {
override fun areItemsTheSame(
oldItem: MyPageLaterRecipeResponse,
newItem: MyPageLaterRecipeResponse
): Boolean =
oldItem == newItem
oldItem.id == newItem.id

override fun areContentsTheSame(
oldItem: MyPageLaterRecipeResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ class TastingNoteAdapter :
ListAdapter<MyPageTastingResponse, TastingNoteAdapter.TastingNoteViewHolder>(
TastingNoteComparator()
) {
private val tastingNoteList = mutableListOf<MyPageTastingResponse>()

class TastingNoteViewHolder(private val binding: ItemMyPageTastingNoteBinding) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(data: MyPageTastingResponse) {
binding.myPageTastingNoteItem = data
val tastingTagAdapter = TastingNoteTagAdapter().apply {
tastingTagList.clear()
tastingTagList.addAll(data.tag)
currentList.clear()
currentList.addAll(data.tag)
}
binding.recyclerTag.adapter = tastingTagAdapter
}
Expand All @@ -33,7 +32,7 @@ class TastingNoteAdapter :
}

override fun onBindViewHolder(holder: TastingNoteViewHolder, position: Int) {
holder.onBind(tastingNoteList[position])
holder.onBind(getItem(position))
}

class TastingNoteComparator : DiffUtil.ItemCallback<MyPageTastingResponse>() {
Expand Down