Skip to content

Commit

Permalink
Some Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal66 committed Sep 21, 2019
1 parent 764582f commit 242b55f
Show file tree
Hide file tree
Showing 21 changed files with 653 additions and 707 deletions.
4 changes: 1 addition & 3 deletions droidar/src/main/java/actions/ActionCalcRelativePos.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ private void resetCameraToNullPosition() {
private boolean worldShouldBeRecalced(double latDistMet, double longDistMet) {
if (Math.abs(latDistMet) > MAX_METER_DISTANCE)
return true;
if (Math.abs(longDistMet) > MAX_METER_DISTANCE)
return true;
return false;
return Math.abs(longDistMet) > MAX_METER_DISTANCE;
}

public void resetWorldZeroPositions(Location location) {
Expand Down
156 changes: 77 additions & 79 deletions droidar/src/main/java/commands/Command.java
Original file line number Diff line number Diff line change
@@ -1,80 +1,78 @@
package commands;

import gui.ListItem;
import gui.MetaInfos;
import listeners.ItemGuiListener;
import util.Log;
import worldData.HasInfosInterface;
import android.view.View;
import android.view.ViewGroup;

/**
* TODO name this Command ?
*
* @author Spobo
*
*/
public abstract class Command implements ListItem, HasInfosInterface {

private MetaInfos myInfoObj;
private ItemGuiListener myItemGuiListener;

/**
* @param transfairObject
* @return true if command was successful. if the transfairObject isn't used
* the default execute()-method will be executed
*/
public boolean execute(Object transfairObject) {
/*
* on default the transfairObject isnt used, this way only command which
* need the transfairobject will have to override this method
*/
return execute();
}

public abstract boolean execute();

@Override
public View getMyListItemView(View viewToUseIfNotNull, ViewGroup parentView) {
if (myItemGuiListener != null)
return myItemGuiListener.requestItemView(viewToUseIfNotNull,
parentView);
Log.d("GUI", " -> Loading default view for " + this.getClass());
return getInfoObject().getDefaultListItemView(viewToUseIfNotNull,
parentView);
}

/**
* TODO remove or refactor, this is never used
*
* @param myItemGuiListener
*/
public void setMyItemGuiListener(ItemGuiListener myItemGuiListener) {
this.myItemGuiListener = myItemGuiListener;
}

@Override
public Command getListClickCommand() {
return this;
}

@Override
public Command getListLongClickCommand() {
return null;
}

@Override
public MetaInfos getInfoObject() {
if (myInfoObj == null)
myInfoObj = new MetaInfos(this);
return myInfoObj;
}

@Override
public boolean HasInfoObject() {
if (myInfoObj != null)
return true;
return false;
}

package commands;

import gui.ListItem;
import gui.MetaInfos;
import listeners.ItemGuiListener;
import util.Log;
import worldData.HasInfosInterface;
import android.view.View;
import android.view.ViewGroup;

/**
* TODO name this Command ?
*
* @author Spobo
*
*/
public abstract class Command implements ListItem, HasInfosInterface {

private MetaInfos myInfoObj;
private ItemGuiListener myItemGuiListener;

/**
* @param transfairObject
* @return true if command was successful. if the transfairObject isn't used
* the default execute()-method will be executed
*/
public boolean execute(Object transfairObject) {
/*
* on default the transfairObject isnt used, this way only command which
* need the transfairobject will have to override this method
*/
return execute();
}

public abstract boolean execute();

@Override
public View getMyListItemView(View viewToUseIfNotNull, ViewGroup parentView) {
if (myItemGuiListener != null)
return myItemGuiListener.requestItemView(viewToUseIfNotNull,
parentView);
Log.d("GUI", " -> Loading default view for " + this.getClass());
return getInfoObject().getDefaultListItemView(viewToUseIfNotNull,
parentView);
}

/**
* TODO remove or refactor, this is never used
*
* @param myItemGuiListener
*/
public void setMyItemGuiListener(ItemGuiListener myItemGuiListener) {
this.myItemGuiListener = myItemGuiListener;
}

@Override
public Command getListClickCommand() {
return this;
}

@Override
public Command getListLongClickCommand() {
return null;
}

@Override
public MetaInfos getInfoObject() {
if (myInfoObj == null)
myInfoObj = new MetaInfos(this);
return myInfoObj;
}

@Override
public boolean HasInfoObject() {
return myInfoObj != null;
}

}
93 changes: 45 additions & 48 deletions droidar/src/main/java/components/TimerComp.java
Original file line number Diff line number Diff line change
@@ -1,48 +1,45 @@
package components;

import commands.Command;

import worldData.Entity;
import worldData.UpdateTimer;
import worldData.Updateable;
import worldData.Visitor;

public class TimerComp implements Entity {

private UpdateTimer timer;
private Updateable myParent;

public TimerComp(float countdownTimeInSeconds, Command commandToExecute) {
timer = new UpdateTimer(countdownTimeInSeconds, commandToExecute);
}

@Override
public boolean update(float timeDelta, Updateable parent) {
setMyParent(parent);
if (timer.update(timeDelta, this)) {
/*
* if the timer returns true that means its time was up and it was
* executed correctly so the TImerComp can be removed from its
* parent -> return false
*/
return false;
}
return true;
}

@Override
public boolean accept(Visitor visitor) {
return visitor.visit(this);
}

@Override
public Updateable getMyParent() {
return myParent;
}

@Override
public void setMyParent(Updateable parent) {
myParent = parent;
}

}
package components;

import commands.Command;

import worldData.Entity;
import worldData.UpdateTimer;
import worldData.Updateable;
import worldData.Visitor;

public class TimerComp implements Entity {

private UpdateTimer timer;
private Updateable myParent;

public TimerComp(float countdownTimeInSeconds, Command commandToExecute) {
timer = new UpdateTimer(countdownTimeInSeconds, commandToExecute);
}

@Override
public boolean update(float timeDelta, Updateable parent) {
setMyParent(parent);
/*
* if the timer returns true that means its time was up and it was
* executed correctly so the TImerComp can be removed from its
* parent -> return false
*/
return !timer.update(timeDelta, this);
}

@Override
public boolean accept(Visitor visitor) {
return visitor.visit(this);
}

@Override
public Updateable getMyParent() {
return myParent;
}

@Override
public void setMyParent(Updateable parent) {
myParent = parent;
}

}
15 changes: 5 additions & 10 deletions droidar/src/main/java/geo/GeoGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,18 +514,18 @@ public String toString() {
}

@Override
public void render(/*GL10 gl,*/ GLES20 unused, Renderable parent) {
public void render(GLES20 unused, Renderable parent) {
if (myNodes == null)
return;
{
for (int i = 0; i < myNodes.myLength; i++) {
myNodes.get(i).render(,/*gl,*/ this);
myNodes.get(i).render(unused, this);
}
}
{
if ((isPath || useEdges) && myEdges != null) {
for (int i = 0; i < myEdges.myLength; i++) {
myEdges.get(i).render(,/*gl,*/ this);
myEdges.get(i).render(unused, this);
}
}
}
Expand Down Expand Up @@ -612,10 +612,7 @@ public boolean isEmpty() {

@Override
public boolean isCleared() {
if (getAllItems().myLength == 0 && isClearedAtLeastOneTime) {
return true;
}
return false;
return getAllItems().myLength == 0 && isClearedAtLeastOneTime;
}

@Override
Expand Down Expand Up @@ -644,9 +641,7 @@ public boolean isUsingItsEdges() {
}

public boolean hasEdges() {
if (myEdges != null && myEdges.myLength > 0)
return true;
return false;
return myEdges != null && myEdges.myLength > 0;
}

public EfficientList<GeoObj> getConnectedNodesOf(GeoObj obj) {
Expand Down
12 changes: 5 additions & 7 deletions droidar/src/main/java/geo/GeoObj.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ public MeshComponent getGraphicsComponent() {
}

@Override
public void setComp(Entity comp) {
if (comp instanceof MeshComponent) {
public void setComp(Entity uniqueCompName) {
if (uniqueCompName instanceof MeshComponent) {
MeshComponent g = getMySurroundGroup();
g.removeAllChildren();
g.addChild((MeshComponent) comp);
g.addChild((MeshComponent) uniqueCompName);
setMyGraphicsComponent(g);
/*
* if the surround-group was not jet added to the GeoObj it will be
Expand All @@ -196,7 +196,7 @@ public void setComp(Entity comp) {
getMyComponents().add(g);
}
} else
super.setComp(comp);
super.setComp(uniqueCompName);
}

/*
Expand Down Expand Up @@ -582,9 +582,7 @@ private static double distFrom(double lat1, double lng1, double lat2,

public boolean hasSameCoordsAs(GeoObj o) {
if (o.getLatitude() == getLatitude()) {
if (o.getLongitude() == getLongitude()) {
return true;
}
return o.getLongitude() == getLongitude();
}
return false;
}
Expand Down
4 changes: 1 addition & 3 deletions droidar/src/main/java/gl/scenegraph/RenderList.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public boolean update(float timeDelta, Updateable parent) {
myItems.remove(myItems.get(i));
}
}
if (myItems.myLength == 0)
return false;
return true;
return myItems.myLength != 0;
}

@Override
Expand Down
4 changes: 1 addition & 3 deletions droidar/src/main/java/gui/MetaInfos.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ public MetaInfos getSelectedInfos() {
}

public boolean isSelected() {
if (mySelectedInfos != null)
return true;
return false;
return mySelectedInfos != null;
}

public boolean setDeselected() {
Expand Down
Loading

0 comments on commit 242b55f

Please sign in to comment.