Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

add @AfterExtras#928

Closed
dodgex wants to merge 18 commits intoandroidannotations:developfrom
dodgex:AfterExtra
Closed

add @AfterExtras#928
dodgex wants to merge 18 commits intoandroidannotations:developfrom
dodgex:AfterExtra

Conversation

@dodgex
Copy link
Member

@dodgex dodgex commented Mar 2, 2014

this PR adds an @AfterExtras annotation, that works similar to @AfterInject, but the methods are called every time a new intent is set to the activty by setIntent(Intent intent).

this allows an activity to get notified about new intents and so new extras.

the generated code looks like this

    private void injectExtras_() {
        Bundle extras_ = getIntent().getExtras();
        if (extras_!= null) {
            if (extras_.containsKey(OPEN_ALARMCLOCK_EXTRA)) {
                openAlarmclock = extras_.getBoolean(OPEN_ALARMCLOCK_EXTRA);
            }
            myAfterExtraMethod();
        }
    }

for multiple extras and/or methods, first all extras get injected and then the methods get called.


to be useful this currently needs this code block in the activity
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
    }

currently known "issues", the first call to an @AfterExtras annotated method does not yet have @Bean fields set. this would require to move the ExtraHandler below the BeanHandler in AnnotationHandlers. i don't think that this would cause any issues. but i'll open a seperate PR for this change.

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants