libgdx/libgdx — pull request #944 by Centril (2013-11-10 01:08:40+00:00)
Title: Decoupling of AndroidApplication logic from Activity (removing inheritance, using delegation)

Background
-----------------

Our project SleepFighter https://github.com/Hasselmannen/sleepfighter
is an alarm app for android that uses mini-games ("Challenge") that needs OpenGL/libgdx
for some Challenges - others use MathML.
We've an activity that spawns these games (ChallengeActivity): https://github.com/Hasselmannen/sleepfighter/blob/master/application/src/se/toxbee/sleepfighter/activity/ChallengeActivity.java
The interface for a Challenge is: https://github.com/Hasselmannen/sleepfighter/blob/master/application/src/se/toxbee/sleepfighter/challenge/Challenge.java

Since all challenges don't use libgdx, it is unacceptable for ChallengeActivity to extend AndroidApplication.
I'd rather send in the ChallengeActivity to AndroidApplication.

Changes
-------------

Since alot of projects rely on AndroidApplication being an activity.
I haven't changed that mechanism, but rather I moved the code in AndroidApplication to AndroidApplicationBackend and let AndroidApplication still be an activity but delegate to AndroidApplicationBackend.

Avoiding inheritance for these cases is sound OOD

I don't know any other way to solve this.
This solution allows for complete backwards compatibility.

I agree that the use case might be rare - but the performance impact of the changes should be slim to nill since people shouldn't call getGraphics(), and such methods in loops but rather store the value of such a call in a local field.

I sent a mail signing the CLA btw =)