afwang / ogame-android-app

Android application for the Ogame web browser game.
GNU General Public License v3.0
2 stars 7 forks source link

Restore XML Pull Parser capabilities #3

Closed afwang closed 9 years ago

afwang commented 9 years ago

I have not touched this project in a long while, but I remember the last time I tested this, the event loading was very very slow on my device. By adding some logs at the right moments, I found a lot of time was spent parsing the HTML responses into DOM trees. Although DOM trees are great for many things, I believe the evidence here shows that they are not well-suited for mobile devices. As such, I have restored the XML pull parsing code that was originally in OgameAgent.

Although pull parsing requires many more lines of code than the clean, simple call to JSoup, the performance benefits are worth it. This commit has also adapted the old pull parsing algorithm to use the static getter in FleetAndResources.

The initialization code for the FleetAndResources HashMap has also been changed to set up the map using very explicit code. Although this is dirty and not a clean way of doing things, it is less error-prone compared to using Reflection.