-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onKeyDown Callthrough listener always consuming event #117
Comments
Maybe some generated code like this would work?: @Override
public boolean onKeyDown(int int$$1, KeyEvent keyEvent$$0) {
boolean consumed;
consumed = searchActivity$$0 .onKeyDown(int$$1, keyEvent$$0);
if(consumed){return true;}
return super(int$$1, keyEvent$$0);
} no idea how to implement this, tough |
I've looked at the source code. Seems to be related to buildActivityDelegateRegistrationGeneratorFactory in RegistrationAnalyzer.java. This one is really important, as there is no workaround. Probably the last showstopper for my project, which has come quite far by now. I'd be really grateful, if somebody could help me on this. |
How comes a solution always pops up once I've posted a request? public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (productListVisible == true) {
showRandomProductList();
return true;
} else {
activity.onBackPressed();
return true;
}
}
return false;
} Hope this is useful for others, too. |
This looks like an ok workaround, but are you really looking to make the super call (Related: #101)?
|
Regarding #101, does this allow to consume the back key event? It is a void method, after all. |
Yes, the intent is to allow for a super call to properly handle the back key event in the case that your application doesn't handle it. As with #115 this functionality is waiting for a major refactoring of the codebase (0.3.0). ASTType is defined within Transfuse. You can find the relevant classes here: https://github.com/johncarl81/transfuse/tree/master/transfuse-support/src/main/java/org/androidtransfuse/adapter. This set of classes follow the adapter pattern, which allows us to treat the Element api (annotation processor-centric) and the Class api (Reflection-centric) the same. In turn, this makes unit testing annotation processors much easier. If you're interested in contributing to Transfuse, I'm more than happy to help explain more regarding the core. Shoot me an email with specific questions and I'll try my best to answer. |
Hi John, so it's on a possible future feature - thats great :) |
@Airblaster, any contributions are greatly appreciated. Just reporting issues, engaging in specific features and believing in the project is huge. We also have documentation that could use some tending on the transfuse-jeykll-site branch. |
@Airblaster, I believe we're addressed this issue. Can I close? |
@johncarl81 : |
@johncarl81 : |
Ah, this is what you'll need to do: @ManualSuper(name = "onKeyDown", parameters = {int.class, KeyEvent.class})
public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (productListVisible == true) {
showRandomProductList();
return true;
}
}
return GeneratedActivity.SUPER.onKeyDown(keyCode, event);
} Just replace Let me know if this works for you. |
Ah, so thats how you use it. |
For some reason, the following registered listener callthrough listeners seem to always consume the event, thus making it impossible to leave the application by pressing the back key:
The generated code looks like this:
Any ideas on how it would be possible to make android consume the event itself and exiting the app when false is returned?
The text was updated successfully, but these errors were encountered: