-
Notifications
You must be signed in to change notification settings - Fork 2.3k
943 release openhelpermanager #1245
943 release openhelpermanager #1245
Conversation
|
I should only beautify my own code. Revert other beautify code. The logic be Ok, not need to modify. |
|
Please rebase this branch as to meld the last two commits into the first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable.
|
Please do not reformat whole classes. We are using tabs for indenting etc. You can use our Eclipse formatter profile, if you save in Eclipse, it automatically formats the code with the proper settings. |
|
BTW i just realized if the client uses daos which uses different helpers, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that the databaseHelper is null at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oftentimes, not.
But I think this is a good habit that can help us to write more strong code.
I'll change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not a question of "habit". If the reference cannot be null, it is
absolutely unnecessary to use a null check. If the reference can be null,
you must add a null check. Actually you even get warnings if you use
@Nullable/@NotNull annotations and a static analysis tool which
inspects them.
|
And a small note about commit messages: please carefully write them, check grammar, typos etc. The commit messages should follow the standard git format (we refer to this in the contributing code page. |
0f3b459 to
9d8e982
Compare
|
Thanks for your advice! I rebased some commit and push to AA. That's my first step. |
|
From @WonderCsabo : I'm trying to learn English well. But, you know, in such a formal occasion, I still hope you help me write some text to warn users in JavaDoc and wiki. Thx! |
f16c550 to
50868a8
Compare
|
From @WonderCsabo : I have been considering this issue long time before start writing the code. But: I'm not rashly to modify the overall framework. |
|
Maye you can create a new interface |
|
Please rebase this whole branch into two commits: a code and a test commit. |
No problem, that's actually another issue, i'll open a new ticket for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we do not actually use this test, please remove any changes from here.
50868a8 to
cd34694
Compare
|
Push again.
I'll solute this issue tomorrow :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all changes from this class, if you do not add anything interesting.
|
Rebase has some error on it. I'll check again. Sorry about that. |
cd34694 to
3c197d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use staticField for static fields.
3c197d3 to
dcee2d3
Compare
2e009cc to
d5012ee
Compare
|
I'm terribly sorry. I have no idea to avoid the "instanceof" condition. Because the Can u give me some advices? :) |
|
Yep, this is a tricky one. You can create the similar solution to the receiver registration. Move the release helper method invocation to a separate class. Then in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you wanted to write this instanceof HasLifecycleMethods, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the logic is OK. But we should refactor this.
d5012ee to
701606e
Compare
Sounds exciting! I'm sorry to trouble you a lot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not do anything here, since it is already done in EServiceHolder. This way you will add two releaseHelper invocations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
I'll create new test classes for Service and Fragment to ensure there is no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can leave that as is, the current test is enough for now.
On Nov 18, 2014 9:21 AM, "Jiongxuan Zhang" notifications@github.com wrote:
In
AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/holder/EIntentServiceHolder.java:@@ -76,4 +79,12 @@ private void createOnHandleIntent() {
JInvocation getActionInvocation = JExpr.invoke(onHandleIntentIntent, "getAction");
onHandleIntentIntentAction = onHandleIntentBody.decl(classes().STRING, "action", getActionInvocation);
}
+
- @OverRide
- protected JFieldVar setDatabaseHelperRef(TypeMirror databaseHelperTypeMirror) {
Yep.
I'll create new test classes for Service and Fragment to ensure there is
no problem.Reply to this email directly or view it on GitHub
https://github.com/excilys/androidannotations/pull/1245/files#r20491186.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm almost finished writing it :)
Okay, I'm fixed it.
701606e to
1d0f891
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think it is not really nice if we use HasReceiverRegistration, because this code has nothing to do with receivers. I suggest to reintroduce the interface that i mentioned, and use it there instead of HasReceiverRegistration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HasLifecycleMethods?
Are you sure that the interface should have onDestroyBeforeSuperBlock method?
If not, how can I insert OpenHelperManager.release in the onDestroy method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think that HasLifecycleMethods should not have onDestroyBeforeSuperBlock? Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the OrmliteDaoHandler can handle two scenarios: with an onDestory method or not.
We cannot create getOnDestroy into HasLifecycleMethods, thus will be ignore annother scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EBean and @EActivity can use it well. But @EBean does not have a onDestroy method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean we should only add onDestroyXXX in the HasLifecycleMethods?
So that it conforms to the ISP? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't get me wrong, I just confirm that I understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, it would be seen as redundant to you, because basically everyting which is a HasLifecycleMethods is HasReceiverRegistration, too. But i still think this is better design. This is what i propose:
create a new HasLifecycleMethods interface:
public interface HasLifecycleMethods extends GeneratedClassHolder {
JBlock getOnCreateAfterSuperBlock();
JBlock getOnDestroyBeforeSuperBlock();
JBlock getOnStartAfterSuperBlock();
JBlock getOnStopBeforeSuperBlock();
JBlock getOnResumeAfterSuperBlock();
JBlock getOnPauseBeforeSuperBlock();
JBlock getOnAttachAfterSuperBlock();
JBlock getOnDetachBeforeSuperBlock();
}Let HasReceiverRegistration extend HasLifecycleMethods, and remove redundant method declarations:
public interface HasReceiverRegistration extends HasLifecycleMethods {
JExpression getContextRef();
JFieldVar getIntentFilterField(String[] actions, String[] dataSchemas);
}Use HasLifecycleMethods in OrmLiteHelper:
public static void injectReleaseInDestroy(JFieldVar databaseHelperRef, HasLifecycleMethods lifecycleMethodsHolder, ProcessHolder.Classes classes) { ... }There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. You're right!
In fact, the most perfect solution i think is split into four interface: HasLifecycleMethods / HasStartAndStopMethods / HasAttachableMethods / HasReceiverRegistration.
There is no connection between them.
EActivityHolder and EFragmentHolder need implement: HasLifecycleMethods,HasStartAndStopMethods, HasAttachableMethods and HasReceiverRegistration
EServiceHolder need implement: HasLifecycleMethods and HasReceiverRegistration
In ReceiverHandler.registerAndUnregisterReceiver method, we can add two method with the same name.
These methods are respectively corresponding to these Interface.
However, this is a huge change. I think to do as you say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we could split it even further, but i think my proposal will suffice
for now.
Remove redundant method declarations in HasReceiverRegistration class.
|
@yDelouis I think this code is finally OK. I would merge. |
|
LGTM. Nice work. :) |
|
Thanks. :) |
Release database helper with @OrmLiteDao
|
Thanks! |
Implement #943 issue.
Please review my code. Thx!