You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
The second one, for Phone, using the "android:configChanges" attribute (to avoid application restart on orientation change).
Both will share the same code, excepted the 2nd one which will handle "onConfigurationChange" by itself.
Since we can't duplicate activities in the Manifest, my plan was to extends the first one :
class MyPhoneActivity extends MyTabletActivity_ { ... }
BUT, using @EActivity on MyTabletActivity, the generated class is final!
Is there any workaround possible, that's really frustrating!
(To those asking why I'm not using the same activity for both tablets and phone : the phone activity has the same layout in both portrait and landscape, while the tablet activity have different one. Thus, application restarting is useless concerning phone. Even more considering that handling configuration change is the ONLY way to keep webviews state.)
If you make MyTabletActivity abstract, then MyTabletActivity_ will not be final :) .
Won't be perfect for your use case though, because you'd want to create an instance of MyTabletActivity too. I guess you could have an empty subclass of MyTabletActivity_, but it's not nice.
Anyway : inheritance is usually a sign that's something wrong :) . You could extract the common behavior in a fragment or in an @EBean, and use activities that have nothing in common.
Regarding webview state handling, you are quite right. Webviews are meant to be reloaded on configuration change.
Sounds like an interesting workaround, will try that.
Concerning your suggestions, I'm already using fragments, but there's still some things like @OptionsItems and @ViewById/@FragmentById that can't be merged into an @ebean, leading to duplicate common code in both activities. Am I right?
Activity
pyricau commentedon Jul 6, 2012
If you make
MyTabletActivityabstract, thenMyTabletActivity_will not be final :) .Won't be perfect for your use case though, because you'd want to create an instance of
MyTabletActivitytoo. I guess you could have an empty subclass ofMyTabletActivity_, but it's not nice.Anyway : inheritance is usually a sign that's something wrong :) . You could extract the common behavior in a fragment or in an
@EBean, and use activities that have nothing in common.Regarding webview state handling, you are quite right. Webviews are meant to be reloaded on configuration change.
renaudcerrato commentedon Jul 6, 2012
Sounds like an interesting workaround, will try that.
Concerning your suggestions, I'm already using fragments, but there's still some things like @OptionsItems and @ViewById/@FragmentById that can't be merged into an @ebean, leading to duplicate common code in both activities. Am I right?
mathieuboniface commentedon Nov 24, 2012
Already fixed by #283