X Tutup
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
Expand Up @@ -15,7 +15,7 @@
*/
package org.androidannotations.handler;

import static com.sun.codemodel.JExpr.ref;
import static com.sun.codemodel.JExpr._this;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
Expand Down Expand Up @@ -68,6 +68,6 @@ public void process(Element element, HasOptionsMenu holder) {
JVar menuParam = holder.getOnCreateOptionsMenuMenuParam();

JFieldRef idsRef = annotationHelper.extractOneAnnotationFieldRef(processHolder, element, IRClass.Res.ID, true);
body.assign(ref(fieldName), menuParam.invoke("findItem").arg(idsRef));
body.assign(_this().ref(fieldName), menuParam.invoke("findItem").arg(idsRef));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (C) 2010-2015 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.menu;

import android.app.Activity;
import android.view.MenuItem;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsMenuItem;

@EActivity
public class OptionsMenuItemActivity extends Activity {

@OptionsMenuItem
MenuItem menu;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright (C) 2010-2015 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.menu;

import org.androidannotations.AndroidAnnotationProcessor;
import org.androidannotations.utils.AAProcessorTestHelper;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;

public class OptionsMenuItemTest extends AAProcessorTestHelper {

@Before
public void setUp() {
addManifestProcessorParameter(OptionsMenuItemTest.class);
addProcessor(AndroidAnnotationProcessor.class);
}

@Test
public void testWhenFieldNameCouldConflictWithParameterName() throws IOException {
CompileResult result = compileFiles(OptionsMenuItemActivity.class);
assertCompilationSuccessful(result);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.androidannotations.menu;

public class R {
public static final class id {
public static final int menu = 0x7f06000a;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--

Copyright (C) 2010-2015 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.

-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.androidannotations.menu"
android:versionCode="1"
android:versionName="1.0" >

<application>
<activity android:name="org.androidannotations.menu.OptionsMenuItemActivity_" />
</application>

</manifest>
X Tutup