Closed IanMSpencer closed 7 years ago
Thanks for your suggestion Ian. Since it seems you already got the fix for this issue, could you submit a pull request? If not, could you provide the JSON that is causing the issue, so that we can reproduce it and fix it ourselves? Thanks!
Hi
Haven't yet worked out how to properly use GitHub, had to use a workaround to rebuild the code for my app under Android Studio 2.2 as I don't really understand the gradle system yet.
The problem will only occur if the data includes the average temperature of the activity. To reproduce: 1) Connect to an account where activities have been created using a device that records temperature (e.g. Garmin 800 series) and download an appropriate ride. 2)I think if you add average_temp to the data created in your activity test it will fail when you round trip the data.
The code is simply incomplete, so not a big deal to sort out once you look!
// Get rides from strava AthleteAPI athleteAPI = new AthleteAPI(config); Athlete athlete = athleteAPI.retrieveCurrentAthlete().execute(); ActivityAPI activityAPI = new ActivityAPI(config); int page = 1; List
activity_list = null; do { Log.i(TAG, "doing page " + page); // ** THIS FAILS WITH REAL DATA FROM GARMIN activity_list = activityAPI.listMyActivities().inPage(page) .execute(); // *** ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DecimalFormat df = new DecimalFormat("#.#"); df.setRoundingMode(RoundingMode.HALF_UP);
for (int i = 0; i < activity_list.size(); i++) { ride_array_list.add(activity_list.get(i).getName() + ": " + df.format(activity_list.get(i).getDistance().getMeters() / 1000)); activity_list.get(i).getID(); } page++; } while (activity_list.size() > 0); return ride_array_list;`
Not being unhelpful - just don't know what I'm doing!
Don't worry, I'll try to provide a fix soon. You have provided valuable feedback to discover the issue ;)
Hi Ian, I have just fixed the issue and published version 1.0.1 of our library. Please, update your Gradle build file to check out the new version where this issue is solved.
When downloading activities generated via a Garmin, i.e. fully populated, the Temperature field of Activity causes an error in JSON - OBJECT expected, number received.
I tried fully populating the Temperature class which seems to be a stub using Distance as a model, but the error still occurs.
Then spotted the type adapters - Temperature missing.
Fixes:
Temperature.java
public class Temperature { private float celsiusDegrees; public static Temperature celsiusDegrees(float celsiusDegrees) { return new Temperature(celsiusDegrees); } public Temperature(float celsiusDegrees) { this.celsiusDegrees = celsiusDegrees; }
}
TemperatureTypeAdapter
public class TemperatureTypeAdapter extends TypeAdapter {
}
and register the typeadapter in config.java