-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(PopularFestivalForegroundAdapter): foreground 인기 축제 목록을 무한 스크롤 가능하게 변경한다. * refactor(PopularFestivalViewPagerAdapter): 변수 이름 카멜 케이스로 변경 * refactor(FestivalListPopularViewHolder): DotIndicator 는 터치해서 이동할 수 없다 * refactor(PopularFestivalViewPagerAdapter): initialPosition 계산 변수로 분리 * fix(PopularFestivalViewPagerAdapter): 축제 목록이 변경되면 포지션 초기화 * feat(PopularFestivalViewPagerAdapter): 미리 로딩하는 좌우 화면 개수를 2로 변경한다 * feat(PopularFestivalViewPagerAdapter): 인기 축제 개수가 0 개면 인기 축제 목록이 보이지 않는다
- Loading branch information
1 parent
6e066bd
commit c41210d
Showing
7 changed files
with
62 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 17 additions & 20 deletions
37
...ation/ui/home/festivallist/popularfestival/foreground/PopularFestivalForegroundAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,33 @@ | ||
package com.festago.festago.presentation.ui.home.festivallist.popularfestival.foreground | ||
|
||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalItemUiState | ||
|
||
class PopularFestivalForegroundAdapter : | ||
ListAdapter<FestivalItemUiState, PopularFestivalForegroundViewHolder>(diffUtil) { | ||
class PopularFestivalForegroundAdapter(festivals: List<FestivalItemUiState> = listOf()) : | ||
RecyclerView.Adapter<PopularFestivalForegroundViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PopularFestivalForegroundViewHolder { | ||
private val _festivals = festivals.toMutableList() | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int, | ||
): PopularFestivalForegroundViewHolder { | ||
return PopularFestivalForegroundViewHolder.of(parent) | ||
} | ||
|
||
override fun onBindViewHolder(holder: PopularFestivalForegroundViewHolder, position: Int) { | ||
holder.bind(getItem(position)) | ||
holder.bind(_festivals[position % _festivals.size]) | ||
} | ||
|
||
companion object { | ||
val diffUtil = object : DiffUtil.ItemCallback<FestivalItemUiState>() { | ||
override fun areItemsTheSame( | ||
oldItem: FestivalItemUiState, | ||
newItem: FestivalItemUiState, | ||
): Boolean { | ||
return oldItem.id == newItem.id | ||
} | ||
override fun getItemCount(): Int = Int.MAX_VALUE | ||
|
||
override fun areContentsTheSame( | ||
oldItem: FestivalItemUiState, | ||
newItem: FestivalItemUiState, | ||
): Boolean { | ||
return oldItem == newItem | ||
} | ||
fun submitList(festivals: List<FestivalItemUiState>) { | ||
if (_festivals.toList() == festivals) { | ||
return | ||
} | ||
_festivals.clear() | ||
_festivals.addAll(festivals) | ||
notifyDataSetChanged() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters