M android/src/com/gindin/util/LogUtils.java +29 -14
@@ 11,8 11,7 @@ import com.flurry.android.FlurryAgent;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
import com.gindin.zmanim.android.location.ZmanimLocationManager;
@@ 54,7 53,7 @@ public class LogUtils {
) {
String where = ( null == t ? "null thread" : t.getName() );
- logError( where, "UEH", e );
+ logError( "UEH", where, e );
}
}
);
@@ 80,12 79,22 @@ public class LogUtils {
LogUtils.locationManager = locationManager;
}
-
+
public static void logError(
String where,
String message,
Throwable error
) {
+ //noinspection NullArgumentToVariableArgMethod
+ logError( where, message, error, null );
+ }
+
+ public static void logError(
+ String where,
+ String message,
+ Throwable error,
+ Pair<String, String>... moreInfo
+ ) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter( sw );
@@ 107,20 116,26 @@ public class LogUtils {
curLocation = "?";
}
- if ( !Version.isDevelopment() ) {
+ if ( Version.isDevelopment() ) {
+ Log.e( where, "Msg: " + message + "\nLocation: " + curLocation + "\nStack: " + stackTrace );
+ }
+ else {
+
+ List<Pair<String,String>> messages = new ArrayList<Pair<String, String>>();
+ messages.add( new Pair<String, String>( "Where", where ) );
+ messages.add( new Pair<String, String>( "Message", message ) );
+ messages.add( new Pair<String, String>( "Location", curLocation ) );
+ messages.add( new Pair<String, String>( "Stack", stackTrace ) );
+ if ( null != moreInfo ) {
+ Collections.addAll( messages, moreInfo );
+ }
//noinspection unchecked
- logEvent( "Error",
- new Pair<String, String>( "Where", where ),
- new Pair<String, String>( "Message", message ),
- new Pair<String, String>( "Location", curLocation ),
- new Pair<String, String>( "Stack", stackTrace )
- );
-
+ logEvent( "Error", messages.toArray( new Pair[ messages.size() ] ) );
+
FlurryAgent.onError( where, message, "" );
}
- Log.e( where, message );
}
@@ 155,8 170,8 @@ public class LogUtils {
String cleaned;
cleaned = message.replace( "com.gindin.zmanim.android.zmanList", "c.g.z.a.z" );
+ cleaned = cleaned.replace( "com.gindin.zmanim.android.location", "c.g.z.a.l" );
cleaned = cleaned.replace( "com.gindin.zmanim.android", "c.g.z.a" );
- cleaned = cleaned.replace( "com.gindin.zmanim.android.location", "c.g.z.a.l" );
cleaned = cleaned.replace( "com.gindin.zmanim.calendar", "c.g.z.c" );
cleaned = cleaned.replace( "com.gindin.zmanim.times", "c.g.z.t" );
cleaned = cleaned.replace( "com.gindin.zmanim", "c.g.z" );
M android/src/com/gindin/zmanim/android/AppUpgrader.java +6 -1
@@ 7,6 7,7 @@ package com.gindin.zmanim.android;
import android.content.Context;
import android.content.SharedPreferences;
import com.gindin.util.LogUtils;
+import com.gindin.util.Pair;
import com.gindin.util.Version;
import com.gindin.zmanim.android.prefs.PersonalPrefsManager;
import com.gindin.zmanim.android.prefs.ZmanimPrefs;
@@ 39,7 40,11 @@ class AppUpgrader {
zmanimSelectionPrefsManager.onHandleUpgrade( thisCodeVersion, lastKnownCodeVersion );
}
catch ( Throwable e ) {
- LogUtils.logError( "doUpgrade", "ver: " + thisCodeVersion + " old: " + lastKnownCodeVersion, e );
+ //noinspection unchecked
+ LogUtils.logError( "doUpgrade", "", e,
+ new Pair<String, String>( "ver", Integer.toString( thisCodeVersion ) ),
+ new Pair<String, String>( "old", Integer.toString( lastKnownCodeVersion ) )
+ );
}
}
M android/src/com/gindin/zmanim/android/location/LocationProvider.java +6 -0
@@ 14,6 14,7 @@ import android.os.Bundle;
import com.gindin.util.LogUtils;
import com.gindin.util.Version;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ 231,6 232,11 @@ abstract class LocationProvider {
address = null;
}
}
+ catch ( IOException ioe ) {
+ // Docs for Geocoder.getFromLocation say this happens when there's no network connectivity, or
+ // there's some other I/O error. In any case, it can happen...
+ address = null;
+ }
catch ( Exception e ) {
address = null;
LogUtils.logError( "LP::lookupLocationName", "", e );
M android/src/com/gindin/zmanim/android/location/StaticLocationProvider.java +6 -0
@@ 13,6 13,7 @@ import android.os.Bundle;
import com.gindin.util.LogUtils;
import com.gindin.zmanim.android.prefs.LocationProviders;
+import java.io.IOException;
import java.util.List;
/**
@@ 80,6 81,11 @@ class StaticLocationProvider
try {
return geocoder.getFromLocationName( places[ 0 ], 5 );
}
+ catch ( IOException ioe ) {
+ // Docs for Geocoder.getFromLocationName say this happens when there's no network connectivity, or
+ // there's some other I/O error. In any case, it can happen...
+ return null;
+ }
catch ( Exception e ) {
LogUtils.logError( "SLP::updateLocationFromPlace", "", e );
return null;
M android/src/com/gindin/zmanim/android/location/ZmanimLocationManager.java +5 -2
@@ 305,8 305,11 @@ public class ZmanimLocationManager {
private void clearLocationFieldListeners() {
- locationField.setOnClickListener( null );
- locationField.setOnLongClickListener( null );
+ // Can happen that we get shutdown before we get a fix and really have an opportunity to get going...
+ if ( null != locationField ) {
+ locationField.setOnClickListener( null );
+ locationField.setOnLongClickListener( null );
+ }
}
M android/src/com/gindin/zmanim/android/zmanList/ZmanRowWrapper.java +5 -1
@@ 8,6 8,7 @@ import android.os.AsyncTask;
import android.view.View;
import android.widget.TextView;
import com.gindin.util.LogUtils;
+import com.gindin.util.Pair;
import com.gindin.zmanim.android.R;
import com.gindin.zmanim.calendar.HebrewZmanimCalendar;
import com.gindin.zmanim.times.Zman;
@@ 96,7 97,10 @@ public abstract class ZmanRowWrapper {
}
catch ( Exception e ) {
final Zman zman = zmans[ 0 ];
- LogUtils.logError( "doInBackground", "Format zman: " + zman.type.name + "; zman: " + zman.name + "; ", e );
+ //noinspection unchecked
+ LogUtils.logError( "ZRW::doInBackground", "Format zman", e,
+ new Pair<String, String>( "type", zman.type.name ),
+ new Pair<String, String>( "zman", zman.name ) );
}
return formatted;