diff --git a/OkHttpClient/OkHttpClient.aar b/OkHttpClient/OkHttpClient.aar new file mode 100644 index 0000000..000426d --- /dev/null +++ b/OkHttpClient/OkHttpClient.aar Binary files differ diff --git a/OkHttpClient/OkHttpClient.iml b/OkHttpClient/OkHttpClient.iml new file mode 100644 index 0000000..e67c146 --- /dev/null +++ b/OkHttpClient/OkHttpClient.iml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bd52a9..2153eb6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ + parameterList; + + public SimpleOpenWeatherApi(){ + } + + public Weather getCurrentWeather(String cityId){ + return getCurrentWeather(cityId, 3, 1); + } + + public Weather getCurrentWeather(double lat, double lon){ + return getCurrentWeather(lat, lon, 3, 1); + } + + public Weather getCurrentWeather(String cityId, int numDays, int maxCities){ + Weather weather = new Weather(); + //TODO + return weather; + } + + public Weather getCurrentWeather(double lat, double lon, int numDays, int maxCities){ + Weather weather = new Weather(); + //TODO + return weather; + } + + public Weather getHistoricalWeather(String cityId){ + return getHistoricalWeather(cityId, 3, 1); + } + + public Weather getHistoricalWeather(String cityId, int numDays, int maxCities){ + Weather weather = new Weather(); + //TODO + return weather; + } + + public Weather getHistoricalWeather(double lat, double lon){ + return getHistoricalWeather(lat, lon, 3, 1); + } + + public Weather getHistoricalWeather(double lat, double lon, long start, long end){ + String options = String.format("lat=%f&lon=%f&type=hour&start=%d&end=%d", lat, lon, start, end); + Map parameterList = parseUrlToParameterList(HISTORIC_WEATHER_API_URL + "?" + options ); + return addParameterListToWeather(parameterList); + } + + private Map parseUrlToParameterList(String Url){ + Map parameterList = new HashMap<>(); + //TODO + return parameterList; + } + + private Weather addParameterListToWeather(Map parameterList){ + Weather weather = new Weather(); + //TODO + return weather; + } + + private String getParameter(Map parameterList, String key){ + String value = parameterList.get(key); + try { + if(value == null) throw new ParameterNotFoundException(); + } catch (ParameterNotFoundException pnfe){ + pnfe.printStackTrace(); + //TODO + } + return value; + } +} + +class ParameterNotFoundException extends Exception { + public ParameterNotFoundException(){ + + } + + public ParameterNotFoundException(String message){ + super(message); + } +} +/* +{"coord":{"lon":9.05,"lat":48.52},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}] +,"base":"cmc stations","main":{"temp":286.31,"pressure":1019,"humidity":87,"temp_min":282.04,"temp_max":289.26}, +"wind":{"speed":1.5,"deg":140},"clouds":{"all":75},"dt":1443962615,"sys":{"type":1,"id":4891,"message":0.0042, +"country":"DE","sunrise":1443936456,"sunset":1443977789},"id":2820860,"name":"Tuebingen","cod":200} + */ +class Weather { + private double latitude; + private double longitude; + private float temp; + private float minTemp; + private float maxTemp; + private int weatherId; + private float pressure; + private float humidity; + //private ??? wind; TODO + private long time; + private String cityName; + private String country; + private String sunrise; + private String sunset; + public Weather(){ + + } + + public String getSunset() { + return sunset; + } + + public double getLatitude() { + return latitude; + } + + public double getLongitude() { + return longitude; + } + + public float getTemp() { + return temp; + } + + public float getMinTemp() { + return minTemp; + } + + public float getMaxTemp() { + return maxTemp; + } + + public int getWeatherId() { + return weatherId; + } + + public float getPressure() { + return pressure; + } + + public float getHumidity() { + return humidity; + } + + public long getTime() { + return time; + } + + public String getCityName() { + return cityName; + } + + public String getCountry() { + return country; + } + + public String getSunrise() { + return sunrise; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public void setTemp(float temp) { + this.temp = temp; + } + + public void setMinTemp(float minTemp) { + this.minTemp = minTemp; + } + + public void setMaxTemp(float maxTemp) { + this.maxTemp = maxTemp; + } + + public void setWeatherId(int weatherId) { + this.weatherId = weatherId; + } + + public void setPressure(float pressure) { + this.pressure = pressure; + } + + public void setHumidity(float humidity) { + this.humidity = humidity; + } + + public void setTime(long time) { + this.time = time; + } + + public void setCityName(String cityName) { + this.cityName = cityName; + } + + public void setCountry(String country) { + this.country = country; + } + + public void setSunrise(String sunrise) { + this.sunrise = sunrise; + } + + public void setSunset(String sunset) { + this.sunset = sunset; + } +} diff --git a/weatherlib-release/weatherlib-release.aar b/weatherlib-release/weatherlib-release.aar new file mode 100644 index 0000000..4e94ce2 --- /dev/null +++ b/weatherlib-release/weatherlib-release.aar Binary files differ diff --git a/weatherlib-release/weatherlib-release.iml b/weatherlib-release/weatherlib-release.iml new file mode 100644 index 0000000..ce58b34 --- /dev/null +++ b/weatherlib-release/weatherlib-release.iml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/weatherlib/weatherlib.aar b/weatherlib/weatherlib.aar new file mode 100644 index 0000000..5831a5b --- /dev/null +++ b/weatherlib/weatherlib.aar Binary files differ diff --git a/weatherlib/weatherlib.iml b/weatherlib/weatherlib.iml new file mode 100644 index 0000000..95e4ca2 --- /dev/null +++ b/weatherlib/weatherlib.iml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file