Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Log removal and using Timber
Browse files Browse the repository at this point in the history
  • Loading branch information
langsmith committed Jan 31, 2019
1 parent 0becbb4 commit daacb10
Show file tree
Hide file tree
Showing 31 changed files with 102 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import java.io.InputStream;

import timber.log.Timber;

import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.geometryType;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
Expand Down Expand Up @@ -177,7 +179,7 @@ private String loadGeoJsonFromAsset(String filename) {
return new String(buffer, "UTF-8");

} catch (Exception exception) {
Log.e("BathymetryActivity", "Exception Loading GeoJSON: " + exception.toString());
Timber.e("Exception Loading GeoJSON: %s", exception.toString());
exception.printStackTrace();
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.mapbox.mapboxandroiddemo.R;
import com.mapbox.mapboxsdk.Mapbox;
Expand All @@ -25,6 +24,8 @@
import java.lang.ref.WeakReference;
import java.util.Scanner;

import timber.log.Timber;

import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.match;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgba;
Expand Down Expand Up @@ -143,7 +144,7 @@ protected Expression.Stop[] doInBackground(Void... voids) {
return stops;
}
} catch (Exception exception) {
Log.d("JsonVectorMixActivity", "Exception Loading GeoJSON: " + exception.toString());
Timber.d("Exception Loading GeoJSON: %s", exception.toString());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;

import com.mapbox.mapboxandroiddemo.R;
Expand All @@ -26,6 +25,8 @@
import java.net.MalformedURLException;
import java.net.URL;

import timber.log.Timber;

import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
import static com.mapbox.mapboxsdk.style.expressions.Expression.division;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
Expand Down Expand Up @@ -156,7 +157,7 @@ private void addClusteredGeoJsonSource(@NonNull Style loadedMapStyle) {
)
);
} catch (MalformedURLException malformedUrlException) {
Log.e("dataClusterActivity", "Check the URL " + malformedUrlException.getMessage());
Timber.e("Check the URL %s", malformedUrlException.getMessage());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.mapbox.mapboxandroiddemo.R;
import com.mapbox.mapboxsdk.Mapbox;
Expand All @@ -20,6 +19,8 @@
import java.net.MalformedURLException;
import java.net.URL;

import timber.log.Timber;

import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.toNumber;
Expand Down Expand Up @@ -76,7 +77,7 @@ private void addClusteredGeoJsonSource(@NonNull Style loadedMapStyle) {
)
);
} catch (MalformedURLException malformedUrlException) {
Log.e("CreateHotspotsActivity", "Check the URL " + malformedUrlException.getMessage());
Timber.e("Check the URL %s", malformedUrlException.getMessage());
}

// Use the earthquakes source to create four layers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import java.lang.ref.WeakReference;
import java.util.Scanner;

import timber.log.Timber;

/**
* Draw a polyline by parsing a GeoJSON file with the Mapbox Android SDK.
*/
public class DrawGeojsonLineActivity extends AppCompatActivity implements OnMapReadyCallback {

private static final String TAG = "DrawGeojsonLineActivity";

private MapView mapView;
private MapboxMap mapboxMap;

Expand Down Expand Up @@ -98,7 +98,7 @@ protected FeatureCollection doInBackground(Void... voids) {
return FeatureCollection.fromJson(convertStreamToString(inputStream));
}
} catch (Exception exception) {
Log.e(TAG, "Exception Loading GeoJSON: " + exception.toString());
Timber.e("Exception Loading GeoJSON: %s" , exception.toString());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import java.util.List;
import java.util.Scanner;

import timber.log.Timber;

import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
import static com.mapbox.mapboxsdk.style.expressions.Expression.concat;
import static com.mapbox.mapboxsdk.style.expressions.Expression.division;
Expand Down Expand Up @@ -208,7 +210,7 @@ protected FeatureCollection doInBackground(Void... voids) {
return featureCollection;
}
} catch (Exception exception) {
Log.d("ExpressionIntegration", "Exception Loading GeoJSON: " + exception.toString());
Timber.d("Exception Loading GeoJSON: %s", exception.toString());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.net.MalformedURLException;
import java.net.URL;

import timber.log.Timber;

import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
import static com.mapbox.mapboxsdk.style.expressions.Expression.division;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
Expand Down Expand Up @@ -97,7 +99,7 @@ private void addClusteredGeoJsonSource(@NonNull Style loadedMapStyle) {
)
);
} catch (MalformedURLException malformedUrlException) {
Log.e("dataClusterActivity", "Check the URL " + malformedUrlException.getMessage());
Timber.e("Check the URL %s" , malformedUrlException.getMessage());
}

//Creating a SymbolLayer icon layer for single data/icon points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import com.mapbox.mapboxandroiddemo.R;
Expand All @@ -21,6 +20,8 @@

import java.io.InputStream;

import timber.log.Timber;

