Last active
November 25, 2018 19:27
-
-
Save patrick-elmquist/e9ec64c59d94e006a5738efd53cfaa54 to your computer and use it in GitHub Desktop.
Revisions
-
patrick-elmquist revised this gist
Nov 25, 2018 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,9 @@ class ShowAdapter(private val items: List<Show>) : RecyclerView.Adapter<ShowViewHolder>() { init { setHasStableIds(true) } override fun getItemCount() = items.size override fun getItemId(position: Int) = items[position].hashCode().toLong() override fun onCreateViewHolder(parent: ViewGroup, vt: Int) = ShowViewHolder(parent.inflate(R.layout.item_show)) override fun onBindViewHolder(holder: ShowViewHolder, position: Int) = holder.bind(items[position]) } -
patrick-elmquist revised this gist
Nov 21, 2018 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,8 @@ class ShowAdapter(tvShows: List<Show>) : RecyclerView.Adapter<ShowViewHolder>() { private val items = tvShows.toList() init { setHasStableIds(true) } override fun getItemCount() = items.size override fun getItemId(position: Int) = items[position].hashCode().toLong() override fun onCreateViewHolder(parent: ViewGroup, vt: Int) = ShowViewHolder(parent.inflate(layout.item_tv_show)) -
patrick-elmquist revised this gist
Nov 21, 2018 . 1 changed file with 0 additions and 33 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,33 +0,0 @@ -
patrick-elmquist revised this gist
Nov 21, 2018 . 3 changed files with 16 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +0,0 @@ This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ class ShowAdapter(tvShows: List<Show>) : RecyclerView.Adapter<ShowViewHolder>() { private val items = tvShows.toList() init { setHasStableIds(true) } override fun getItemCount() = items.size override fun getItemId(position: Int) = items[position].hashCode().toLong() override fun onCreateViewHolder(parent: ViewGroup, vt: Int) = ShowViewHolder(parent.inflate(layout.item_tv_show)) override fun onBindViewHolder(holder: ShowViewHolder, position: Int) = holder.bind(items[position]) } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ class ShowViewHolder(view: View) : ViewHolder(view) { private val title = itemView.title private val description = itemView.description private val thumb = itemView.thumb @@ -23,10 +23,11 @@ class SeriesViewHolder(view: View) : ViewHolder(view) { thumb.translationX = translation } fun bind(viewModel: Show) { title.setText(viewModel.title) description.setText(viewModel.description) thumb.setImageResource(viewModel.image) poster.setImageResource(viewModel.image) // ... } } -
patrick-elmquist revised this gist
Nov 20, 2018 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ class SeriesAdapter(series: List<Series>) : RecyclerView.Adapter<SeriesViewHolder>() { private val items = series.toList() init { setHasStableIds(true) } override fun getItemCount() = items.size override fun getItemId(position: Int) = items[position].hashCode().toLong() override fun onCreateViewHolder(parent: ViewGroup, vt: Int) = SeriesViewHolder(parent.inflate(layout.item_series)) override fun onBindViewHolder(holder: SeriesViewHolder, position: Int) = holder.bind(items[position]) } -
patrick-elmquist created this gist
Nov 20, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ class SeriesViewHolder(view: View) : ViewHolder(view) { private val title = itemView.title private val description = itemView.description private val thumb = itemView.thumb private val poster = itemView.poster private val interpolator = FastOutLinearInInterpolator() /** * Offset the thumb and text with a factor [-1, 1] of the total width */ var offset: Float = 0f set(v) { field = v val unsigned = abs(v) val translation = if (v < 0) { interpolator.getInterpolation(unsigned) * itemView.measuredWidth } else { interpolator.getInterpolation(unsigned) * -itemView.measuredWidth } title.translationX = translation description.translationX = translation thumb.translationX = translation } fun bind(viewModel: Series) { title.setText(viewModel.title) description.setText(viewModel.description) thumb.setImageResource(viewModel.image) poster.setImageResource(viewModel.image) } }