开发者

How to avoid calling implements at 2 activites?

开发者 https://www.devze.com 2023-03-20 15:07 出处:网络
I have two activities: MainActivity extends ListActivity and Preferences implements BillingController.IConfiguration.

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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消