superdavex / Motoactv_export

Motoactv TCX exporter
http://forum.xda-developers.com/showthread.php?t=1842658
Other
9 stars 8 forks source link

Exception when populating spinner list #4

Open mindlos opened 10 years ago

mindlos commented 10 years ago

In onCreate of MainActivity.java line 171-193 (try-catch), the following query on line 178:

Cursor csum =getContentResolver().query(DataUtil. CONTENT_URI_WORKOUT_ACTIVITY_SUMMARY, null, "workout_activity_id = " + id + " and metric_id = 4",null, null);

can return a "nothing" when encountering a workout summary that has no metric_id of 4. This occurs with workouts like weight lifting and I assume it is because there is no distance. This causes an exception on generation of the spinner items does not complete,

06-16 23:14:27.139 1793 1793 D sd_motoactv_export: Error loading activities:android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0

hence workouts after the exception won't show in the spinner and cannot be manually exported.

Either there has to nested try catch or at test for a "good" csum after the query so that more items can be processed by the while loop and get added to the spinner. There isn't a big issue with ignoring workouts without distance as a solution and has the least impact to the rest of the code.