- Click the Fork symbol in the top right of the repo.
- Navigate to the newly forked repo in your account
- Click the green clone or download button on the repo.
- Copy the provided URL
- Open a git bash console in the directory where you want your project to be.
- Clone the repo into your workspace
- Open Android Studio
- Import the cloned project
a. With an open project, go to File->New->Import
b. With all projects closed, click Import Project
- Create the layout for an activity that will list the display name for all returned congresspeople.
You can see the data provided for all congresspeople in this query in the API documentation (https://projects.propublica.org/api-docs/congress-api/members/#lists-of-members)
- Write a CongressPersonOverview repository class that will wrap data from the provided library in a
MutableLiveData
object and return it.
Use
ArrayList<CongresspersonOverview> rawData = CongressDao.getAllMembers();
to get overview details from the library.
- Write a
ViewModel
class that returns a singletonLiveData
object.
Remember, a singleton class doesn't have a public constructor. Intead, it has a getter that checks if the object has been instantiated, if it hasn't it builds the object and returns it. If it has, it returns the object.
- In your
Activity
class, attach your viewmodel to the view by usingviewModel = ViewModelProviders.of(this).get(MyViewModel.class)
- Call the
observe(Context, Observer)
method. In the observer, write what the app should do each time the data is updated (ie update the UI).
You'll want to build a display name for each congressperson combining things like First and Last Name, party and state.
Add the congress person's ID to theTag
field of theView
object so you can retreive it when the view is clicked. If this takes more than a few lines of code, do it in a separate method. You'll need to userunOnUiThread
to perform the final process of attaching the newView
to the UI.
- Be sure to thoroughly test this activity.
- Create a layout for an Activity that will display details for a selected congress person.
You can see the data provided for each congressperson in this query in the API documentation (https://projects.propublica.org/api-docs/congress-api/members/#get-a-specific-member)
- In your list Activity, build an
onClickListener
that will retrieve theTag
from the view and attach it to anIntent
which launches your new activity. - Test your
Intent
.
- Repeat steps 2 - 6 of part 3 for your new activity.
Use
CongresspersonDetails profile = CongressDao.getMemberDetails(id);
to get the congressperson's details (step 2)
Submit your project by creating a pull request on this project, your PM will review it and respond to you.