diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintActivity.java b/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintActivity.java index 57741c6..c262372 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintActivity.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintActivity.java @@ -19,6 +19,7 @@ import org.ntlab.acanthus_client.entities.Position; import org.ntlab.acanthus_client.entities.Stroke; +import java.util.ArrayList; import java.util.Collection; //----------------------------------------------------------------- @@ -30,7 +31,8 @@ private PaintScreenShot paintScreenShot; private ActivityPaintBinding binding; private PaintViewModel paintViewModel; - + private int laststrokesize=0; + private float lastpositionx=0; private boolean buttonView = false; //----------------------------------------------------------------- @@ -135,21 +137,30 @@ paintViewModel.getStroke().observe(this, new Observer>() { @Override public void onChanged(Collection strokes) { - paintCanvas.getCanvas(); + ArrayList s = new ArrayList<>(strokes); + paintCanvas.getCanvas(strokes); + try{ + lastpositionx = s.get(s.size()-1).getPositions().get(s.get(s.size()-1).getPositions().size()-1).getX(); + }catch (ArrayIndexOutOfBoundsException ex){ } } }); //1時的コメントアウトここから - // paintViewModel.getmStrokeNo().observe(this, new Observer() { -// @Override -// public void onChanged(Integer integer) { -// paintViewModel.getPosition(integer); -// } -// }); + paintViewModel.getmStrokeNo().observe(this, new Observer() { + @Override + public void onChanged(Integer integer) { + if(laststrokesize!=integer || lastpositionx != -1) { + paintViewModel.getStrokes(); + laststrokesize=integer; + } + //paintViewModel.getPosition(integer); + } + }); // paintViewModel.getMlatestPosition().observe(this, new Observer>() { // @Override // public void onChanged(Collection positions) { -// if(positions.size()!=1){ -// //paintCanvas.latestPositionWrite(positions); +// if((positions.size()!=1) && (positions.size()!=lastpositionsize)){ +// paintCanvas.latestPositionWrite(positions); +// lastpositionsize=positions.size(); // } // } // });