Changed the way the Android dependent interfaces are passed in the constructor.

This commit is contained in:
2013-11-28 08:59:19 -04:30
parent 44b58565ff
commit 5eb079fb7b
2 changed files with 19 additions and 11 deletions

View File

@@ -6,6 +6,7 @@ import ve.ucv.ciens.ccg.nxtar.interfaces.Toaster;
import ve.ucv.ciens.ccg.nxtar.network.RobotControlThread; import ve.ucv.ciens.ccg.nxtar.network.RobotControlThread;
import ve.ucv.ciens.ccg.nxtar.network.ServiceDiscoveryThread; import ve.ucv.ciens.ccg.nxtar.network.ServiceDiscoveryThread;
import ve.ucv.ciens.ccg.nxtar.network.VideoStreamingThread; import ve.ucv.ciens.ccg.nxtar.network.VideoStreamingThread;
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
import com.badlogic.gdx.Application; import com.badlogic.gdx.Application;
import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.ApplicationListener;
@@ -18,9 +19,9 @@ import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
public class Main implements ApplicationListener, NetworkConnectionListener { public class NxtARCore implements ApplicationListener, NetworkConnectionListener {
private static final String TAG = "NXTAR_CORE_MAIN"; private static final String TAG = "NXTAR_CORE_MAIN";
private static final String CLASS_NAME = Main.class.getSimpleName(); private static final String CLASS_NAME = NxtARCore.class.getSimpleName();
private OrthographicCamera camera; private OrthographicCamera camera;
private SpriteBatch batch; private SpriteBatch batch;
@@ -34,11 +35,16 @@ public class Main implements ApplicationListener, NetworkConnectionListener {
private VideoStreamingThread videoThread; private VideoStreamingThread videoThread;
private RobotControlThread robotThread; private RobotControlThread robotThread;
public Main(Toaster toaster, MulticastEnabler mcastEnabler){ public NxtARCore(Application concreteApp){
super(); super();
this.toaster = toaster;
this.mcastEnabler = mcastEnabler;
connections = 0; connections = 0;
try{
this.toaster = (Toaster)concreteApp;
this.mcastEnabler = (MulticastEnabler)concreteApp;
}catch(ClassCastException cc){
Gdx.app.debug(TAG, CLASS_NAME + ".Main() :: concreteApp does not implement any of the required interfaces.");
System.exit(ProjectConstants.EXIT_FAILURE);
}
} }
@Override @Override

View File

@@ -5,6 +5,8 @@ public abstract class ProjectConstants {
public static final int SERVER_TCP_PORT_1 = 9989; public static final int SERVER_TCP_PORT_1 = 9989;
public static final int SERVER_TCP_PORT_2 = 9990; public static final int SERVER_TCP_PORT_2 = 9990;
public static final String MULTICAST_ADDRESS = "230.0.0.1"; public static final String MULTICAST_ADDRESS = "230.0.0.1";
public static final int EXIT_SUCCESS = 0;
public static final int EXIT_FAILURE = 1;
public static final boolean DEBUG = true; public static final boolean DEBUG = true;
} }