This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
Context : Android
Problem : There are many "Brands" like mufti , levis , blackberry and so on. Each Brand contains Various categories like Jeans, t-shirts and so on.
As a user i want to select the Brand and then the Category and then want to see the various items in a particular category . These items will be shown in a VIEWPAGER wherein the user can swipe and see various items.
Present Solution : I am using ViewPager and it requires an instance of PagerAdapter which sends the Page in accordance to the position.
I extended PagerAdapter with mine "MyAdapter". MyAdapter class contains various if-else statements which decides the page to send back to "ViewPager" in accordance to the item and category chosen by a user.
So i tried cleaning up my code and ends up as follows
Whoever that was who asked the question about creating 100 adapter classes if you had 100 brands is spot on. The design you have lacks abstraction and is not a very good one. Its seems to me that you only need one Adapter class that can be parameterized with Brand and Category.