All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gwt.material.design.client.ui.MaterialWeather Maven / Gradle / Ivy

There is a newer version: 2.8.3
Show newest version
package gwt.material.design.client.ui;

/*
 * #%L
 * GwtMaterial
 * %%
 * Copyright (C) 2015 GwtMaterialDesign
 * %%
 * 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.
 * #L%
 */

//@formatter:off

import com.google.gwt.user.client.ui.HTML;

/**
 * Material Weather - used OpenWeatherAPI to get results about location based  weather
 *
 * 

*

UiBinder Usage:

*
 * {@code
 *     
 * }
 * 
*

* * @author kevzlou7979 * @author Ben Dol * @author paulux84 */ //@formatter:on public class MaterialWeather extends MaterialPanel { public MaterialWeather() { super(); HTML html = new HTML("
  • 0

    0

  • 0

  • 0

    0

  • 0
  • 3.9 mph
  • 0 hPa
"); this.getElement().appendChild(html.getElement()); } private String location; private String color; private String name; @Override protected void onLoad() { super.onLoad(); this.name = "weatherContainer"; this.addStyleName(name); this.getElement().setId("weatherContainer"); showWeather(location, name, color); } public String getLocation() { return location; } public void setLocation(String location) { this.location = location; showWeather(location, name, color); } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public static native void showWeather(String location, String div, String color)/*-{ $wnd.jQuery.getJSON( "http://api.openweathermap.org/data/2.5/weather?q=" + location + "&APPID=53455a3a8a8a46135396f0272314f49d", function( data ) { var items = []; var location = data.sys.country + ", " + data.name; var icon = "http://gwt-material.appspot.com/bin/weather/" +data.weather[0].icon + ".png"; var temp = Math.round((data.main.temp - 273.15)* 10 ) / 10; var main = data.weather[0].main; var desc = data.weather[0].description; var humidity = data.main.humidity; var pressure = data.main.pressure; var wind = data.wind.speed; var d = new Date(); var weekday = new Array(7); weekday[0]= "Sunday"; weekday[1] = "Monday"; weekday[2] = "Tuesday"; weekday[3] = "Wednesday"; weekday[4] = "Thursday"; weekday[5] = "Friday"; weekday[6] = "Saturday"; var today = weekday[d.getDay()]; items.push("
  • "+main+"

    "+desc+"

  • "+temp+"

  • "+location+"

    "+today+"

  • invert_colors "+humidity+"%
  • wifi_tethering"+wind+" mph
  • av_timer"+pressure+" hPa
"); $wnd.document.getElementById('weatherContainer').innerHTML = ''; $wnd.jQuery( "
    ", { "class": "my-new-list", html: items.join( "" ) }).appendTo( "." + div ); $wnd.Materialize.showStaggeredList('#weatherPanel'); }); }-*/; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy