Integration with HoloEverywhere by mikegr · Pull Request #429 · androidannotations/androidannotations · GitHub
Skip to content
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
@@ -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