How to avoid calling implements at 2 activites?
I have two activities: MainActivity extends ListActivity
and Preferences implements BillingController.IConfiguration
.
Now I need t开发者_JAVA技巧o call BillingController.someMethod(this)
at MainActivity
. Such call can be made only if MainActivity implements BillingController.IConfiguration
. But this is already implemented at Preferences
class. What can I do to avoid implementing that again?
Make a class that implements BillingController.IConfiguration
and use it inside both MainActivity
and Preferences
to delegate method calls to it.
Do an instance of check.
if (instance instanceof BillingController.IConfiguration) {
((BillingController.IConfiguration)instance).someMethod(this);
}
精彩评论