From: gu.martinm@gmail.com Date: Wed, 9 Apr 2014 07:21:51 +0000 (+0200) Subject: Improvements in GUI for google map in weather information app. X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=33c43ad9678f134d5982f87cf1f4f8aedb47c3b8;p=JavaForFun Improvements in GUI for google map in weather information app. --- diff --git a/Android/WeatherInformation/gen/.gitignore b/Android/WeatherInformation/gen/.gitignore new file mode 100644 index 0000000..d4ffb9e --- /dev/null +++ b/Android/WeatherInformation/gen/.gitignore @@ -0,0 +1,2 @@ +/com +/de diff --git a/Android/WeatherInformation/res/drawable-hdpi/ic_action_map.png b/Android/WeatherInformation/res/drawable-hdpi/ic_action_map.png deleted file mode 100644 index 370cf5c..0000000 Binary files a/Android/WeatherInformation/res/drawable-hdpi/ic_action_map.png and /dev/null differ diff --git a/Android/WeatherInformation/res/drawable-hdpi/ic_action_place.png b/Android/WeatherInformation/res/drawable-hdpi/ic_action_place.png new file mode 100644 index 0000000..dba994d Binary files /dev/null and b/Android/WeatherInformation/res/drawable-hdpi/ic_action_place.png differ diff --git a/Android/WeatherInformation/res/drawable-mdpi/ic_action_map.png b/Android/WeatherInformation/res/drawable-mdpi/ic_action_map.png deleted file mode 100644 index 50a9100..0000000 Binary files a/Android/WeatherInformation/res/drawable-mdpi/ic_action_map.png and /dev/null differ diff --git a/Android/WeatherInformation/res/drawable-mdpi/ic_action_place.png b/Android/WeatherInformation/res/drawable-mdpi/ic_action_place.png new file mode 100644 index 0000000..ce055ca Binary files /dev/null and b/Android/WeatherInformation/res/drawable-mdpi/ic_action_place.png differ diff --git a/Android/WeatherInformation/res/drawable-xhdpi/ic_action_map.png b/Android/WeatherInformation/res/drawable-xhdpi/ic_action_map.png deleted file mode 100644 index 537c5a4..0000000 Binary files a/Android/WeatherInformation/res/drawable-xhdpi/ic_action_map.png and /dev/null differ diff --git a/Android/WeatherInformation/res/drawable-xhdpi/ic_action_place.png b/Android/WeatherInformation/res/drawable-xhdpi/ic_action_place.png new file mode 100644 index 0000000..5e93aeb Binary files /dev/null and b/Android/WeatherInformation/res/drawable-xhdpi/ic_action_place.png differ diff --git a/Android/WeatherInformation/res/drawable-xxhdpi/ic_action_map.png b/Android/WeatherInformation/res/drawable-xxhdpi/ic_action_map.png deleted file mode 100644 index ed72ce9..0000000 Binary files a/Android/WeatherInformation/res/drawable-xxhdpi/ic_action_map.png and /dev/null differ diff --git a/Android/WeatherInformation/res/drawable-xxhdpi/ic_action_place.png b/Android/WeatherInformation/res/drawable-xxhdpi/ic_action_place.png new file mode 100644 index 0000000..25623c7 Binary files /dev/null and b/Android/WeatherInformation/res/drawable-xxhdpi/ic_action_place.png differ diff --git a/Android/WeatherInformation/res/menu/weather_main_menu.xml b/Android/WeatherInformation/res/menu/weather_main_menu.xml index 33a8e65..a589c87 100644 --- a/Android/WeatherInformation/res/menu/weather_main_menu.xml +++ b/Android/WeatherInformation/res/menu/weather_main_menu.xml @@ -28,7 +28,7 @@ Language city not found country not found - Downloading remote data + Downloading remote data + Please wait… diff --git a/Android/WeatherInformation/src/de/example/exampletdd/WeatherInformationMapActivity.java b/Android/WeatherInformation/src/de/example/exampletdd/WeatherInformationMapActivity.java index ad67b52..779a243 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/WeatherInformationMapActivity.java +++ b/Android/WeatherInformation/src/de/example/exampletdd/WeatherInformationMapActivity.java @@ -20,9 +20,9 @@ import android.os.Bundle; import android.util.Log; import android.widget.TextView; +import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener; -import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener; import com.google.android.gms.maps.MapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.Marker; @@ -50,13 +50,6 @@ public class WeatherInformationMapActivity extends Activity { this.mMap.setMyLocationEnabled(true); this.mMap.getUiSettings().setCompassEnabled(false); this.mMap.setOnMapLongClickListener(new LongClickListener()); - this.mMap.setOnMarkerClickListener(new MarkerClickListener()); - - } - - @Override - public void onResume() { - super.onResume(); GeocodingData geocodingData = null; try { @@ -75,9 +68,11 @@ public class WeatherInformationMapActivity extends Activity { final LatLng point = new LatLng( geocodingData.getLatitude(), geocodingData.getLongitude()); this.mMap.clear(); - this.mMarker = this.mMap.addMarker(new MarkerOptions().position( - point).draggable( - true)); + this.mMarker = this.mMap.addMarker(new MarkerOptions().position(point).draggable(true)); + + this.mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(point,15)); + this.mMap.animateCamera(CameraUpdateFactory.zoomIn()); + this.mMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null); final TextView cityCountry = (TextView) WeatherInformationMapActivity.this .findViewById(R.id.weather_map_citycountry_data); @@ -128,16 +123,7 @@ public class WeatherInformationMapActivity extends Activity { @Override public void onMapLongClick(final LatLng point) { - if (WeatherInformationMapActivity.this.mMarker == null) { - WeatherInformationMapActivity.this.mMarker = WeatherInformationMapActivity.this.mMap - .addMarker(new MarkerOptions().position(point).draggable( - true)); - } else { - WeatherInformationMapActivity.this.mMarker.setPosition(point); - } - final GeocoderAsyncTask geocoderAsyncTask = new GeocoderAsyncTask(); - geocoderAsyncTask.execute(point.latitude, point.longitude); } } @@ -148,7 +134,8 @@ public class WeatherInformationMapActivity extends Activity { public GeocoderAsyncTask() { this.newFragment = ProgressDialogFragment - .newInstance(R.string.weather_progress_getdata); + .newInstance(R.string.progress_dialog_get_remote_data, + WeatherInformationMapActivity.this.getString(R.string.progress_dialog_generic_message)); } @Override @@ -198,6 +185,7 @@ public class WeatherInformationMapActivity extends Activity { private void onPostExecuteThrowable(final GeocodingData geocodingData) throws FileNotFoundException, IOException { + WeatherInformationMapActivity.this.storeGeocodingDataToFile(geocodingData); final String city = (geocodingData.getCity() == null) ? @@ -206,11 +194,18 @@ public class WeatherInformationMapActivity extends Activity { final String country = (geocodingData.getCountry() == null) ? WeatherInformationMapActivity.this.getString(R.string.country_not_found) : geocodingData.getCountry(); - final TextView cityCountry = (TextView) WeatherInformationMapActivity.this - .findViewById(R.id.weather_map_citycountry_data); - + .findViewById(R.id.weather_map_citycountry_data); cityCountry.setText(city + "," + country); + + final LatLng point = new LatLng(geocodingData.getLatitude(), geocodingData.getLongitude()); + if (WeatherInformationMapActivity.this.mMarker == null) { + WeatherInformationMapActivity.this.mMarker = + WeatherInformationMapActivity.this.mMap.addMarker + (new MarkerOptions().position(point).draggable(true)); + } else { + WeatherInformationMapActivity.this.mMarker.setPosition(point); + } } private GeocodingData getGeocodingData(final double latitude, final double longitude) throws IOException { @@ -234,14 +229,4 @@ public class WeatherInformationMapActivity extends Activity { } } - - private class MarkerClickListener implements OnMarkerClickListener { - - @Override - public boolean onMarkerClick(final Marker marker) { - marker.getPosition(); - return false; - } - - } } diff --git a/Android/WeatherInformation/src/de/example/exampletdd/fragment/WeatherInformationDataFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/WeatherInformationDataFragment.java index efc8657..5d60ecf 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/WeatherInformationDataFragment.java +++ b/Android/WeatherInformation/src/de/example/exampletdd/fragment/WeatherInformationDataFragment.java @@ -210,11 +210,12 @@ public class WeatherInformationDataFragment extends Fragment implements GetWeath entries.set(6, new WeatherDataEntry(this.getString(R.string.text_field_cloudiness), tempFormatter.format(cloudiness))); } - if (weatherData.getIconData() != null) { + if (weatherData.getWeather().getIcon() != null) { final Bitmap icon = BitmapFactory.decodeByteArray( weatherData.getIconData(), 0, weatherData.getIconData().length); - final ImageView imageIcon = (ImageView) this.getActivity().findViewById(R.id.weather_picture); + final ImageView imageIcon = (ImageView) this.getActivity() + .findViewById(R.id.weather_picture); imageIcon.setImageBitmap(icon); } @@ -285,8 +286,10 @@ public class WeatherInformationDataFragment extends Fragment implements GetWeath final WeatherService weatherService) { this.weatherHTTPClient = weatherHTTPClient; this.weatherService = weatherService; - this.newFragment = ProgressDialogFragment - .newInstance(R.string.weather_progress_getdata); + this.newFragment = ProgressDialogFragment.newInstance( + R.string.progress_dialog_get_remote_data, + WeatherInformationDataFragment.this + .getString(R.string.progress_dialog_generic_message)); } @Override