Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Complex, Beautiful and Performant Screens

Building Complex, Beautiful and Performant Screens

Jamie Adkins

October 27, 2018
Tweet

More Decks by Jamie Adkins

Other Decks in Technology

Transcript

  1. Proud Digital Partner to some of the biggest names in

    Sport. Clubs Leagues & Events World & National Governing Bodies Building Complex, Beautiful and Performant Screens
  2. What is a complex screen? Building Complex, Beautiful and Performant

    Screens Screens that show lots of different types of content. Lots of different view types in your RecyclerView. The Facebook news feed is a great example. Our app home screens are complex screens. We show news, video, live scores, social feeds.
  3. Building Complex, Beautiful and Performant Screens • Smooth scrolling perfomance

    • Easy to use for developers • Seamless and graceful loading for users Goals
  4. Building Complex, Beautiful and Performant Screens • Abstraction away from

    ViewHolder • Update widgets individually CoreWidget - Pros
  5. Building Complex, Beautiful and Performant Screens • Performance • No

    Diffing • Poor User Experience CoreWidget - Cons
  6. • Huge widgets need to be split up, without sacrificing

    ease of use for developers • Introduce placeholder/skeleton views to improve the loading experience • Clever diffing Refined Goals Building Complex, Beautiful and Performant Screens
  7. Building Complex, Beautiful and Performant Screens • Library that makes

    building complex screens easier. • Divides everything into groups that can be individually updated. Groupie
  8. Building Complex, Beautiful and Performant Screens • Each View in

    the RecyclerView is an ‘Item’ • Can group Items using ‘Sections’ • Sections can be updated independently, and the RecyclerView sees the individual items Groupie
  9. Building Complex, Beautiful and Performant Screens Articles Section Header Article

    Article Footer Developer’s POV RecyclerView’s POV
  10. Groupie Items Building Complex, Beautiful and Performant Screens data class

    ArticleItem(private val article: Article) : Item() { override fun getLayout(): Int { return R.layout.item_content } override fun bind(viewHolder: ViewHolder, position: Int) { val view = viewHolder.itemView view.contentTitle.text = article.title ... } }
  11. Groupie Items Building Complex, Beautiful and Performant Screens data class

    ArticleItem(private val article: Article) : Item() { override fun getLayout(): Int { return R.layout.item_content } override fun bind(viewHolder: ViewHolder, position: Int) { val view = viewHolder.itemView view.contentTitle.text = article.title ... } }
  12. Groupie Items Building Complex, Beautiful and Performant Screens data class

    ArticleItem(private val article: Article) : Item() { override fun getLayout(): Int { return R.layout.item_content } override fun bind(viewHolder: ViewHolder, position: Int) { val view = viewHolder.itemView view.contentTitle.text = article.title ... } }
  13. Groupie Items Building Complex, Beautiful and Performant Screens data class

    ArticleItem(private val article: Article) : Item() { override fun getLayout(): Int { return R.layout.item_content } override fun bind(viewHolder: ViewHolder, position: Int) { val view = viewHolder.itemView view.contentTitle.text = article.title ... } }
  14. Groupie Items Building Complex, Beautiful and Performant Screens data class

    ArticleItem(private val article: Article) : Item() { override fun getLayout(): Int { return R.layout.item_content } override fun bind(viewHolder: ViewHolder, position: Int) { val view = viewHolder.itemView view.contentTitle.text = article.title ... } }
  15. Groupie Items Building Complex, Beautiful and Performant Screens data class

    ArticleItem(private val article: Article) : Item() { override fun getLayout(): Int { return R.layout.item_content } override fun bind(viewHolder: ViewHolder, position: Int) { val view = viewHolder.itemView view.contentTitle.text = article.title ... } }
  16. Groupie Sections Building Complex, Beautiful and Performant Screens class ArticlesSection(header:

    HeaderItem, placeholder: Section) : Section() { init { setHeader(header) setPlaceholder(placeholder) } }
  17. Groupie Sections Building Complex, Beautiful and Performant Screens class ArticlesSection(header:

    HeaderItem, placeholder: Section) : Section() { init { setHeader(header) setPlaceholder(placeholder) } }
  18. Groupie Sections Building Complex, Beautiful and Performant Screens class ArticlesSection(header:

    HeaderItem, placeholder: Section) : Section() { init { setHeader(header) setPlaceholder(placeholder) } }
  19. Groupie Sections Building Complex, Beautiful and Performant Screens class ArticlesSection(header:

    HeaderItem, placeholder: Section) : Section() { init { setHeader(header) setPlaceholder(placeholder) } }
  20. Groupie Sections Building Complex, Beautiful and Performant Screens class ArticlesSection(header:

    HeaderItem, placeholder: Section) : Section() { init { setHeader(header) setPlaceholder(placeholder) } }
  21. Groupie Sections Building Complex, Beautiful and Performant Screens class ArticlesSection(header:

    HeaderItem, placeholder: Section) : Section() { init { setHeader(header) setPlaceholder(placeholder) setFooter(footerSection) setHideWhenEmpty(true) } }
  22. Groupie Adapters Building Complex, Beautiful and Performant Screens class HomeGroupAdapter(

    articlesSection: ArticlesSection, ladderSection: LadderSection, videosSection: VideosSection, aroundTheNetworkSection: AroundTheNetworkSection, homeFavouritesSection: HomeFavouritesSection ) : GroupAdapter<ViewHolder>() { init { spanCount = 2 add(articlesSection) add(ladderSection) add(videosSection) add(aroundTheNetworkSection) add(homeFavouritesSection) } }
  23. Groupie Adapters Building Complex, Beautiful and Performant Screens class HomeGroupAdapter(

    articlesSection: ArticlesSection, ladderSection: LadderSection, videosSection: VideosSection, aroundTheNetworkSection: AroundTheNetworkSection, homeFavouritesSection: HomeFavouritesSection ) : GroupAdapter<ViewHolder>() { init { spanCount = 2 add(articlesSection) add(ladderSection) add(videosSection) add(aroundTheNetworkSection) add(homeFavouritesSection) } }
  24. Groupie Adapters Building Complex, Beautiful and Performant Screens class HomeGroupAdapter(

    articlesSection: ArticlesSection, ladderSection: LadderSection, videosSection: VideosSection, aroundTheNetworkSection: AroundTheNetworkSection, homeFavouritesSection: HomeFavouritesSection ) : GroupAdapter<ViewHolder>() { init { spanCount = 2 add(articlesSection) add(ladderSection) add(videosSection) add(aroundTheNetworkSection) add(homeFavouritesSection) } }
  25. Groupie Adapters Building Complex, Beautiful and Performant Screens class HomeGroupAdapter(

    articlesSection: ArticlesSection, ladderSection: LadderSection, videosSection: VideosSection, aroundTheNetworkSection: AroundTheNetworkSection, homeFavouritesSection: HomeFavouritesSection ) : GroupAdapter<ViewHolder>() { init { spanCount = 2 add(articlesSection) add(ladderSection) add(videosSection) add(aroundTheNetworkSection) add(homeFavouritesSection) } }
  26. Groupie Adapters Building Complex, Beautiful and Performant Screens class HomeGroupAdapter(

    articlesSection: ArticlesSection, ladderSection: LadderSection, videosSection: VideosSection, aroundTheNetworkSection: AroundTheNetworkSection, homeFavouritesSection: HomeFavouritesSection ) : GroupAdapter<ViewHolder>() { init { spanCount = 2 add(articlesSection) add(ladderSection) add(videosSection) add(aroundTheNetworkSection) add(homeFavouritesSection) } }
  27. Groupie Adapters Building Complex, Beautiful and Performant Screens class HomeGroupAdapter(

    articlesSection: ArticlesSection, ladderSection: LadderSection, videosSection: VideosSection, aroundTheNetworkSection: AroundTheNetworkSection, homeFavouritesSection: HomeFavouritesSection ) : GroupAdapter<ViewHolder>() { init { spanCount = 2 add(articlesSection) add(ladderSection) add(videosSection) add(aroundTheNetworkSection) add(homeFavouritesSection) } }
  28. Updating Sections Building Complex, Beautiful and Performant Screens override fun

    showArticles(articles: List<Article>) { val items = articles.map { article -> ArticleItem(article) } articlesSection.update(items) }
  29. Updating Sections Building Complex, Beautiful and Performant Screens override fun

    showArticles(articles: List<Article>) { val items = articles.map { article -> ArticleItem(article) } articlesSection.update(items) }
  30. Updating Sections Building Complex, Beautiful and Performant Screens override fun

    showArticles(articles: List<Article>) { val items = articles.map { article -> ArticleItem(article) } articlesSection.update(items) }
  31. Updating Sections Building Complex, Beautiful and Performant Screens override fun

    showArticles(articles: List<Article>) { val items = articles.map { article -> ArticleItem(article) } articlesSection.update(items) }
  32. Updating Sections Building Complex, Beautiful and Performant Screens override fun

    showArticles(articles: List<Article>) { val items = articles.map { article -> ArticleItem(article) } articlesSection.update(items) }
  33. Building Complex, Beautiful and Performant Screens • Split up your

    Views! • Think about loading states • Groupie isn’t the silver bullet Takeaways