Ahh! nice! For some reason I was expecting an actual proxy port! :P So your method looks really good but it's just about the same thing if I create a CustomActivity class extends Activity and overwrite the methods I need to do special things such as checking user pref. I guess both ways can be clean.... I'm guessing ether way will have the same performance...
Thanks again! -Moto On Aug 20, 5:21 pm, TreKing <treking...@gmail.com> wrote: > On Fri, Aug 20, 2010 at 3:58 PM, Moto <medicalsou...@gmail.com> wrote: > > Mmm Activity proxy class? I kind of understand the concept but I'm > > not following well... you have a simple example? > > class ActivityProxy > { > mActivity = null; > > public ActivityProxy(Activity activity) > { > mActivity = activity; > } > > // Do whatever every Activity should do in onCreate > public void onCreate() > { > if (Prefs.runFullScreen) > mActivity->setFullScreen(); > } > > } > > public MyActivity1 : Activity > { > ActivityProxy proxy = new ActivityProxy(this); > > protected void onCreate() > { > proxy->onCreate(); // Now all common code is abstracted here. > ... > } > > } > > public MyActivity2 : Activity > { > ActivityProxy proxy = new ActivityProxy(this); > > protected void onCreate() > { > proxy->onCreate(); // Now all common code is abstracted here. > ... > } > > } > > So your proxy does all the work that you want other Activities the ability > to do, but it's centralized and encapsulated. The tradeoff, of course, being > you need an instance in each Activity. But this is really no different than > the alternative of overriding a base and then overriding all the required > methods. > > This may not be worth it in your simple case, but once your app grows and > you have tons of common code you can't put in a base class, it proves its > worth. > > ------------------------------------------------------------------------------------------------- > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago > transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en