Back to project page Sunshine.
The source code is released under:
MIT License
If you think the Android project Sunshine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package me.kalehv.t.sunshine.data; /*from ww w . j a v a2 s . c o m*/ import android.content.ContentUris; import android.net.Uri; import android.provider.BaseColumns; /** * Created by harshadkale on 7/19/14. */ public class WeatherContract { public static final String CONTENT_AUTHORITY = "me.kalehv.t.sunshine.app"; public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY); public static final String PATH_WEATHER = "weather"; public static final String PATH_LOCATION = "location"; /** * TABLE class for storing location information */ public static final class LocationEntry implements BaseColumns { public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_LOCATION).build(); public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + CONTENT_AUTHORITY + "/" +PATH_LOCATION; public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + CONTENT_AUTHORITY + "/" + PATH_LOCATION; /** * TABLE - Location */ public static final String TABLE_NAME = "location"; /** * COLUMN - Location Setting */ public static final String COLUMN_LOCATION_SETTING = "location_setting"; /** * COLUMN - City Name */ public static final String COLUMN_CITY_NAME = "city_name"; /** * COLUMNS - City Longitude and Lattitude */ public static final String COLUMN_COORD_LONG = "coord_long"; public static final String COLUMN_COORD_LAT = "coord_lat"; public static Uri buildLocationUri(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } } /** * TABLE - class for Weather information */ public static final class WeatherEntry implements BaseColumns { public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_WEATHER).build(); public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + CONTENT_AUTHORITY + "/" +PATH_WEATHER; public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + CONTENT_AUTHORITY + "/" + PATH_WEATHER; public static final String TABLE_NAME = "weather"; // Column with the foreign key into the location table. public static final String COLUMN_LOC_KEY = "location_id"; // Date, stored as Text with format yyyy-MM-dd public static final String COLUMN_DATETEXT = "date"; // Weather id as returned by API, to identify the icon to be used public static final String COLUMN_WEATHER_ID = "weather_id"; // Short description and long description of the weather, as provided by API. // e.g "clear" vs "sky is clear". public static final String COLUMN_SHORT_DESC = "short_desc"; // Min and max temperatures for the day (stored as floats) public static final String COLUMN_MIN_TEMP = "min"; public static final String COLUMN_MAX_TEMP = "max"; // Humidity is stored as a float representing percentage public static final String COLUMN_HUMIDITY = "humidity"; // Humidity is stored as a float representing percentage public static final String COLUMN_PRESSURE = "pressure"; // Windspeed is stored as a float representing windspeed mph public static final String COLUMN_WIND_SPEED = "wind"; // Degrees are meteorological degrees (e.g, 0 is north, 180 is south). Stored as floats. public static final String COLUMN_DEGREES = "degrees"; public static Uri buildWeatherUri(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } public static Uri buildWeatherUri(String locationSetting) { return CONTENT_URI.buildUpon().appendPath(locationSetting).build(); } public static Uri buildWeatherLocationWithStartDate(String locationSetting, String startDate) { return CONTENT_URI.buildUpon().appendPath(locationSetting) .appendQueryParameter(COLUMN_DATETEXT, startDate).build(); } public static Uri buildWeatherLocationWithDate(String locationSetting, String date) { return CONTENT_URI.buildUpon().appendPath(locationSetting).appendPath(date).build(); } public static String getLocationSettingFromUri(Uri uri) { return uri.getPathSegments().get(1); } public static String getDateFromUri(Uri uri) { return uri.getPathSegments().get(2); } public static String getStartDateFromUri(Uri uri) { return uri.getQueryParameter(COLUMN_DATETEXT); } } }