Skip to content
Snippets Groups Projects
Commit a84130d4 authored by SCHILLING Juliette's avatar SCHILLING Juliette
Browse files

pbm id resolu (enfin !)

parent d2fd9e39
No related branches found
No related tags found
No related merge requests found
......@@ -168,44 +168,64 @@ public class CreationOuvertureActivity extends AppCompatActivity{
imageViewDepart.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getPointerCount() == 2) {
float x1, x2, y1, y2;
x1 = event.getX(0);
y1 = event.getY(0);
x2 = event.getX(1);
y2 = event.getY(1);
Log.i("SelectActivity", "################################################# Coords : " + x1 + " | " + y1 + " & " + x2 + " | " + y2);
rectDepart = new Rect((int) x1, (int) y1, (int) x2, (int) y2);
rectDepart.sort();
try {
canvasDepart = surfaceViewDepart.getHolder().lockCanvas();
synchronized (surfaceViewDepart.getHolder()) {
canvasDepart.drawColor(0, PorterDuff.Mode.CLEAR);
canvasDepart.drawRect(rectDepart, myPaint);
if (pieceEnCours != null) {
if (event.getPointerCount() == 2) {
float x1, x2, y1, y2;
x1 = event.getX(0);
y1 = event.getY(0);
x2 = event.getX(1);
y2 = event.getY(1);
Log.i("SelectActivity", "################################################# Coords : " + x1 + " | " + y1 + " & " + x2 + " | " + y2);
if (pieceEnCours.equals(pieceDepart)) {
rectDepart = new Rect((int) x1, (int) y1, (int) x2, (int) y2);
rectDepart.sort();
try {
canvasDepart = surfaceViewDepart.getHolder().lockCanvas();
synchronized (surfaceViewDepart.getHolder()) {
canvasDepart.drawColor(0, PorterDuff.Mode.CLEAR);
canvasDepart.drawRect(rectDepart, myPaint);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (canvasDepart != null) {
surfaceViewDepart.getHolder().unlockCanvasAndPost(canvasDepart);
}
}
} else {
rectArrivee = new Rect((int) x1, (int) y1, (int) x2, (int) y2);
rectArrivee.sort();
try {
canvasDepart = surfaceViewDepart.getHolder().lockCanvas();
synchronized (surfaceViewDepart.getHolder()) {
canvasDepart.drawColor(0, PorterDuff.Mode.CLEAR);
canvasDepart.drawRect(rectArrivee, myPaint);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (canvasDepart != null) {
surfaceViewDepart.getHolder().unlockCanvasAndPost(canvasDepart);
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (canvasDepart != null) {
surfaceViewDepart.getHolder().unlockCanvasAndPost(canvasDepart);
}
}
//Log.i("SelectActivity", "################################################# Coords Rect : " + rect.left + " | " + rect.top + " & " + rect.right + " | " + rect.bottom);
//Log.i("SelectActivity", "################################################# Coords Rect : " + rect.left + " | " + rect.top + " & " + rect.right + " | " + rect.bottom);
}
if (event.getAction() == MotionEvent.ACTION_UP) {
if (rectDepart != null) {
Log.i("Touchup", "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ je releve mon doigt");
}
if (event.getAction() == MotionEvent.ACTION_UP) {
if (rectDepart != null) {
Log.i("Touchup", "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ je releve mon doigt");
//showImage();
//showImage();
}
}
}
return true;
}
});
......
......@@ -9,6 +9,7 @@ import outils.FabriqueId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
public class Habitat implements Parcelable {
......@@ -109,4 +110,15 @@ public class Habitat implements Parcelable {
public void reset(){
pieces.clear();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
return false;
}
@Override
public int hashCode() {
return Objects.hash(pieces);
}
}
......@@ -8,6 +8,8 @@ import org.json.JSONException;
import org.json.JSONObject;
import outils.FabriqueId;
import java.util.Objects;
public class Mur implements Parcelable {
private Habitat habitat;
......@@ -135,4 +137,16 @@ public class Mur implements Parcelable {
}
return jsonObject;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
return id == ((Mur) o).getId() && Objects.equals(habitat, ((Mur) o).getHabitat()) && Objects.equals(piece, ((Mur) o).getPiece()) && orientation == ((Mur) o).getOrientation();
}
@Override
public int hashCode() {
return Objects.hash(habitat, piece, orientation, id);
}
}
......@@ -7,6 +7,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Objects;
public class Piece implements Parcelable {
private Habitat habitat;
......@@ -142,4 +143,16 @@ public class Piece implements Parcelable {
}
return jsonObject;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
return Objects.equals(habitat, ((Piece) o).getHabitat()) && Objects.equals(nom, ((Piece) o).getNom()) && Objects.equals(murs, ((Piece) o).getMurs());
}
@Override
public int hashCode() {
return Objects.hash(habitat, nom, murs);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment