Last active
December 20, 2015 01:29
-
-
Save ljanzik/6049950 to your computer and use it in GitHub Desktop.
SImple example for View Injection for a Android Application by using AspectJ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Aspect | |
public class ActivityInjectionAspect { | |
@Before("execution(* android.app.Activity.onCreate(..)) && within(@com.thoughtsonmobile.example.aspectj.Layout *)") | |
public void beforeOnCreate(JoinPoint joinPoint) { | |
Activity activity = (Activity)joinPoint.getTarget(); | |
Layout layout = activity.getClass().getAnnotation(Layout.class); | |
activity.setContentView(layout.value()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Layout(R.layout.dashboard) | |
public class DashboardActivity extends Activity { | |
[..] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment