Nguyen_TienDat
Nguyen_TienDat
BACHELOR’S THESIS
May 2023
Bachelor of Engineering
Software Engineering
ABSTRACT
Tampereen ammattikorkeakoulu
Tampere University of Applied Sciences
Bachelor of Engineering
This thesis presents the development of the Review Movie application, which is
an entertainment application, and indicates which method and architecture have
been used in its development. The purpose of this project was to create an ap-
plication where people can find entertainment after stressful working hours. This
application provides users with information, ratings, and genres of movies so
they can find the right movies among the ever-growing selection of titles.
With the use of Retrofit and the Model-View-ViewModel, the Review Movie appli-
cation has the ability to separate concerns and responsibilites in the codebase,
making it easier to maintain and update the application. The result of combining
Retrofit and Model-View-ViewModel patterns is a robust and scalable codebase.
In addition, this combination allows for efficient data binding, which means that
changes to the data in the ViewModel automatically update the user interface.
CONTENTS
1 INTRODUCTION .................................................................................. 5
1.1 History of movie industry ................................................................ 5
1.2 Project background and purpose ................................................... 5
2 APPLICATION REQUIREMENTS ........................................................ 7
2.1 User requirements.......................................................................... 7
2.2 Technical requirements .................................................................. 7
3 TECHNOLOGIES AND TOOLS .......................................................... 10
3.1 Kotlin ............................................................................................ 10
3.2 Retrofit ......................................................................................... 10
3.3 MVVM architecture....................................................................... 11
3.4 Android Studio.............................................................................. 11
4 TECHNICAL IMPLEMENTATION ....................................................... 13
4.1 MVVM (Model-View-ViewModel).................................................. 13
4.2 Retrofit ......................................................................................... 18
4.2.1 Retrofit Service ................................................................... 18
4.2.2 API Service ......................................................................... 20
4.3 User authentication ...................................................................... 22
4.4 Android Youtube Player ............................................................... 25
4.5 Review Movie application development ....................................... 27
4.6 Graphical user interface ............................................................... 28
5 TESTING AND ANALYSIS ................................................................. 31
5.1 User experience ........................................................................... 31
5.2 Comparative analysis ................................................................... 31
6 CONCLUSIONS AND DISCUSSION .................................................. 35
REFERENCES ........................................................................................ 36
4
1 INTRODUCTION
The film industry began in the late 19th century with the invention of motion-pic-
ture cameras and the cinématographe projector (University of Minnesota Librar-
ies, 2019). These innovations allowed for the creation of moving images that cap-
tured the attention of audiences around the world. By 1915, Hollywood had be-
come the center of the industry, and the introduction of talking films in the late
1920s marked a significant milestone.
Following World War II, the invention of television led to the development of new
genres and formats, such as sitcoms and dramas. The adoption of Video Cas-
sette Recorders in the 1980s marked another turning point, as audiences shifted
from movie theaters to home viewership (Encyclopædia Britannica, n.d.). Today,
the film industry continues to thrive with diverse movie themes and advanced
technologies that create high-quality movies that captivate viewers with stunning
visual effects and immersive sound.
Despite the challenges it has faced over the years, the film industry continues to
captivate audiences worldwide. From the early days of motion-picture cameras
to today's advanced technologies, industry has undergone numerous transfor-
mations and adaptations. It has set the foundation for prestigious awards cere-
monies such as the Oscars, which celebrate the best films and performances of
the year.
The movie industry originated and developed thanks to the development of tech-
nology with the inventions of contributed inventors and the creative ideas of film
makers. It was established to meet the demand of society, with countless of pur-
poses: from entertainment demand to the excited feelings that was actived by the
substances released to stimulate the brain - the dopamine, the seratone, the ox-
ytocin.
6
On the back side, with countless movie themes for the selection of the audiences,
that would make it hard for them to easily pick out the ones that meet all their
standards.
With the fast pace of modern life, people have strict routines and very little spare
time, so with the invention of an application that combines all in one feature to
review the movies would be the one the audiences are waiting for. To have better
interaction with the audiences, an application on a smartphone store would be
the best tool to reach the audience.
2 APPLICATION REQUIREMENTS
With the application users should be able to search and watch the hottest movies,
classic or popular TV shows from many countries. Moreover, this application also
provides other features such as viewing reviews, rankings, descriptions, and ac-
tors of the movies. Especially, this application should provide a feature that user
can create an account to save their favorite movies in their playlist. From this we
can draw user requirements for the application.
Besides, another problem when deploying a project is too many files and func-
tions, which can make it a little dificult for developers to manage and work. To
address this challenge, one technology was developed called Model-View-View
Model (MVVM) architecture (Figure 2. MVVM architecture (GeeksforGeeks). With
the logical separation of the application into separate parts of this pattern, it is
easier to develop and manage the project. From the Figure 2. MVVM architecture
(GeeksforGeeks), it can be observed that the View layer is responsible for dis-
playing data to the user and receiving user input. The ViewModel layer acts as
an intermediary between the View and the Model layers. It retrieves data from the
Model and prepares it for display in the View. The Model layer is responsible for
9
retrieving data from a data source, such as a database or API. The arrows in the
figure show the flow of data between the layers.
3.1 Kotlin
The merits of Kotlin, such as its concise syntax, null safety features, and seam-
less interoperability with existing Java codebases, have made it a popular lan-
guage for Android apps and web development. Kotlin is also supported by big
companies like Google, JetBrains, and Gradle. For that, Kotlin is a good choice
for this project.
3.2 Retrofit
Retrofit has been briefly summarized in term of affects as well as benefits above
and can be seen at Figure 1. Data flow of Retrofit.. Retrofit is an open-source
library for Android development. It is a type-safe HTTP client for Android and Java
that allows developers to consume Restful APIs by mapping HTTP requests and
responses to Java objects. Built on top of the OkHTTP library by Square, MVVM
provides a simple interface for making network requests easily (DigitalOcean,
2018).
Retrofit also has a simple and easy-to-use interface that allows developers to
make network requests easily. Additionally, it uses annotations to add metadata
to the API interfaces, making the code easier to read and understand. Further-
more, Retrofit is built on top of OkHTTP, a widely-used HTTP client library, which
provides support for features such as connection pooling, transparent compres-
sion, and response caching.
11
Overall, choosing Retrofit for API integration in Android development offers sev-
eral benefits, including improved code maintainability, reduced errors during de-
velopment, and ease of use.
The MVVM architecture provides a clear separation of concerns between the dif-
ferent components of an application, making it easier to maintain and extend the
codebase. MVVM makes it easy to test the business logic of the application by
isolating it from the UI. This leads to more reliable and predictable code and re-
duces the likelihood of bugs. Additionally, MVVM allows for more flexibility in the
UI, as it can be updated independently of the data and business logic.
Android Studio is the official Integrated Development Environment (IDE) for An-
droid application development. Based on the powerful code editor and developer
tools from IntelliJ IDEA, Android Studio offers even more features that enhance
their productivity when building Android apps (Android Developers, 2016). An-
droid Studio offers Android developers key benefits such as:
• Provides complete and powerful Android application development tools
and features.
• Has a user-friendly interface.
• Integrate with the Android SDK, allowing convenient creation and man-
agement of Android projects.
12
4 TECHNICAL IMPLEMENTATION
The application was developed using the MVVM pattern. A TabFragment file was
created to serve as the View component of the application. Its main role is to
present data to the user. Please refer to Picture 1 for the implementation code of
TabFragment. Code explanation will be provided below (Picture 7).
A folder containing all the models required for the application was created as
shown in Picture 2.
For instance, the Cast object (Picture 3) was used as an example to implement
corresponding objects marked with different annotations. In this case, the
@SerializedName annotation was used to specify the name when converting
between Java object and Javascript Object Notation (JSON). This mapping
enables the corresponding field in the JSON object to parse data when using the
Gson library.
In order to transfer data between the View and Model components, the
ViewModel was utilized to facilitate the process.
The LiveEvent class was used to retrieve and store data from the Movie Model
as depicted in Picture 4. Three classes were created to inherit the LiveEvent
class: showEmptyEvent, showRefreshEvent, and itemClickEvent.
The code was then implemented to interact with the data and store it in the
adapter, as shown in Picture 5. The items represent the data in this context.
Following the data acquisition, This code is a method called loadData() (Picture
6) that loads data from an API and updates the UI accordingly. It sets a flag to
16
indicate that loading is in progress, then uses a coroutine to make the API call on
a background thread. Once the response is received, it updates the UI on the
main thread by adding the results to a list, checking if more data can be loaded,
and showing an empty layout if the list is empty. It also updates flags to indicate
loading and refreshing are finished.
Once the data was displayed on the View side, the observe() method is used to
monitor changes in the data of the ViewModel and update the UI accordingly. The
loading, showEmptyEvent, and showRefreshEvent variables are observed for
changes and trigger the appropriate UI updates when their values change. The
itemClickEvent variable is also observed to handle click events on a specific item
and open a new activity with the selected item's details (as shown in Picture 7).
In simple terms, the ViewModel retrieves data from the Model and transfers it to
the View. When there is a change in the data, the View updates the UI through
the ViewModel.
18
4.2 Retrofit
Since Retrofit was built on top of the OkHttp library, some of its methods were
utilized. Additionally, the Gson library was also employed to simplify data transfer
(Picture 9).
The API utilized for the application was obtained from https://www.the-
moviedb.org/. Initially, registration was required, and the api-key was obtained
from the server. Once all the necessary APIs were available, a Gradle configura-
tion was created for development as shown in Picture 10 to simplify the applica-
tion development process, minimize development time, and enable easy man-
agement.
19
The next step involves building the API model, referred to as RetrofitService as
shown in Picture 11, which will be utilized by other services to communicate with
the API. This is a code snippet for adding an interceptor to an instance of
OkHttpClient in an Android application. The interceptor adds a base query and
header to each outgoing HTTP request, including an API key and optionally a
session ID. The original request URL is modified using a builder object, and the
modified request is then returned by the interceptor. The modified request is then
used to proceed with the network call. This is commonly used in API communi-
cation to ensure authentication and authorization for API requests.
The application features three main functions: movie data display, login, and fa-
vorite movie storage. To manage each of these features, three services were
implemented (Picture 12).
Subsequently, implementation was carried out for each file, starting with the au-
thentication service (Picture 13).Error! Reference source not found.
The FavoriteService (Picture 14) and MovieService (Picture 15) classes also
have a getInstance() function that returns an instance of the corresponding ser-
vice. Annotations are used to interact with the API in these services, and they are
similar to the ones used in the AuthenticationService. The FavoriteService is re-
sponsible for managing users' favorite movies, while the MovieService is used to
retrieve movie data from the API.
The API can be used to access MovieService for searching and displaying movie
information. AuthenticationService offers token requests for user login. Addition-
ally, users can store favorite movies using the FavoriteMovie feature in their per-
sonal account.
Creating a separate authentication system for this app is not necessary. Instead,
the API can be used to create one by following three steps:
Once the request token is obtained, the user can be directed to the following URL
to approve the request token via the sign-in button. Clicking the button indicates
the user's approval and allows for proceeding to step 3.
24
After the user clicks the sign-in button in step 2, the following function will be
initiated in step 3. The server will return a new session ID, which can be used to
write user data. If the session is valid, the user can log in. Otherwise, an error
message will be displayed.
The application features a trailer viewing function in addition to the ability to read
information and reviews for each movie. During API exploration, related videos
were discovered, all of which are from YouTube. To enable video playback, the
androidyoutubeplayer library was utilized (Picture 20).
The API provides the key for the video, which can be used for the trailer feature.
In the createIntent() function, the method arguments were utilized to pass the key
to the dialog as shown in Picture 21.
When the user clicks on the button to play trailer, dialog will appear on the device
via the dialog.show method (Picture 22).
Once the dialog appears, the onCreateView method will be initiated to construct
the fragments according to the specified layout. The layout, which can be seen
on line 75 as "dialog_trailer_view" in Picture 23, is used for this purpose.
The method "onViewCreated" will execute right after the dialog's lifecycle. Within
this method, the YouTube PlayerView is utilized, and the "loadVideo" method is
called with the videoId key that was passed earlier, triggering the feature trailer
video to launch (Picture 24).
27
The development of the Review Movie Application was aided using the MVVM
pattern, a popular design pattern used in software development. The MVVM pat-
tern helps to simplify the application architecture by separating the application
components into three distinct layers: the data (Model), the interface (View), and
the logic (View-Model).
By separating these components, the MVVM pattern helps to make the codebase
cleaner and easier to maintain. The Model layer represents the data, which can
be obtained from various sources such as a database or web service. The View
layer represents the UI, which interacts with the user to display data and receive
input. The View-Model layer acts as a bridge between the Model and View layers,
providing the logic and data necessary to update the View based on changes in
the Model.
In addition to using the MVVM pattern, the Review Movie Application also utilizes
Retrofit to access the API. Retrofit is a type-safe HTTP client for Android and
Java, which greatly simplifies the process of making network requests and pro-
cessing the response data. Retrofit helps to reduce the amount of code needed
to access the API, which saves time and reduces the likelihood of errors.
28
As can be seen in Picture 25, there are two functions: Search and Add Favorite
Movie. This could trigger a search query to the backend API that retrieves a list
of movies matching the search criteria. In addition to the search function, the app
also shows an "add Favorite Movie" function. This feature would allow users to
save their favorite movies to a personal account within the Review Movie appli-
cation.
In Picture 26, the app displays a list of movies categorized as popular, now play-
ing, up coming, and top-rated, each tab displays a list of movie titles and posters,
29
which are likely sourced from an API. When a user selects a movie from the list,
additional information about that movie is displayed to the list. This information
includes the movie's title, synopsis, rating, release date, and perhaps even user
reviews or ratings.
The last two functions are authentication and video trailers (Picture 27). The au-
thentication function allows users to create an account or log in with their existing
account credentials. Once logged in, they can access their personal account’s
favorite list and add or remove movies as they like. The video trailer’s function
allows users to watch trailers for each selected movie directly in the app. This
feature enhances the user experience by allowing them to preview the movie
before deciding to watch it.
The application was then tested to ensure it worked as required. The testing pro-
cess was conducted by users to verify the application's features, including logging
into the application, saving movies to favorites, viewing related information about
movies, and ensuring proper functionality of the video playback function. Most of
users confirmed that all functions were fully operational and functioning properly,
indicating that the API endpoints worked correctly with no lags when passing in-
formation from the frontend to the backend and vice versa.
While the current functionality of the Review Movie application is relatively sim-
plistic, it was designed with a clean and intuitive UI that allows for easy navigation
and access to important information. The UI features a minimalist design with a
modern look and feel, which helps to create a more immersive and engaging
experience for users.
Overall, while the Review Movie application has been successfully tested and
offers a solid foundation for further development, there is still ample room for
growth and improvement. By continuing to refine and enhance the application's
functionality and user experience, developers can ensure that it remains a popu-
lar and indispensable tool for movie lovers everywhere.
For the purpose of comparison and further development for Review Movie appli-
cation. I tested another popular movie application, IMDb. IMDb is known as the
go-to source for the world's most popular movies, TV, and celebrity information
(Picture 28).
32
In short, Review Movie still has a lot of potential for development and needs to
be improved in many aspects.
35
Through the development of the application and the writing of this thesis, it can
be clear that the two technologies used have greatly simplified the management
and implementation of coding. Application development can continue, and more
features can still be added more easily.
Overall, people’s entertainment needs are increasing, and with the development
of technology, they can easily meet those needs. Developing applications with
the use of advanced technologies and good methods creates a sense of fun for
users. That also proves that the market and development potential of entertain-
ment applications are huge now and in the future.
REFERENCES
GitHub. 2016. Obut, Orhan. Hawk: HTTP authentication for Android & Java. Read
on 07.04.2023. https://github.com/orhanobut/hawk