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.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,7 @@
public @interface EFragment {
int value() default ResId.DEFAULT_VALUE;

boolean forceLayoutInjection() default false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this the last method. Also add some JavaDoc.


String resName() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,16 @@ public void process(Element element, EFragmentHolder holder) {

JFieldVar contentView = holder.getContentView();

block._if(contentView.eq(_null())) //
._then() //
.assign(contentView, inflater.invoke("inflate").arg(contentViewId).arg(container).arg(FALSE));
boolean forceInjection = element.getAnnotation(EFragment.class).forceLayoutInjection();

if (!forceInjection) {
block._if(contentView.eq(_null())) //
._then() //
.assign(contentView, inflater.invoke("inflate").arg(contentViewId).arg(container).arg(FALSE));
} else {
block.assign(contentView, inflater.invoke("inflate").arg(contentViewId).arg(container).arg(FALSE));
}

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.sun.codemodel.JMod;
import com.sun.codemodel.JTypeVar;
import com.sun.codemodel.JVar;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.helper.ActionBarSherlockHelper;
import org.androidannotations.helper.AnnotationHelper;
import org.androidannotations.process.ProcessHolder;
Expand Down Expand Up @@ -247,8 +248,12 @@ private void setOnCreateView() {

JVar savedInstanceState = onCreateView.param(classes().BUNDLE, "savedInstanceState");

boolean forceInjection = getAnnotatedElement().getAnnotation(EFragment.class).forceLayoutInjection();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not really use getAnnotatedElement() for these kind of purposes. But i also do not see other solution to this problem. @yDelouis WDYT?


JBlock body = onCreateView.body();
body.assign(contentView, _super().invoke(onCreateView).arg(inflater).arg(container).arg(savedInstanceState));

if (!forceInjection)
body.assign(contentView, _super().invoke(onCreateView).arg(inflater).arg(container).arg(savedInstanceState));

setContentViewBlock = body.block();

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