diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/paint/MyPaint.java b/app/src/main/java/org/ntlab/acanthus_client/views/paint/MyPaint.java index 1fbf18b..7811213 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/paint/MyPaint.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/paint/MyPaint.java @@ -19,6 +19,7 @@ import androidx.annotation.Nullable; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; + import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -45,7 +46,7 @@ paint.setColor(Color.RED);//色の指定 paint.setStyle(Paint.Style.STROKE);//線をひく paint.setStrokeWidth(20);//幅 - this.acanthus= new Acanthus(); + this.acanthus = new Acanthus(); this.strokeNo = new MutableLiveData(); } @@ -54,7 +55,7 @@ @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); - canvas.drawPath(path,paint); + canvas.drawPath(path, paint); } @@ -69,15 +70,15 @@ ylen.add(y); //(3-2)タッチの処理 - switch (event.getAction()){ + switch (event.getAction()) { case MotionEvent.ACTION_DOWN: - path.moveTo(x,y); + path.moveTo(x, y); addStrokes(getAcanthus()); invalidate(); break; case MotionEvent.ACTION_MOVE: - path.lineTo(x,y); - AddPositions(x,y,getStrokeNo()); + path.lineTo(x, y); + AddPositions(x, y, getStrokeNo()); invalidate(); break; case MotionEvent.ACTION_UP: @@ -90,16 +91,17 @@ //4)クリア処理 - public void clearCanvas(){ + public void clearCanvas() { System.out.println(xlen.toArray()); path.reset(); invalidate(); } - public void setAcanthus(Acanthus acanthus){ - this.acanthus=acanthus; + public void setAcanthus(Acanthus acanthus) { + this.acanthus = acanthus; } - public Acanthus getAcanthus(){ + + public Acanthus getAcanthus() { return acanthus; } @@ -114,20 +116,20 @@ ////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////// //retrofit - public void AddPositions(double x, double y ,MutableLiveData strokeno){ + public void AddPositions(double x, double y, MutableLiveData strokeno) { Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/") .addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(JacksonConverterFactory.create()) .build(); final StrokesRest strokesRest = retrofit.create(StrokesRest.class); - Call call = strokesRest.addPositions(1111,strokeno.getValue(),x,y); + Call call = strokesRest.addPositions(1111, strokeno.getValue(), x, y); call.enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { - if(response.isSuccessful()) { + if (response.isSuccessful()) { System.out.println("success"); - }else{ + } else { System.out.println("false"); } } @@ -140,21 +142,21 @@ } - public void addStrokes(Acanthus acanthus){ + public void addStrokes(Acanthus acanthus) { Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/") .addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(JacksonConverterFactory.create()) .build(); final StrokesRest strokesRest = retrofit.create(StrokesRest.class); - Call call = strokesRest.addStrokes(1111,acanthus.getPreferenceUid(),acanthus.getPreferenceToken(),1,1,1); + Call call = strokesRest.addStroke(1111, acanthus.getPreferenceUid(), acanthus.getPreferenceToken(), 1, 1, 1); call.enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { - if(response.isSuccessful()) { + if (response.isSuccessful()) { System.out.println("success"); setStrokeNo(response.body().intValue()); - }else{ + } else { System.out.println("false"); } }