Created
June 23, 2014 18:16
-
-
Save anonymous/d7cab67eb5e0d871e3da to your computer and use it in GitHub Desktop.
Weather Contract with WeatherEntry
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
/* | |
* Copyright (C) 2014 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
package com.example.android.sunshine.app.data; | |
import android.provider.BaseColumns; | |
/** | |
* Defines table and column names for the weather database. | |
*/ | |
public class WeatherContract { | |
/* Inner class that defines the table contents of the weather table */ | |
public static final class WeatherEntry implements BaseColumns { | |
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"; | |
} | |
} |
Comment on COLUMN_PRESSURE and COLUMN_HUMIDITY are equal.
Great clean code!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Comment on
COLUMN_SHORT_DESC
implies aCOLUMN_LONG_DESC
, which is absent.Comments on
COLUMN_PRESSURE
andCOLUMN_DEGREES
are incorrect, likely due to copypasta.