Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincollins committed May 9, 2014
2 parents ae2de93 + e0a3748 commit 7c63be7
Show file tree
Hide file tree
Showing 895 changed files with 28,173 additions and 1,844 deletions.
14 changes: 7 additions & 7 deletions AerisDemo/res/values/aeris_default_values.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<item name="animation_min_speed" format="float" type="dimen">100</item>
<item name="animation_max_speed" format="float" type="dimen">1000</item>
<item name="animation_default_speed" format="float" type="dimen">100</item>
<item name="tile_default_opacity" format="float" type="dimen">.5</item>
<item name="aerismaps_animation_min_speed" format="float" type="dimen">100</item>
<item name="aerismaps_animation_max_speed" format="float" type="dimen">1000</item>
<item name="aerismaps_animation_default_speed" format="float" type="dimen">100</item>
<item name="aerismaps_tile_default_opacity" format="float" type="dimen">.5</item>

<integer name="animation_end_frame_additional_time">1000</integer>
<integer name="camera_change_millis">1500</integer>
<integer name="animation_tiles_to_load">10</integer>
<integer name="aerismaps_animation_end_frame_additional_time">1000</integer>
<integer name="aerismaps_camera_change_millis">1500</integer>
<integer name="aerismaps_animation_tiles_to_load">10</integer>

</resources>
15 changes: 7 additions & 8 deletions AerisDemo/src/com/example/fragment/HeadlessFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.hamweather.aeris.communication.parameter.FilterParameter;
import com.hamweather.aeris.communication.parameter.FromParameter;
import com.hamweather.aeris.communication.parameter.LimitParameter;
import com.hamweather.aeris.communication.parameter.PLimitParamter;
import com.hamweather.aeris.communication.parameter.PLimitParameter;
import com.hamweather.aeris.communication.parameter.PlaceParameter;
import com.hamweather.aeris.communication.parameter.ToParameter;
import com.hamweather.aeris.model.AerisBatchResponse;
Expand Down Expand Up @@ -141,7 +141,7 @@ public void performNearbyObs(AerisProgressListener listener) {
public void performRecentsObs(AerisProgressListener listener) {
AerisRequest request = new AerisRequest(new Endpoint(
EndpointType.OBSERVATIONS_RECENT), Action.CLOSEST,
new PlaceParameter(getActivity()), new PLimitParamter(10));
new PlaceParameter(getActivity()), new PLimitParameter(10));
AerisCommunicationTask task = new AerisCommunicationTask(getActivity(),
this, request);
if (listener != null) {
Expand Down Expand Up @@ -186,13 +186,12 @@ public void performDetailedObservation(AerisProgressListener listener) {
.addParameters(FieldsParameter.initWith("place")));
builder.addEndpoint(new Endpoint(EndpointType.FORECASTS, Action.CLOSEST)
.addParameters(new FilterParameter("daynight"),
new PLimitParamter(2)));
new PLimitParameter(2)));
builder.addEndpoint(new Endpoint(EndpointType.FORECASTS, Action.CLOSEST)
.addParameters(new FilterParameter("3hr"),
new PLimitParamter(4), FieldsParameter.initWith(
ForecastsFields.TEMP_F, ForecastsFields.TEMP_C,
ForecastsFields.ICON,
ForecastsFields.DATETIME_ISO, Fields.INTERVAL)));
.addParameters(new FilterParameter("3hr"), new PLimitParameter(
4), FieldsParameter.initWith(ForecastsFields.TEMP_F,
ForecastsFields.TEMP_C, ForecastsFields.ICON,
ForecastsFields.DATETIME_ISO, Fields.INTERVAL)));
AerisRequest request = builder.build();
BatchCommunicationTask task = new BatchCommunicationTask(getActivity(),
this, request);
Expand Down
135 changes: 104 additions & 31 deletions AerisDemo/src/com/example/fragment/MapFragment.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.fragment;

import android.content.Intent;
import java.util.List;

