‫Let's continue with the main activity.
‫I need to initialize the recycler view and set a layout manager to width equals to binding dot recycler
‫view.
‫And here I need an adapter.
‫So movie adapter equal to new movie adapter.
‫This and I'll pass the movies array list then recycler view dot set item animator new default animator.
‫This is just for animation and recycler view dot set adapter to the movie adapter that we created before
‫and movie adapter dot notify data set changed.
‫Don't miss this very important step.
‫Movie adapter dot notify data set changed this method notify data set changed is used to notify an adapter
‫associated with a recycler.
‫View that the underlying data set has changed and it should refresh the displayed items in the recycler
‫view.
‫Let's go up and here I need to initialize the swipe refresh layout equals to binding dot swipe layout
‫swipe refresh layout dot set color schema resource.
‫And this method is used to specify the colors of swipe to refresh loading indicator and I'll use r dot
‫color dot black swipe refresh lay out.
‫This is an instance of swipe refresh layout class, which is a common android UI component used to implement
‫the pull to refresh gesture.
‫It allows users to refresh the content of the view by swiping down and swipe refresh layout dot set
‫on refresh listener new swipe on refresh listener.
‫So when the user refresh it, I need to call this method Get popular movies again.
‫Okay.
‫Save the project and don't miss when dealing with internet and using remote data sources like the databases,
‫you should include the permission to access the internet.
‫Let's run our project and we have this error.
‫I think it's a duplicate class error because scroll down, you can see duplicate classes.
‫The solution I mentioned before how to solve the common errors of Android studio.
‫I'll use this implementation for this platform.
‫Sync Now run again and I have another error here in the movie list item.
‫I specified this for the layout so I remove them.
‫I remove the width and height for the layout tag.
‫And this is our application.
‫Everything is working fine, but no movies.
‫This is just because I didn't specify the layout manager for the recycler view.
‫So always when dealing with recycler view, please pay attention to set the adapter to notify data set
‫changed and to specify the layout manager set layout manager and I'll use grid layout because I'm going
‫to display the movies into a grid manner span, count how many columns I need to use.
‫So let's run again and congratulations guys.
‫This is our amazing application that fetches the movies from the online database, which is that the
‫IMDb API and display all of these movies in a swipe to refresh layout.
‫So if you scroll down, you can see this loading and it's searching for new movies to display.
‫You can see the movie image, the movie title, and the average rate for every movie.