Hot answers tagged

2

Technical improvements use albumMap.values() to get a Collection<Album> directly instantiated as list, which supports positional access get(index). So no need for array and filling loop. See Listing 1. use some of Android's ListView interfaces which usually provide a convenient method on their underlying data model like getItemAtPosition(position). ...


1

I changed some local variables and make them static variables, why ? because these are created and destroyed if you use serveral times the method onFling. The main Idea is to improve the performance and decrease the space your method uses. Also I refactorized some pieces of code class MyGestureDetector extends SimpleOnGestureListener { private ...


1

I am not familiar with Android so I don't know how you get albumMap into the click event. Can you get selected Album (album object) into the event? If not.. I assume albumMap is a map between position to Album. If so I suggest the name postion2album. if not please update your post and clarify what this map is. So all you need to do is albumMap[...


1

Hellow K.H. thanks for the answer. I rewrote the code using Dagger 2 for dependency injection and following your advice. Could you take a look at this code and answer a couple of questions: How to correctly pass name to JsonSharedPreferences (Make a setter, make a module that will provide name). Is it correct to select this code as a separate component or ...


1

Why saving reference to Context and then create SharedPreferences each time? There's duplicate code for creating SharedPreferences You could just use context in constructor to create member SharedPreferences to use in your methods. If you want to keep it as it is, at least extract duplicate code into separate method. I am missing null checks. I expect to get ...


Only top voted, non community-wiki answers of a minimum length are eligible