public abstract class PlatformDistributor<T>
extends java.lang.Object
Using manual:
First of all create an Interface that contains the methods you want to share between LibGDX modules (android, ios)
then create PlatformDistributor which will be accessible from all modules.
class AndroidAndIosManager extends PlatformDistributor<YourInterface>{
}
Now create classes that implements same interface in android and ios modules:
class MyAndroidLib implements YourInterface{}
class MyIOSLib implements YourInterface{}
Last step is telling PlatformDistributor which classes it should use on each platform,
you can do this by implementing getAndroidClassName() and getIOSClassName() methods.
| Modifier and Type | Field and Description |
|---|---|
protected T |
platformObject |
| Modifier | Constructor and Description |
|---|---|
protected |
PlatformDistributor()
Creates platform specific object by reflection.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract java.lang.String |
getAndroidClassName()
Gives class name of object that will be create when application running on android platform.
|
protected abstract java.lang.String |
getIOSClassName()
Gives class name of object that will be create when application running on ios platform.
|
void |
setMockObject(T mockObject)
Sets mock representation of platform distribution.
|
protected T platformObject
protected PlatformDistributor()
throws PlatformDistributorException
Uses class names given by getAndroidClassName() and getIOSClassName()
If environment is different than Android or iOS creates mock class provided by Proxy.newProxyInstance(ClassLoader, Class[], InvocationHandler)
PlatformDistributorException - Throws when something is wrong with environmentpublic void setMockObject(T mockObject)
Useful when it is need to run application on not-supported platform.
mockObject - Mock representation of platform distribution object - Tprotected abstract java.lang.String getIOSClassName()
protected abstract java.lang.String getAndroidClassName()