Android Audit – good experience
In the last 6 months, I’ve worked on around 10 projects doing the stuff that I hate most: fix other peoples code.
At first, I hated it so so much, but after you spend around 10-20 hours on a bug, and see how beautiful the whole things works after you’re done is just perfect.
What I have
Recently, I got to work on an app that has a TabLayout with 3-4 tabs, each with it’s list of items. The items had subitems as well, so you could expand the main item if you taped on it.
What’s the problem
Very low FPS. To test this, installed TinyDancer, the fps would drop to around 10 when switching tabs and to around 20 when scrolling. As well, the items had some kind of animation that would drop to anywhere between 10 and 20 FPS when played.
Checked the code behind it and saw that a ListView was used with no pattern and that on each bind, there was a findViewById used (which is a pretty expensive operation). To add insult to injury it had a horrible implementation for the on swipe to dismiss item gesture.
Another thing that I found very very strange was that there was only ONE layout.xml file, though I could clearly see two types of cells. As I saw the code, the previous developer, used >>>HTML<<< to style the text size and programatically differentiate views.
How to solve it
Well, first, I decided to use a ViewHolder pattern in the ListView to cache the findViewById call.
Then, I saw that there were some peculiar animations on the list items that would make most phones feel lazy.
But was thinking if I’m still here, might as well implement a RecyclerView to better support multiple kind of views (categories, sub-categories, sub-sub-categories) and have out of the box notification when an item will be dismissed.
By: Adrian Coman