This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SettingsActivity extends PreferenceActivity | |
implements Preference.OnPreferenceChangeListener { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Add 'general' preferences, defined in the XML file | |
// TODO: Add preferences from XML | |
addPreferencesFromResource(R.xml.pref_general); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<string name="app_name">Sunshine</string> | |
<string name="action_settings">Settings</string> | |
<string name="action_map">Map Location</string> | |
<string name="pref_location_label">Location</string> | |
<string name="pref_location_key" translatable="false">location</string> | |
<string name="pref_location_default" translatable="false">40377</string> | |
<string name="pref_units_label">Temperature Units</string> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<EditTextPreference | |
android:defaultValue="@string/pref_location_default" | |
android:inputType="text" | |
android:key="@string/pref_location_key" | |
android:singleLine="true" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void loadData() { | |
mWeekForecastAdapter.clear(); | |
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext); | |
String location = sharedPreferences.getString(getString(R.string.pref_location_key), | |
getString(R.string.pref_location_default)); | |
String units = sharedPreferences.getString(getString(R.string.pref_units_key), | |
getString(R.string.pref_units_metric)); | |
Retrofit retrofit = new Retrofit.Builder() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class SimpleService { | |
public static final String API_URL = "http://api.openweathermap.org/data/2.5/forecast/"; | |
public interface OpenWeatherMap { | |
@GET("daily?mode=json") | |
Call<ApiResponse> getWeather( | |
@Query("q") String city, | |
@Query("units") String units, | |
@Query("cnt") int count, |
NewerOlder