Title: Add @RootFragment annotation for @EBean · Issue #1636 · androidannotations/androidannotations · GitHub
Open Graph Title: Add @RootFragment annotation for @EBean · Issue #1636 · androidannotations/androidannotations
X Title: Add @RootFragment annotation for @EBean · Issue #1636 · androidannotations/androidannotations
Description: Hi! Currently, the only way to access the parent Fragment in an @EBean is by writing a setter in the bean manually, or by making a @FragmentById/@FragmentByTag public in the @RootContextannotated Activity. The code is not that beautiful,...
Open Graph Description: Hi! Currently, the only way to access the parent Fragment in an @EBean is by writing a setter in the bean manually, or by making a @FragmentById/@FragmentByTag public in the @RootContextannotated A...
X Description: Hi! Currently, the only way to access the parent Fragment in an @EBean is by writing a setter in the bean manually, or by making a @FragmentById/@FragmentByTag public in the @RootContextannotated A...
Opengraph URL: https://github.com/androidannotations/androidannotations/issues/1636
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add @RootFragment annotation for @EBean","articleBody":"Hi!\n\nCurrently, the only way to access the parent `Fragment` in an `@EBean` is by writing a setter in the bean manually, or by making a `@FragmentById`/`@FragmentByTag` public in the `@RootContext`annotated `Activity`. The code is not that beautiful, so why not create an `@RootFragment` annotation?\n\nIt would work the same way as `@RootContext`, excepted that it would not need to be re-injected if the Fragment instance is retained (see `setRetainInstance()` \u0026 `getRetainInstance()`) and the field is annotated with `NonConfigurationInstance` when config changes occurs (screen rotation, locale change, etc) as the Fragment itself (only it's View hierarchy) is not destroyed if retained.\n\nExamples speak better than words, so here's how it would look like:\n\n``` java\n@EBean\npublic class MyRecyclerView extends RecyclerView.Adapter {\n\n @RootFragment\n MyEFragment mFragment;\n\n // I can now access the fragment, it's @InstanceState members,\n // and keep easily my adapter state, such as selected items\n}\n```\n\nBelow are the quotes to \"help\" implementation, from Gitter:\n\n\u003e - @WonderCsabo: the problem is that it is not trivial to implement\n\u003e - @LouisCAD: What would be the hard part(s)? Wouldn't it work by adding a setFragment_(MyEFragment fragment) call in onCreate() for all @EBeans in MyEFragment containing an @RootFragment field?\n\u003e - @WonderCsabo: Yeah, it is not too hard, that was an overstatement.\n\nI'm on the way to learn how Annotation Processors work under the hood, so I hope I'll be able to add this myself (If I begin working on this, I'll post updates here), but if in the meantime, someone with the skills wants to add this new feature, I'd be very grateful (and I hope I would not be the only one).\n","author":{"url":"https://github.com/LouisCAD","@type":"Person","name":"LouisCAD"},"datePublished":"2015-11-23T16:07:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1636/androidannotations/issues/1636"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d6f8f8a0-323b-d8f5-a9e1-dccf60167c76 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9EAA:1075A3:19C119:21E3DC:6A6145F2 |
| html-safe-nonce | 7db668bddee4286537fc64c49d9aad866e3424213855827221413ab4cf3d7923 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RUFBOjEwNzVBMzoxOUMxMTk6MjFFM0RDOjZBNjE0NUYyIiwidmlzaXRvcl9pZCI6IjgyNTI1MTA5NDIxMjQ5MTgyNTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | eda8e88ac40cf7fdcb2e53085c0c8c6281487f9304900425ebce88cdb10452bb |
| hovercard-subject-tag | issue:118413814 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/androidannotations/androidannotations/1636/issue_layout |
| twitter:image | https://opengraph.githubassets.com/05b718cd1f14a5926bcced1c38677161947b1bb61d3965dee0a5995403dfc82a/androidannotations/androidannotations/issues/1636 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/05b718cd1f14a5926bcced1c38677161947b1bb61d3965dee0a5995403dfc82a/androidannotations/androidannotations/issues/1636 |
| og:image:alt | Hi! Currently, the only way to access the parent Fragment in an @EBean is by writing a setter in the bean manually, or by making a @FragmentById/@FragmentByTag public in the @RootContextannotated A... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LouisCAD |
| hostname | github.com |
| expected-hostname | github.com |
| None | 358090e896abe1815bef70fcaae0a12d8ebf315874207428312daf7419e9c7c9 |
| turbo-cache-control | no-preview |
| go-import | github.com/androidannotations/androidannotations git https://github.com/androidannotations/androidannotations.git |
| octolytics-dimension-user_id | 1315313 |
| octolytics-dimension-user_login | androidannotations |
| octolytics-dimension-repository_id | 3116751 |
| octolytics-dimension-repository_nwo | androidannotations/androidannotations |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3116751 |
| octolytics-dimension-repository_network_root_nwo | androidannotations/androidannotations |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 87be91c8b3c813d60ac5c8ece422529a03a7e332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width