fgoncalves/AlbumSample — pull request #2 by anawara (2014-04-30 10:15:53+00:00)
Title: Assignment for Delivery Hero

Hi,

I've completed all of the following from the assignment:

Q: As you can see we created 1000 dummy entries in our list fragment. For the sake of simplicity let’s keep this dummy data generation, but let’s assume we have a lot more entries in our list. If there’s a way we could optimize our adapter, how would we do it? Please refactor the code as you see fit.

A: For this requirement, I implemented the ViewHolder pattern for the adapter. I also moved the LayoutInflater initialization code to the constructor of the adapter to avoid initializing it every time the getView method is called. Other potential enhancements in a more realistic scenario would be to implement infinite scrolling with pagination

Q: When we open the drawer we can select different sections. You will see “Albums”, “Songs” and “Artists”. However, there’s no contextual information for the user. It doesn’t matter if the drawer is opened or closed, or if a drawer item is clicked, the action bar title is always the same. Let’s change this such that when the drawer is opened we display the name of our app and upon an item selection we display the item’s name

A: Implemented title setting for the action bar according to the loaded fragment and also if the drawer is opened the title is changed to the application's title

Q: Now our application provides more information to the user, but the list always displays the same items. Let’s change our list whenever the user selects another item from the drawer. For the sake of simplicity you can simply create dummy items and change the main header

A: The main header in the lists now reflects Albums, Songs and Artists. The title of the loaded fragment is used as the main header. For the purpose of this example, since we are using one fragment to display different content, the title is passed in as an argument through a bundle. I've also created a newInstance static method in the fragment class to be used by the activity for obtaining new instances of the fragment instead of directly using the constructor.

Q: Now that we have different lists we can focus on the list items. The picture on said items is always the same. Imagine we have a server hosting our pictures. How could we change our current code to support loading these pictures. You don’t need to code the part that interacts with the network, just leave it with stub methods. Please describe your choices in a “readme” file. Please take into consideration performance and usability. We don’t want the user to feel like his/her device is not performing well and we still want to give the user the opportunity to interact with the app.

A: Implemented retrieval of remote images. Created an array of 4 URLs for remote images that are assigned randomly to items in the items creation code fragment. I chose to use the Universal Image Loader library. There are other libraries such as Picasso. However, I have used UIL before in an image centric application and its performance was superb. The library implements in-memory and disk caching and performs very well with a lot of image views.

Q: (BONUS) Adapt the app such that when using a tablet, instead of displaying a list of elements we display a grid with 2 columns.

A: Modified app to use a gridview instead of a listview. If the app is in portrait mode, it will display a list of items (1 row), if the app is in landscape mode, it will display 2 columns, if the app is on a tablet it will display 3 columns.

I've also fixed up some of the code in the assignment (the home button wasn't opening the drawer when clicked)

If there are any questions please let me know and I'll get back to you as soon as I can.

I hope you find my implementation up to your standards.

Best regards,
Ahmed