import static com.mapbox.mapboxsdk.style.expressions.Expression.heatmapDensity;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.linear;
Expand Down Expand Up @@ -423,7 +424,7 @@ private String loadGeoJsonFromAsset(String filename) {
return new String(buffer, "UTF-8");

} catch (Exception exception) {
Log.e("MultipleHeatmapStyling", "Exception loading GeoJSON: " + exception.toString());
Timber.e("Exception loading GeoJSON: %s", exception.toString());
exception.printStackTrace();
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.mapbox.mapboxandroiddemo.R;
import com.mapbox.mapboxsdk.Mapbox;
Expand All @@ -18,6 +17,8 @@

import java.io.InputStream;

import timber.log.Timber;

import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.match;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
Expand Down Expand Up @@ -124,7 +125,7 @@ private String loadGeoJsonFromAsset(String filename) {
return new String(buffer, "UTF-8");

} catch (Exception exception) {
Log.e("StyleLineActivity", "Exception Loading GeoJSON: " + exception.toString());
Timber.e("Exception Loading GeoJSON: %s", exception.toString());
exception.printStackTrace();
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

Expand Down Expand Up @@ -152,51 +151,39 @@ public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.san_francisco:
goToNewLocation(37.784282779035216, -122.4232292175293);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: san_francisco");
return true;
case R.id.los_angeles:
goToNewLocation(34.04412546508576, -118.28636169433594);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: los_angeles");
return true;
case R.id.seattle:
goToNewLocation(47.60651025683697, -122.33327865600585);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: seattle");
return true;
case R.id.new_orleans:
goToNewLocation(29.946159058399612, -90.10042190551758);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: new_orleans");
return true;
case R.id.chicago:
goToNewLocation(41.87531293759582, -87.6240348815918);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: chicago");
return true;
case R.id.philadelphia:
goToNewLocation(39.95370120254379, -75.1626205444336);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: philadelphia");
return true;
case R.id.new_york:
goToNewLocation(40.72228267283148, -73.99772644042969);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: new york");
return true;
case R.id.atlanta:
goToNewLocation(33.74910736130734, -84.39079284667969);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: atlanta");
return true;
case R.id.portland:
goToNewLocation(45.522104713562825, -122.67179489135742);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: portland");
return true;
case R.id.denver:
goToNewLocation(39.74428621972816, -104.99565124511719);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: denver");
return true;
case R.id.minneapolis:
goToNewLocation(44.969656023708175, -93.26637268066406);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: minneapolis");
return true;
case R.id.miami:
goToNewLocation(25.773846629676616, -80.19624710083008);
Log.d("PopDensityExtrusion", "onOptionsItemSelected: miami");
return true;
case android.R.id.home:
finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;

import com.mapbox.mapboxandroiddemo.R;
Expand All @@ -22,6 +21,8 @@
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.plugins.building.BuildingPlugin;

import timber.log.Timber;

/**
* Change the camera's bearing and tilt based on device movement while viewing building extrusions
*/
Expand Down Expand Up @@ -170,13 +171,13 @@ private void registerSensorListeners() {
if (sensorControl.getGyro() != null) {
sensorManager.registerListener(this, sensorControl.getGyro(), sensorEventDeliveryRate);
} else {
Log.d("RotationExtrusion", "Whoops, no accelerometer sensor");
Timber.d("Whoops, no accelerometer sensor");
Toast.makeText(this, R.string.no_accelerometer, Toast.LENGTH_SHORT).show();
}
if (sensorControl.getMagnetic() != null) {
sensorManager.registerListener(this, sensorControl.getMagnetic(), sensorEventDeliveryRate);
} else {
Log.d("RotationExtrusion", "Whoops, no magnetic sensor");
Timber.d("Whoops, no magnetic sensor");
Toast.makeText(this, R.string.no_magnetic, Toast.LENGTH_SHORT).show();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public class DirectionsActivity extends AppCompatActivity {
private static final String ICON_SOURCE_ID = "icon-source-id";
private static final String RED_PIN_ICON_ID = "red-pin-icon-id";
private MapView mapView;
private MapboxMap mapboxMap;
private DirectionsRoute currentRoute;
private MapboxDirections client;
private Point origin;
Expand All @@ -75,7 +74,6 @@ protected void onCreate(Bundle savedInstanceState) {
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
DirectionsActivity.this.mapboxMap = mapboxMap;

mapboxMap.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

Expand All @@ -28,6 +27,7 @@
import java.net.URL;

import okhttp3.HttpUrl;
import timber.log.Timber;

import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.geometryType;
Expand Down Expand Up @@ -190,7 +190,7 @@ private void addDataToMap(@NonNull Style style, @NonNull LatLng mapClickPoint) {
}

} catch (Throwable throwable) {
Log.e("IsochroneActivity", "Couldn't add GeoJsonSource to map", throwable);
Timber.e(throwable, "Couldn't add GeoJsonSource to map");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.mapbox.api.matching.v5.MapboxMapMatching;
import com.mapbox.api.matching.v5.models.MapMatchingMatching;
Expand Down Expand Up @@ -35,14 +34,14 @@
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import timber.log.Timber;

import static com.mapbox.api.directions.v5.DirectionsCriteria.PROFILE_DRIVING;
import static com.mapbox.core.constants.Constants.PRECISION_6;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth;


/**
* Match raw GPS points to the map so they align with roads and pathways.
*/
Expand Down Expand Up @@ -139,7 +138,7 @@ protected FeatureCollection doInBackground(Void... voids) {
return FeatureCollection.fromJson(convertStreamToString(inputStream));
}
} catch (Exception exception) {
Log.e(TAG, "Exception Loading GeoJSON: " + exception.toString());
Timber.e("Exception Loading GeoJSON: %s", exception.toString());
}
return null;
}
Expand Down Expand Up @@ -202,17 +201,17 @@ public void onResponse(@NonNull Call<MapMatchingResponse> call,
drawMapMatched(Objects.requireNonNull(response.body()).matchings());
} else {
// If the response code does not response "OK" an error has occurred.
Log.e(TAG, "MapboxMapMatching failed with " + response.code());
Timber.e("MapboxMapMatching failed with %s", response.code());
}
}

@Override
public void onFailure(Call<MapMatchingResponse> call, Throwable throwable) {
Log.e(TAG, "MapboxMapMatching error: ", throwable);
Timber.e(throwable, "MapboxMapMatching error");
}
});
} catch (ServicesException servicesException) {
Log.e(TAG, "MapboxMapMatching error: ", servicesException);
Timber.e(servicesException, "MapboxMapMatching error");
}
}

Expand Down
Loading

0 comments on commit daacb10

Please sign in to comment.