ayoola-solomon / mytracks

Automatically exported from code.google.com/p/mytracks
0 stars 0 forks source link

java.lang.NumberFormatException in Integer.parseInt() of DynamicSpeedTrackPathDescriptor #680

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Track stack of this crash:
java.lang.NumberFormatException: unable to parse '' as integer
at java.lang.Integer.parseInt(Integer.java:412)
at java.lang.Integer.parseInt(Integer.java:382)
at com.google.android.apps.mytracks.maps.DynamicSpeedTrackPathDescriptor.void 
onSharedPreferenceChanged(android.content.SharedPreferences,java.lang.String)(MT
:94)
at 
android.app.ContextImpl$SharedPreferencesImpl$EditorImpl.commit(ContextImpl.java
:2885)
at android.preference.Preference.tryCommit(Preference.java:1218)
at android.preference.Preference.persistString(Preference.java:1245)
at android.preference.EditTextPreference.setText(EditTextPreference.java:88)
at 
android.preference.EditTextPreference.onDialogClosed(EditTextPreference.java:142
)
at android.preference.DialogPreference.onDismiss(DialogPreference.java:384)
at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1047)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)

Meet error when execute following statement:
...
    speedMargin = Integer.parseInt(prefs.getString(
        context.getString(R.string.track_color_mode_dynamic_speed_variation_key), "25"));
...

Maybe we need check the value first and then parse it to integer.

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

Please use labels and text to provide additional information.

Original issue reported on code.google.com by youtaol@google.com on 15 Dec 2011 at 8:23

GoogleCodeExporter commented 9 years ago
Meet error when execute following two statements in 
DynamicSpeedTrackPathDescriptor:
...
line:55
    speedMargin = Integer.parseInt(prefs.getString(
        context.getString(R.string.track_color_mode_dynamic_speed_variation_key), "25"));
...

...
 line:93
  speedMargin = 
        Integer.parseInt(
            prefs.getString(
                context.getString(R.string.track_color_mode_dynamic_speed_variation_key), "25"));

...

Original comment by youtaol@google.com on 15 Dec 2011 at 8:29

GoogleCodeExporter commented 9 years ago
You can reproduce this bug by going to
menu->Settings->Display->Color mode->Dynamic thresholds
Percentage->enter an empty string

We should check that the value is not "" before parsing it as an integer.

Original comment by jshih@google.com on 22 Dec 2011 at 1:20

GoogleCodeExporter commented 9 years ago
Hi Sandor:

Can you review
http://code.google.com/r/jshih-mytracks2/source/detail?r=9399fc25c7ce38ea4177795
181cea29a9f368e0c

Original comment by jshih@google.com on 22 Dec 2011 at 1:58

GoogleCodeExporter commented 9 years ago

Original comment by jshih@google.com on 23 Dec 2011 at 8:30