Move Tuple4 out of CanvasView and create Tuple2.

This commit is contained in:
kenkeiras 2017-07-22 17:46:24 -04:00
parent dcbc0e5cad
commit b37e5e1ae1
4 changed files with 49 additions and 22 deletions

View File

@ -21,6 +21,7 @@ import com.codigoparallevar.minicards.types.Part;
import com.codigoparallevar.minicards.types.PartGrid;
import com.codigoparallevar.minicards.types.Position;
import com.codigoparallevar.minicards.types.Selectable;
import com.codigoparallevar.minicards.types.Tuple4;
import org.json.JSONArray;
import org.json.JSONException;
@ -54,7 +55,7 @@ class CanvasView extends View implements PartGrid {
private final static float touchTimeForLongTouchInMillis = 500;
private boolean _isDragging = false;
private MainActivity parentActivity = null;
private Tuple<Integer, Integer, Integer, Integer> _dropToRemoveZone = new Tuple<>(0, 0, 0, 0);
private Tuple4<Integer, Integer, Integer, Integer> _dropToRemoveZone = new Tuple4<>(0, 0, 0, 0);
private boolean _devMode = false;
public CanvasView(Context context) {
@ -362,31 +363,11 @@ class CanvasView extends View implements PartGrid {
}
public void setDropZone(float x1, float x2, float y1, float y2) {
_dropToRemoveZone = new Tuple<>((int) x1, (int) x2, (int) y1, (int) y2);
_dropToRemoveZone = new Tuple4<>((int) x1, (int) x2, (int) y1, (int) y2);
}
public void setDevMode(boolean devMode) {
_devMode = devMode;
this.invalidate();
}
private class Tuple<T, T1, T2, T3> {
final T _x1;
final T1 _x2;
final T2 _y1;
final T3 _y2;
public Tuple(T x1, T1 x2, T2 y1, T3 y2) {
_x1 = x1;
_x2 = x2;
_y1 = y1;
_y2 = y2;
}
@Override
public String toString(){
return "(" + _x1 + " - " + _x2 + ", " + _y1 + " - " + _y2 + ")";
}
}
}

View File

@ -0,0 +1,14 @@
package com.codigoparallevar.minicards.parts;
import com.codigoparallevar.minicards.types.Part;
public class PartConnection {
public final Part outputPart;
public final String inputPartId;
public PartConnection(Part outputPart, String inputPartId) {
this.outputPart = outputPart;
this.inputPartId = inputPartId;
}
}

View File

@ -0,0 +1,11 @@
package com.codigoparallevar.minicards.parts;
public class Tuple<T1, T2> {
public final T1 item1;
public final T2 item2;
public Tuple(T1 item1, T2 item2) {
this.item1 = item1;
this.item2 = item2;
}
}

View File

@ -0,0 +1,21 @@
package com.codigoparallevar.minicards.types;
public class Tuple4<T, T1, T2, T3> {
public final T _x1;
public final T1 _x2;
public final T2 _y1;
public final T3 _y2;
public Tuple4(T x1, T1 x2, T2 y1, T3 y2) {
_x1 = x1;
_x2 = x2;
_y1 = y1;
_y2 = y2;
}
@Override
public String toString(){
return "(" + _x1 + " - " + _x2 + ", " + _y1 + " - " + _y2 + ")";
}
}