Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Extend new Fragment Scope for EBean #2214

Copy link
Copy link
@smaugho

Description

@smaugho
Issue body actions

We resently added Fragment Scope for EBean annotated classes on #2206. Its usage right now is simply to ensure that the EBean is the same if it is injected in the same fragment scope. There is some cases of uses in which could be useful, though there are other cases in which its usability increases.

It is common to have fragments which contains multiple subfragments. Or to have a collection of fragments which are related in functionality.

I do propose to extend the Fragment scope for this cases, for doing so, @EBean should support 2 extra parameters, fragmentId, and fragmentTag. This is an example of usage:

@EBean(scope = Scope.Fragment, fragmentId = {R.id.fragment1, R.id.fragment2})
public class SomeBean {
    //Code
}

This will increase the usability of the new Fragment scope. You could have complete sections on the app sharing the same instance of a Bean, which is really useful.

For doing this, basically to inject the Bean, it is used exactly the same mechanism implemented on #2206, merged with a search of Fragment by ID or by Tag (similar to how the @FragmentById or @FragmentByTag work).

The fragment will be injected using the first BeanHolder found, so if a serie of fragmentsId is provided, the first one would be the "holder" of the bean. In the case of not existing the second and so on.

In cases where there is a "parent fragment" of course, the best is that the programmer select this parent fragment as the holder (only providing its ID to the @EBean) (like a fragment with a ViewPager which contains multiple other fragments).

If the parameters fragmentId or fragmentTag are not provided, then it works exactly how it is currently implemented.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.