示例#1
0
 private void drawPuzzles() {
   puzzles.forEach(
       new Matrix.OnEachHandler<Bitmap>() {
         @Override
         public void handle(Matrix<Bitmap> matrix, Position pos) {
           if (!existDraggedPuzzle() || !pos.equals(draggedPosition)) {
             Point leftUpper = leftUpperOfPuzzle(pos);
             Paint paint = paintForPosition(pos);
             Bitmap puzzle = puzzles.get(pos);
             canvas.drawBitmap(puzzle, leftUpper.x, leftUpper.y, paint);
           }
         }
       });
   if (existDraggedPuzzle()) {
     Bitmap draggedPuzzle = puzzles.get(draggedPosition);
     canvas.drawBitmap(draggedPuzzle, draggedLeftUpper.x, draggedLeftUpper.y, null);
   }
 }
示例#2
0
 private void cutIntoPuzzles() {
   puzzles.forEach(
       new Matrix.OnEachHandler<Bitmap>() {
         @Override
         public void handle(Matrix<Bitmap> matrix, Position pos) {
           matrix.set(pos, puzzleByPosition(pos));
         }
       });
 }
示例#3
0
 private void onUpTouch(Point pt) {
   if (!existDraggedPuzzle()) {
     return;
   }
   if (draggedAndNearestCanBeSwapped()) {
     puzzles.swap(nearestPosition, draggedPosition);
   }
   nearestPosition = null;
   draggingStopped();
   invalidate();
   if (puzzlesChecker.puzzleAssembled(puzzles)) {
     notifyThatPuzzleAssembled();
   }
 }
示例#4
0
 public void releaseImageResources() {
   if (!imageWasSet()) {
     return;
   }
   fullImage.recycle();
   puzzles.forEach(
       new Matrix.OnEachHandler<Bitmap>() {
         @Override
         public void handle(Matrix<Bitmap> matrix, Position pos) {
           Bitmap bitmap = matrix.get(pos);
           bitmap.recycle();
           matrix.set(pos, null);
         }
       });
 }