johncarl81 / transfuse

:syringe: Transfuse - A Dependency Injection and Integration framework for Google Android
http://androidtransfuse.org/
Apache License 2.0
220 stars 28 forks source link

Remove superCall() from onBackPressed callback #163

Closed goodsoft closed 9 years ago

goodsoft commented 9 years ago

Default implementation of onBackPressed method just finishes the activity. As the usual reason for overriding onBackPressed is preventing activity finish, it doesn't seem reasonable to always call super.onBackPressed. In case user still wants to finish the activity, he should call injected activity's finish() method.

johncarl81 commented 9 years ago

Nice catch, will merge soon. Would you care to rebase?

goodsoft commented 9 years ago

Seems rebased to me

dbachelder commented 9 years ago

I think this will be a breaking change to existing clients.. I think it's a great change, but this alone might warrant a major version update.

johncarl81 commented 9 years ago

Thinking about htis more, we do have the ability to cancel the super call using the @ManualSuper annotation (this needs to be documented). So the question is, should we remove the super call altogether?

dbachelder commented 9 years ago

That is how we get around this issue in our app.

goodsoft commented 9 years ago

Oh wow, didn't know about that annotation. So should I just write something like this:

@OnBackPressed @ManualSuper
void onBackPressed() {
    // ...
}

and the super.onBackPressed() won't be called, right?

goodsoft commented 9 years ago

Okay, @ManualSuper(name = "onBackPressed") and NOT calling generated SUPER.onBackPressed() method solved the problem, so closing this PR.

johncarl81 commented 9 years ago

Yes, and this feature needs to be docuemnted.

By the way, the documentation is git friendly and super easy to edit via Asciidoc. Here's the content: https://github.com/johncarl81/transfuse-site