import android.location.Location;
import android.os.Bundle;
import android.view.LayoutInflater;
Expand All @@ -9,39 +10,44 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.demoaerisproject.R;
import com.example.view.TemperatureInfoData;
import com.example.view.TemperatureWindowAdapter;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.hamweather.aeris.communication.Action;
import com.hamweather.aeris.communication.AerisCallback;
import com.hamweather.aeris.communication.AerisCommunicationTask;
import com.hamweather.aeris.communication.AerisRequest;
import com.hamweather.aeris.communication.Endpoint;
import com.hamweather.aeris.communication.EndpointType;
import com.hamweather.aeris.communication.fields.Fields;
import com.hamweather.aeris.communication.fields.ObservationFields;
import com.hamweather.aeris.communication.parameter.FieldsParameter;
import com.hamweather.aeris.communication.loaders.ObservationsTask;
import com.hamweather.aeris.communication.loaders.ObservationsTaskCallback;
import com.hamweather.aeris.communication.parameter.ParameterBuilder;
import com.hamweather.aeris.communication.parameter.PlaceParameter;
import com.hamweather.aeris.location.LocationHelper;
import com.hamweather.aeris.maps.AerisMapView;
import com.hamweather.aeris.maps.AerisMapView.AerisMapType;
import com.hamweather.aeris.maps.AerisMapView.OnAerisMapLongClickListener;
import com.hamweather.aeris.maps.MapOptionsActivity;
import com.hamweather.aeris.maps.MapViewFragment;
import com.hamweather.aeris.maps.interfaces.OnAerisMapLongClickListener;
import com.hamweather.aeris.maps.interfaces.OnAerisMarkerInfoWindowClickListener;
import com.hamweather.aeris.maps.markers.AerisMarker;
import com.hamweather.aeris.model.AerisError;
import com.hamweather.aeris.model.AerisResponse;
import com.hamweather.aeris.model.Observation;
import com.hamweather.aeris.model.RelativeTo;
import com.hamweather.aeris.response.EarthquakesResponse;
import com.hamweather.aeris.response.FiresResponse;
import com.hamweather.aeris.response.ObservationResponse;
import com.hamweather.aeris.response.StormCellResponse;
import com.hamweather.aeris.response.StormReportsResponse;

public class MapFragment extends MapViewFragment implements
OnAerisMapLongClickListener, AerisCallback {
public static final int OPTIONS_ACTIVITY = 1025;
OnAerisMapLongClickListener, AerisCallback, ObservationsTaskCallback,
OnAerisMarkerInfoWindowClickListener {
private LocationHelper locHelper;
private Marker marker;
private TemperatureWindowAdapter infoAdapter;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Expand All @@ -63,8 +69,14 @@ private void initMap() {
Location myLocation = locHelper.getCurrentLocation();
mapView.moveToLocation(myLocation, 7);
mapView.setOnAerisMapLongClickListener(this);
mapView.getMap().setInfoWindowAdapter(
new TemperatureWindowAdapter(getActivity()));

// setup the custom info window adapter to use
infoAdapter = new TemperatureWindowAdapter(getActivity());
mapView.addWindowInfoAdapter(infoAdapter);

// setup doing something when a user presses an info window
// from the Aeris Point Data.
mapView.setOnAerisWindowClickListener(this);

}

Expand All @@ -77,8 +89,7 @@ private void initMap() {
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.menu_weather_layers) {
this.startActivityForResult(new Intent(getActivity(),
MapOptionsActivity.class), OPTIONS_ACTIVITY);
mapView.startAerisMapOptionsActivity(getActivity());
return false;
} else {
return super.onOptionsItemSelected(item);
Expand Down Expand Up @@ -111,15 +122,23 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
*/
@Override
public void onMapLongClick(double lat, double longitude) {
AerisRequest request = new AerisRequest(new Endpoint(
EndpointType.OBSERVATIONS), Action.CLOSEST, new PlaceParameter(
lat, longitude), FieldsParameter.initWith(
ObservationFields.ICON, ObservationFields.TEMP_C,
ObservationFields.TEMP_F, Fields.RELATIVE_TO));
AerisCommunicationTask task = new AerisCommunicationTask(getActivity(),
this, request);
// AerisRequest request = new AerisRequest(new Endpoint(
// EndpointType.OBSERVATIONS), Action.CLOSEST, new PlaceParameter(
// lat, longitude), FieldsParameter.initWith(
// ObservationFields.ICON, ObservationFields.TEMP_C,
// ObservationFields.TEMP_F, Fields.RELATIVE_TO));
// AerisCommunicationTask task = new
// AerisCommunicationTask(getActivity(),
// this, request);
//
// task.execute();

task.execute();
// the above using a specific object loader
ParameterBuilder builder = new ParameterBuilder().withFields(
ObservationFields.ICON, ObservationFields.TEMP_C,
ObservationFields.TEMP_F, Fields.RELATIVE_TO);
ObservationsTask task = new ObservationsTask(getActivity(), this);
task.requestClosest(new PlaceParameter(lat, longitude), builder.build());
}

/*
Expand All @@ -138,19 +157,73 @@ public void onResult(EndpointType type, AerisResponse response) {
response.getFirstResponse());
Observation ob = obResponse.getObservation();
RelativeTo relativeTo = obResponse.getRelativeTo();
MarkerOptions options = new MarkerOptions()
.position(new LatLng(relativeTo.lat, relativeTo.lon))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.map_indicator_blank))
.title(ob.icon).snippet(String.valueOf(ob.tempF))
.anchor(.5f, .5f);
if (marker != null) {
marker.remove();
}
marker = mapView.getMap().addMarker(options);
TemperatureInfoData data = new TemperatureInfoData(ob.icon,
String.valueOf(ob.tempF));
marker = infoAdapter.addGoogleMarker(mapView.getMap(),
relativeTo.lat, relativeTo.lon, BitmapDescriptorFactory
.fromResource(R.drawable.map_indicator_blank),
data);
marker.showInfoWindow();
}
}
}

@Override
public void earthquakeWindowPressed(EarthquakesResponse response,
AerisMarker marker) {
// do something with the response data.
Toast.makeText(getActivity(), "Earthquake pressed!", Toast.LENGTH_SHORT)
.show();
}

@Override
public void stormReportsWindowPressed(StormReportsResponse response,
AerisMarker marker) {
// do something with the response data.
Toast.makeText(getActivity(), "Storm Report pressed!",
Toast.LENGTH_SHORT).show();
}

@Override
public void stormCellsWindowPressed(StormCellResponse response,
AerisMarker marker) {
// do something with the response data.
Toast.makeText(getActivity(), "Storm Cell pressed!", Toast.LENGTH_SHORT)
.show();
}

@Override
public void wildfireWindowPressed(FiresResponse response, AerisMarker marker) {
// do something with the response data.
Toast.makeText(getActivity(), "Wildfire pressed!", Toast.LENGTH_SHORT)
.show();

}

@Override
public void onObservationsFailed(AerisError arg0) {
Toast.makeText(getActivity(),
"Failed to load observation at that point", Toast.LENGTH_SHORT)
.show();

}

@Override
public void onObservationsLoaded(List<ObservationResponse> responses) {
ObservationResponse obResponse = responses.get(0);
Observation ob = obResponse.getObservation();
RelativeTo relativeTo = obResponse.getRelativeTo();
if (marker != null) {
marker.remove();
}
TemperatureInfoData data = new TemperatureInfoData(ob.icon,
String.valueOf(ob.tempF));
marker = infoAdapter.addGoogleMarker(mapView.getMap(), relativeTo.lat,
relativeTo.lon, BitmapDescriptorFactory
.fromResource(R.drawable.map_indicator_blank), data);
marker.showInfoWindow();
}
}
4 changes: 2 additions & 2 deletions AerisDemo/src/com/example/service/NotificationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.hamweather.aeris.communication.fields.ObservationFields;
import com.hamweather.aeris.communication.parameter.FieldsParameter;
import com.hamweather.aeris.communication.parameter.FilterParameter;
import com.hamweather.aeris.communication.parameter.PLimitParamter;
import com.hamweather.aeris.communication.parameter.PLimitParameter;
import com.hamweather.aeris.communication.parameter.PlaceParameter;
import com.hamweather.aeris.model.AerisBatchResponse;
import com.hamweather.aeris.response.ForecastsResponse;
Expand Down Expand Up @@ -43,7 +43,7 @@ protected void onHandleIntent(Intent intent) {
ForecastsFields.IS_DAY, ForecastsFields.MAX_TEMP_F,
ForecastsFields.MIN_TEMP_F, ForecastsFields.MIN_TEMP_C,
ForecastsFields.MAX_TEMP_C), new FilterParameter(
"daynight"), new PLimitParamter(2)));
"daynight"), new PLimitParameter(2)));
AerisRequest request = builder.build();
BatchCommunicationTask task = new BatchCommunicationTask(this, request);
AerisBatchResponse retval = task.executeSyncTask();
Expand Down
12 changes: 12 additions & 0 deletions AerisDemo/src/com/example/view/TemperatureInfoData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.view;


public class TemperatureInfoData {
public String icon;
public String temperature;

public TemperatureInfoData(String icon, String temperature) {
this.icon = icon;
this.temperature = temperature;
}
}
43 changes: 18 additions & 25 deletions AerisDemo/src/com/example/view/TemperatureWindowAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import android.widget.TextView;

import com.example.demoaerisproject.R;
import com.google.android.gms.maps.GoogleMap.InfoWindowAdapter;
import com.google.android.gms.maps.model.Marker;
import com.hamweather.aeris.maps.AerisMarkerWindow;
import com.hamweather.aeris.util.FileUtil;
import com.hamweather.aeris.util.WeatherUtil;

Expand All @@ -17,7 +17,7 @@
* @author Ben Collins
*
*/
public class TemperatureWindowAdapter implements InfoWindowAdapter {
public class TemperatureWindowAdapter extends AerisMarkerWindow {
/**
* Used to inflate the view.
*/
Expand All @@ -38,33 +38,26 @@ public TemperatureWindowAdapter(Context context) {
this.context = context;
}

/*
* (non-Javadoc)
*
* @see
* com.google.android.gms.maps.GoogleMap.InfoWindowAdapter#getInfoContents
* (com.google.android.gms.maps.model.Marker)
*/
@Override
public View getInfoContents(Marker marker) {
return null;
}

/*
* (non-Javadoc)
*
* @see
* com.google.android.gms.maps.GoogleMap.InfoWindowAdapter#getInfoWindow
* (com.google.android.gms.maps.model.Marker)
*/
@Override
public View getInfoWindow(Marker arg0) {
public View getView() {
TextView view = (TextView) inflater.inflate(
R.layout.dialog_aeris_windowadapter, null);
view.setText(WeatherUtil.appendDegree(arg0.getSnippet()));
int drawable = FileUtil.getDrawableByName(arg0.getTitle(), context);
view.setCompoundDrawablesWithIntrinsicBounds(drawable, 0, 0, 0);
return view;
}

@Override
public void fillView(View view, Marker marker) {
TextView textView = (TextView) view;
TemperatureInfoData data = (TemperatureInfoData) getData(marker);
textView.setText(WeatherUtil.appendDegree(data.temperature));
textView.setCompoundDrawablesWithIntrinsicBounds(
FileUtil.getDrawableByName(data.icon, context), 0, 0, 0);

}

@Override
public void onInfoWindowPressed(Marker marker) {

}

}
Binary file modified AerisMapsLibrary-release/libs/aeris-android-lib-0.9.6.jar
Binary file not shown.
Loading

0 comments on commit 7c63be7

Please sign in to comment.