Skip to content

Android application which lists the latest photos of the NASA's API: Astronomy Picture of the Day.

License

Notifications You must be signed in to change notification settings

1ud0v1c/nasa-apod

Repository files navigation

NASA - Astronomy Picture of the Day

API Unit Tests Quality Gate Status

Android application which list the last 30 photos of the NASA's API: Astronomy Picture of the Day.

Design

The main inspiration for the HomeActivity comes from the Photo Application from Nick Ermakov.

To be able to provide a great user experience when loading or when an error occurred while fetching the data, I browsed some really great projects, for example :

To find the logo to display the current state of my adapter list, I used the website Undraw.

Inspiration

I wanted to thank, those two applications which give me inspiration for design or even some actions (like set as wallpaper):

  • Resplash: A very effective application to find beautiful wallpaper for our smartphone powered by the website Unsplash
  • APODWallpaper: An application which consumes the APOD API.

HomeActivity

For the HomeActivity, I tried to provide a nice & efficient user experience, thanks to different state. If you launch the application without having internet, you will have a screen which gives you a way to relaunch the request, In the same spirit, if you have a timeout or a server issue, you will ended with a different screen.

Home no internet Home network error

If everything is ok, you will first end up with a loading screen to help the user be patient, then you will have with a fadeOut animation the list of images displayed.

Home loading screen Home listing

The next time, you will launch the application, the data will be loaded from the database, thus you will end directly on the list. Some days, the API gives us some video instead of a classical image, to be able to offer a thumbnail in this case, I work on a solution :

Finally, I added 3 actions available in the action bar:

  • As, I use a database to avoid to always request the NASA API, you need to be able to request it anew to be up to date. That is why, I provided a refresh action button which gives the user the possibility to relaunch a request.
  • I found it a bit frustrating to not be able to request more days to display. So, in order to increase the application life duration. I added a number picker, to choose the number of days to request. As soon as the user validated the new number of days, we launch a new request.
  • The last action is very simple, but is still useful. It is the possibility to see the remaining quota for our API Key.

Home number picker Home quota

DetailActivity

After a click on an item from the HomeActivity, you will enter in the DetailActivity, which list every information about the photo of the day.

DetailActivity screen

You will also be able to do two actions. Share the URL to the website of the Nasa about the current photo

DetailActivity share action

Use the HD version of the image as wallpaper for your smartphone.

DetailActivity wallpaper download DetailActivity wallpaper error DetailActivity wallpaper result

ZoomActivity

Last, but not least, the ZoomActivity, entered after a click on the photo from the DetailActivity, allow an user to access the HD version of the image and can zoom on it.

ZoomActivity loading ZoomActivity loaded

You will enter in an interactive mode and will be able to zoom or move on the photo.

ZoomActivity zoom interaction

A landscape experience will be better because the majority of the photo are well suited for landscape.

ZoomActivity landscape

Architecture

For this test, I used an MVVM architecture.

MVVM architecture

We can check the HomeActivity implementation :

  • HomeActivity, it is the View himself, which can interact with the user
  • HomeViewModel, the man-in-the middle classes which make the linking between the View and the Model
  • HomeRepository, last but not least the class which does all the business logic. Generally speaking, this class handle the call to API or database.

The main advantage of this type of architecture, it is the capacity to easily test the business logic, We just have to test the repositories classes. And with dependency injection, it is even easier.

External dependencies

  • Retrofit: A type-safe HTTP client for Android. I used a moshi converter. I tend to use moshi over gson or jackson since I saw that talk. Moshi seems to better handle accent and error than Gson and is much smaller than Jackson.
  • For my database, I chose Room for the efficiency to handle entities and database access.
  • Coroutines: Light-weight thread implementation. I like the readability and the simplicity of coroutine.
  • Glide: Fast and efficient open source image loading framework for Android that wraps media decoding, memory and disk caching, and resource pooling. Easy to use and easily configurable, it was the perfect library for this test.
  • Koin: I used Koin for dependency injection.
  • PhotoView: A wrapper of an ImageView which supports a zooming experience. Very appropriate to display HD images.