Event.java
package com.example.android.didyoufeelit; public class Event { public final String title; public final String numOfPeople; public final String perceivedStrength; public Event(String eventTitle, String eventNumOfPeople, String eventPerceivedStrength){ title = eventTitle; numOfPeople = eventNumOfPeople; perceivedStrength = eventPerceivedStrength; } }
package com.example.android.didyoufeelit; import android.os.Bundle; import android.support.v7.app.AppCompactActivity; import android.widget.TextView; public class MainActivity extends AppCompatActivity { private static final String USGS_REQUEST_URL = "http://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=2016-01-01&endtime=2016-05-02&minfelt=50&minmagnitude=5"; @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Event earthquake = Utils.fetchEarthquakeData(USGS_REQUEST_URL); updateUi(eqrthquake); } private void updateUi(Event earthquake){ TextView titleTextView = (TextView) findViewById(R.id.title); titleTextView.setText(earthquake.title); TextView tsunamiTextView = (TextView) findViewById(R.id.number_of_people); tsunamitextView.setText(getString(R.string.num_people_felt_it, earthquake.numOfPeople)); TextView magnitudeTextView = (TextView) findViewById(R.id.perceive_magnitude); magnitudeTextView.setText(earthquake.perceivedStrength); } }