By Carl Sundberg
In this task, I've utilized the NASA Near Earth Object Web Service (NeoWs) API to retrieve information about asteroids approaching Earth. The API provides data on asteroid trajectories, velocities, and their potential collision risks. The purpose of the app is to display a list of asteroids based on specific dates and show more detailed information about each one.
-
/feed?start_date=&end_date=
Retrieves a list of all asteroids approaching Earth within a specific time frame. Users can select a start and end date to fetch the data. This is implemented in thegetDateAsteroids
function, where both start and end dates are sent as parameters. -
/feed/today
Fetches today's asteroids and their detailed data. This endpoint is used in thegetTodayAsteroids
function to display asteroids for the current day.
Once the data is fetched from the API, it is directed to various fragments within the app:
-
AsteroidTodayFragment
Displays a list of today's closest asteroids. The information includes the asteroid's name, absolute magnitude, relative speed, collision risk, and more. -
DateSelectionFragment
Users can select a specific start and end date to retrieve asteroids from the chosen period. -
AsteroidOrbitFragment
This view visually shows the asteroid's trajectory using a WebView that loads NASA's JPL page for the selected asteroid.
Navigation between fragments is managed with the Navigation Component, allowing seamless transitions between views. The back button follows the steps in the backstack until reaching the main view.
The app is designed to function in both portrait and landscape modes. It utilizes ConstraintLayout
and Flow
to ensure that graphical components are dynamically positioned and adapt to different screen sizes and orientations.
Features two buttons leading to the app's primary functions.
Displays a list of the closest asteroids to Earth.
Shows NASA's Orbital View with the asteroid's trajectory.
Allows the user to specify a time frame to retrieve data.
Although the app's design is simple, the development was quite challenging. I encountered multiple issues with RecyclerView
and NavController
not behaving as expected. Additionally, handling JSON data proved frustrating due to vague error messages, complicating the debugging process. However, layout design—typically a source of frustration—was smoother this time, as I now have a better grasp of ConstraintLayout
and Flow
.