My entry for Stage 2 of the Popular Movies Project for Udacity can be found here on GitHub.
Before I Begin
It’s mostly a polishing and finishing of Stage 1, with additional basic functionality, plus offline persistence. I like that of all of the things learnt after Stage 1, the one thing they force you to do is to handle data in a database through a Content Provider.
I would’ve liked to try out Realm.io here, but this chapter specifically mentions Cursors and SQLite, so that’d be a bit presumptuous. I’ll do it in the next project, maybe. Anyway, on to the project.
Work In Progress
I more or less copied the Content Provider and Database functionality from the sample app they give and it works quite well. It’s amazing to see how much of a performance/UX difference an app makes when it doesn’t have to wait for API calls before displaying something to the user.
I show the Movie Reviews and Trailers as two RecyclerViews, each in a Fragment inside a ViewPager. This is, to me, the most intuitive solution from a UX perspective. Unfortunately this raised quite a few issues in terms of Portrait/Landscape/Tablet support, and correct drawing of Fragment Height/Width can be tricky, especially along with HandleInstanceState.
|This is fine||This is fine||This is not fine||Totally not fine|
See how the table of images doesn’t fit into the website because of formatting clashes? That’s what it’s like working with a ViewPager in ConstraintLayout when a user rotates his screen. Luckily I could solve it by using LinearLayout to divide the large segments, and then ConstraintLayout inside to manage all the small working parts. That seems to be the ideal way to approach ConstraintLayout, until I figure it out a bit better later.
So I made life more difficult for myself with those fragments, but other than that I’m happy with what I did. It’s not perfect, but it works.