Dear Fellow Developers
Need your advice about the architecture design, specifically about the inheritance of custom activities. In my case, there is a necessity to create a music application with the exactly same functionally like the original one but with a different UI and behavior.
Please, hit me whether the approach described below is right or not. I would appreciate your suggestions how to use maximally functionalities of already implemented activities.
I think to inherit my track browser, playlist browser, media playback and etc. activities from the standard ones of the original music player. Then I would need to replace the layout and intercept with appropriate handling some events.
Challenge 1: setContentView sets already the layout inside onCreate of an original activity. I need to call super.onCreate in my onCreate and then call setContentView again. I’ve investigated that it’s possible to call setContentView several times but it’s necessary to instantiate all UI elements each time again. I think that they may be performance and compatibility problems. My suggestion 1: overload setContentView and detect if the instance of the appropriate layout is passed. In case it’s we inflate the activity.
Challenge 2: almost all members are private in original activities but I would need to replace the adapter and may be some broadcast receivers loaded in the original activities. My suggestion 2: again I can overload setListAdapter, registerReceivers and etc. and check what kind of instances they try to load. If the instances are not ones of my classes I would skip loading them otherwise I would load it.
I’m searching a root conception of a big project so I would like to be sure if my thinking is right in advance. Please, point whether I’m not violating conceptions of Android applications design.