Skip to content
This repository has been archived by the owner on Jan 26, 2018. It is now read-only.

Commit

Permalink
Small style fixes (googlemaps#410)
Browse files Browse the repository at this point in the history
* Removed unused imports

* Comment fixed (no javadoc inside methods)

* Removed unnecessary semicolon

* If expression simplified

* Declaring values as List to avoid castings

* Removed unnecessary casting

* Removed unused imports, Comment fixed (no javadoc inside methods), Declaring type of list

* Internationalization

* Using a constant

* Removed unused resources

* Using ellipsis character

* If to swicth, while to foreach
  • Loading branch information
MarionaDSR authored and stephenmcd committed Jul 26, 2017
1 parent c50a9ce commit 70cbb34
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 59 deletions.
6 changes: 3 additions & 3 deletions demo/res/layout/heatmaps_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Radius"
android:text="@string/button_radius"
android:onClick="changeRadius" />

<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Gradient"
android:text="@string/button_gradient"
android:onClick="changeGradient" />


<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Opacity"
android:text="@string/button_opacity"
android:onClick="changeOpacity" />

</LinearLayout>
Expand Down
8 changes: 4 additions & 4 deletions demo/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Maps Utils Demo</string>
<string name="input_text">Looking for...</string>
<string name="input_text">Looking for</string>
<string name="button_send">Go!</string>
<string name="police_stations">Police Stations in Victoria</string>
<string name="medicare">Medicare Offices</string>
Expand All @@ -10,11 +10,11 @@
<string name="medicare_url">http://data.gov.au/dataset/location-of-medicare-offices/resource/5d38e1be-4011-49c4-8b8b-75405eeb1088</string>
<string name="kml_url">http://googlemaps.github.io/kml-samples/morekml/Polygons/Polygons.Google_Campus.kml</string>
<string name="geojson_url">https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson</string>
<string name="remove">Remove</string>
<string name="add">Add</string>
<string name="visibility">Toggle Vis</string>
<string-array name="heatmaps_datasets_array">
<item>@string/police_stations</item>
<item>@string/medicare</item>
</string-array>
<string name="button_radius">Radius</string>
<string name="button_gradient">Gradient</string>
<string name="button_opacity">Opacity</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

package com.google.maps.android.utils.demo;

import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.LocationSource;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;

import java.util.List;
Expand Down Expand Up @@ -100,6 +101,6 @@ public void setColorFilter(ColorFilter colorFilter) {

@Override
public int getOpacity() {
return 0;
return PixelFormat.UNKNOWN;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected void startDemo() {

List<LatLng> simplifiedLine;

/**
/*
* Simplified lines - increasing the tolerance will result in fewer points in the simplified
* line
*/
Expand Down
6 changes: 1 addition & 5 deletions library/src/com/google/maps/android/PolyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,7 @@ public static List<LatLng> simplify(List<LatLng> poly, double tolerance) {
public static boolean isClosedPolygon(List<LatLng> poly) {
LatLng firstPoint = poly.get(0);
LatLng lastPoint = poly.get(poly.size()-1);
if (firstPoint.equals(lastPoint)) {
return true;
} else {
return false;
}
return firstPoint.equals(lastPoint);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public int getSize() {
@Override
public int hashCode() {
return mClusterItem.hashCode();
};
}

@Override
public boolean equals(Object other) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public String toString() {
@Override
public int hashCode() {
return mCenter.hashCode() + mItems.hashCode();
};
}

@Override
public boolean equals(Object other) {
Expand Down
4 changes: 1 addition & 3 deletions library/src/com/google/maps/android/data/MultiGeometry.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public MultiGeometry(List<? extends Geometry> geometries) {

//convert unknown geometry type (due to GeoJSON types) to Geometry type
ArrayList geometriesList = new ArrayList();
Iterator<? extends Geometry> geometriesIterator = geometries.iterator();
while (geometriesIterator.hasNext()) {
Geometry geometry = geometriesIterator.next();
for (Geometry geometry : geometries) {
geometriesList.add(geometry);
}

Expand Down
29 changes: 15 additions & 14 deletions library/src/com/google/maps/android/data/geojson/GeoJsonParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,21 @@ private static HashMap<String, String> parseProperties(JSONObject properties)
*/
private static Geometry createGeometry(String geometryType, JSONArray geometryArray)
throws JSONException {
if (geometryType.equals(POINT)) {
return createPoint(geometryArray);
} else if (geometryType.equals(MULTIPOINT)) {
return createMultiPoint(geometryArray);
} else if (geometryType.equals(LINESTRING)) {
return createLineString(geometryArray);
} else if (geometryType.equals(MULTILINESTRING)) {
return createMultiLineString(geometryArray);
} else if (geometryType.equals(POLYGON)) {
return createPolygon(geometryArray);
} else if (geometryType.equals(MULTIPOLYGON)) {
return createMultiPolygon(geometryArray);
} else if (geometryType.equals(GEOMETRY_COLLECTION)) {
return createGeometryCollection(geometryArray);
switch (geometryType) {
case POINT:
return createPoint(geometryArray);
case MULTIPOINT:
return createMultiPoint(geometryArray);
case LINESTRING:
return createLineString(geometryArray);
case MULTILINESTRING:
return createMultiLineString(geometryArray);
case POLYGON:
return createPolygon(geometryArray);
case MULTIPOLYGON:
return createMultiPolygon(geometryArray);
case GEOMETRY_COLLECTION:
return createGeometryCollection(geometryArray);
}
return null;
}
Expand Down
5 changes: 1 addition & 4 deletions library/src/com/google/maps/android/data/kml/KmlBoolean.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
*/
public class KmlBoolean {
public static boolean parseBoolean(String text) {
if ("1".equals(text) || "true".equals(text)) {
return true;
}
return false;
return "1".equals(text) || "true".equals(text);
}
}
27 changes: 16 additions & 11 deletions library/src/com/google/maps/android/ui/IconGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,21 @@ public Bitmap makeIcon() {

Canvas canvas = new Canvas(r);

if (mRotation == 0) {
// do nothing
} else if (mRotation == 1) {
canvas.translate(measuredWidth, 0);
canvas.rotate(90);
} else if (mRotation == 2) {
canvas.rotate(180, measuredWidth / 2, measuredHeight / 2);
} else {
canvas.translate(0, measuredHeight);
canvas.rotate(270);
switch (mRotation) {
case 0:
// do nothing
break;
case 1:
canvas.translate(measuredWidth, 0);
canvas.rotate(90);
break;
case 2:
canvas.rotate(180, measuredWidth / 2, measuredHeight / 2);
break;
case 3:
canvas.translate(0, measuredHeight);
canvas.rotate(270);
break;
}
mContainer.draw(canvas);
return r;
Expand All @@ -121,7 +126,7 @@ public Bitmap makeIcon() {
* Sets the child view for the icon.
* <p/>
* If the view contains a {@link TextView} with the id "text", operations such as {@link
* #setTextAppearance} and {@link #makeIcon(String)} will operate upon that {@link TextView}.
* #setTextAppearance} and {@link #makeIcon(CharSequence)} will operate upon that {@link TextView}.
*/
public void setContentView(View contentView) {
mRotationLayout.removeAllViews();
Expand Down
7 changes: 3 additions & 4 deletions library/tests/src/com/google/maps/android/PolyUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import junit.framework.TestCase;

import java.lang.String;
import java.lang.reflect.Array;
import java.util.List;
import java.util.ArrayList;

Expand Down Expand Up @@ -219,7 +218,7 @@ public void testContainsLocation() {
}

public void testSimplify() {
/**
/*
* Polyline
*/
final String LINE = "elfjD~a}uNOnFN~Em@fJv@tEMhGDjDe@hG^nF??@lA?n@IvAC`Ay@A{@DwCA{CF_EC{CEi@PBTFDJBJ?V?n@?D@?A@?@?F?F?LAf@?n@@`@@T@~@FpA?fA?p@?r@?vAH`@OR@^ETFJCLD?JA^?J?P?fAC`B@d@?b@A\\@`@Ad@@\\?`@?f@?V?H?DD@DDBBDBD?D?B?B@B@@@B@B@B@D?D?JAF@H@FCLADBDBDCFAN?b@Af@@x@@";
Expand Down Expand Up @@ -292,7 +291,7 @@ public void testSimplify() {
assertLineLength(line, simplifiedLine);
assertInputUnchanged(line, copy);

/**
/*
* Polygons
*/
// Open triangle
Expand All @@ -307,7 +306,7 @@ public void testSimplify() {

copy = copyList(triangle);
tolerance = 88; // meters
List simplifiedTriangle = PolyUtil.simplify(triangle, tolerance);
List<LatLng> simplifiedTriangle = PolyUtil.simplify(triangle, tolerance);
assertEquals(4, simplifiedTriangle.size());
assertEndPoints(triangle, simplifiedTriangle);
assertSimplifiedPointsFromLine(triangle, simplifiedTriangle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ public void testMulti() {
public void testCollection() {
BiMultiMap<String> map = new BiMultiMap<>();
String key = "foo";
Object values = Arrays.asList("bar", "baz");
List<String> values = Arrays.asList("bar", "baz");
map.put(key, values);
assertEquals(1, map.size());
assertEquals(values, map.get(key));
for (String value : (List<String>) values) {
for (String value : values) {
assertEquals(key, map.getKey(value));
}
map.remove(key);
assertEquals(0, map.size());
for (String value : (List<String>) values) {
for (String value : values) {
assertEquals(null, map.getKey(value));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void testProperty() throws Exception {

public void testNullProperty() throws Exception {
GeoJsonLayer layer = new GeoJsonLayer(null, createFeatureCollection());
GeoJsonFeature feature = (GeoJsonFeature) layer.getFeatures().iterator().next();
GeoJsonFeature feature = layer.getFeatures().iterator().next();
assertTrue(feature.hasProperty("prop0"));
assertNull(feature.getProperty("prop0"));
assertFalse(feature.hasProperty("prop1"));
Expand Down

0 comments on commit 70cbb34

Please sign in to comment.