I've got an activity with several instances of a custom View. This custom View is passed an object, and the contents of this object will decide how the View is displayed.
Also, when the View is created, an OnClickListener is added to it. The previously mentioned object is passed on to this onClickListener through a contructor and private variables, and inside the listener I've got a switch statement which will handle the OnClick differently depending on the object-data.
Is there anything fundamentally wrong with my approach? Would it be better to have several OnClickListeners, and add the correct one from the View, instead of evaluating the object inside the OnClickListener, thus reducing the size/memory footprint? I'm guessing all the onClickListeners will be loaded as objects in memory once the activity loads? Maybe I should access the object and context through the view that is passed to onClick instead of passing them as arguments (and duplicating them?), however I'm struggling with acheiving this...
I'm basically looking to optimize CPU and memory usage. The program runs fine as is.