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.
Merged
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 @@ -90,6 +90,11 @@ public final class CanonicalNameConstants {
public static final String SHERLOCK_MENU_ITEM = "com.actionbarsherlock.view.MenuItem";
public static final String SHERLOCK_MENU_INFLATER = "com.actionbarsherlock.view.MenuInflater";

/*
* HoloEverywhere
*/
public static final String HOLO_EVERYWHERE_LAYOUT_INFLATER = "org.holoeverywhere.LayoutInflater";

/*
* SpringFramework
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright (C) 2010-2012 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.helper;

import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.NoType;
import javax.lang.model.type.TypeMirror;

import org.androidannotations.processing.EBeanHolder;

/**
* @author Eric Kok
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought you were Michael Greifeneder, not Eric Kok :)

public class HoloEverywhereHelper {

private final AnnotationHelper annotationHelper;

public HoloEverywhereHelper(AnnotationHelper annotationHelper) {
this.annotationHelper = annotationHelper;
}

/**
* Checks whether the Activity extends one of the ActionBarSherlock Activity
* types
*/
public boolean usesHoloEverywhere(EBeanHolder holder) {
TypeElement typeElement = annotationHelper.typeElementFromQualifiedName(holder.generatedClass._extends().fullName());

TypeMirror superType;
while (!((superType = typeElement.getSuperclass()) instanceof NoType)) {
typeElement = (TypeElement) ((DeclaredType) superType).asElement();
String qName = typeElement.getQualifiedName().toString();
if (qName.startsWith("org.holoeverywhere")) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public boolean usesSherlock(EBeanHolder holder) {
TypeMirror superType;
while (!((superType = typeElement.getSuperclass()) instanceof NoType)) {
typeElement = (TypeElement) ((DeclaredType) superType).asElement();
if (typeElement.getQualifiedName().toString().startsWith("com.actionbarsherlock.app")) {
String qName = typeElement.getQualifiedName().toString();
if (qName.startsWith("com.actionbarsherlock.app")) {
return true;
}
if (qName.startsWith("org.holoeverywhere")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wow. I didn't get it at first, but then I realized HoloEverywhere relies on ABS dirty hidden classes instead of extends SherlockActivity.

return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public class Classes {
public final JClass SHERLOCK_MENU_ITEM = refClass(CanonicalNameConstants.SHERLOCK_MENU_ITEM);
public final JClass SHERLOCK_MENU_INFLATER = refClass(CanonicalNameConstants.SHERLOCK_MENU_INFLATER);

/*
* HoloEverywhre
*/
public final JClass HOLO_EVERYWHERE_LAYOUT_INFLATER = refClass(CanonicalNameConstants.HOLO_EVERYWHERE_LAYOUT_INFLATER);

/*
* RoboGuice
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.androidannotations.processing;

import static org.androidannotations.helper.ModelConstants.GENERATION_SUFFIX;
import static com.sun.codemodel.JExpr.FALSE;
import static com.sun.codemodel.JExpr._new;
import static com.sun.codemodel.JExpr._null;
Expand All @@ -25,6 +24,7 @@
import static com.sun.codemodel.JMod.PRIVATE;
import static com.sun.codemodel.JMod.PUBLIC;
import static com.sun.codemodel.JMod.STATIC;
import static org.androidannotations.helper.ModelConstants.GENERATION_SUFFIX;

import java.lang.annotation.Annotation;

Expand All @@ -33,10 +33,12 @@
import javax.lang.model.element.TypeElement;

import org.androidannotations.annotations.EFragment;
import org.androidannotations.helper.HoloEverywhereHelper;
import org.androidannotations.helper.IdAnnotationHelper;
import org.androidannotations.processing.EBeansHolder.Classes;
import org.androidannotations.rclass.IRClass;
import org.androidannotations.rclass.IRClass.Res;

import com.sun.codemodel.ClassType;
import com.sun.codemodel.JBlock;
import com.sun.codemodel.JClass;
Expand All @@ -51,9 +53,12 @@
public class EFragmentProcessor implements GeneratingElementProcessor {

private final IdAnnotationHelper helper;
private HoloEverywhereHelper holoEverywhereHelper;

public EFragmentProcessor(ProcessingEnvironment processingEnv, IRClass rClass) {
helper = new IdAnnotationHelper(processingEnv, getTarget(), rClass);
holoEverywhereHelper = new HoloEverywhereHelper(helper);

}

@Override
Expand Down Expand Up @@ -113,7 +118,13 @@ public void process(Element element, JCodeModel codeModel, EBeansHolder eBeansHo
// onCreateView()
JMethod onCreateView = holder.generatedClass.method(PUBLIC, classes.VIEW, "onCreateView");
onCreateView.annotate(Override.class);
JVar inflater = onCreateView.param(classes.LAYOUT_INFLATER, "inflater");
JClass inflaterClass = classes.LAYOUT_INFLATER;

if (holoEverywhereHelper.usesHoloEverywhere(holder)) {
inflaterClass = classes.HOLO_EVERYWHERE_LAYOUT_INFLATER;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd probably use an if else here to show the fact that inflaterClass holds either classes.LAYOUT_INFLATER or classes.HOLO_EVERYWHERE_LAYOUT_INFLATER

}
JVar inflater = onCreateView.param(inflaterClass, "inflater");

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

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