I have the following problem:
I have an abstract Activity class that allows me to call it MyAbstractActivity, which contains code that I would like to reuse (for example: standard connecting tool, common menu items, common initialization code, etc.). Usually I just used it to subclass my specific actions and did with it.
However, I sometimes need to use another supertype, such as ListActivity or MapActivity.
So the question is: how to avoid duplication of this support code inside the Activity if I need to use a different base class?
I came up with a solution based on a decorator pattern like this:
.
However, I see a problem with this approach: What to do with protected methods (e.g. onCreate ())? Should I introduce an additional class "bridge", which makes them public for the purpose of the decorator, in the same way as presented below (starting to look a little byzantine ...)?

Any other way?
I hope I made myself relatively clear. Thank you in advance for any feedback!
PS. Using static utility classes is not a good solution, in my opinion, since it introduces the ability to hard identify programming errors.
source share