public void handleMessage(Message msg) { Ball B; for (int idx = 0; idx < arBall.size(); idx++) { B = arBall.get(idx); B.Move(getWidth(), getHeight()); if (B.count > 4) { arBall.remove(idx); idx--; } } invalidate(); mHandler.sendEmptyMessageDelayed(0, DELAY); }
public void addFreeSquares(ArrayList<Point> points) { // add all squares for (int i = 0; i < GRID_WIDTH; i++) { for (int j = 0; j < GRID_HEIGHT; j++) { points.add(new Point(i, j)); } } // remove all pieces for (Piece piece : game.getPieces()) { if (!piece.isOut()) { points.remove(piece.getLocation()); } } }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (backStack.size() > 1) { backStack.remove(backStack.size() - 1); wrapFiles(); } else { Intent intent = new Intent(); setResult(RESULT_CANCELED, intent); finish(); } return true; } return super.onKeyDown(keyCode, event); }
@Override public void onItemClick(AdapterView<?> aListView, View aView, int aPosition, long aID) { final FileWrapper item = adapter.getItem(aPosition); if (item.parentItem && backStack.get(backStack.size() - 1).parentIsBack) { backStack.remove(backStack.size() - 1); wrapFiles(); return; } else if (item.dirSelectItem) { finishWithPath(listedDirectory.getAbsolutePath()); return; } final File selected = item.parentItem ? listedDirectory.getParentFile() : item.file; if (selected.isDirectory()) { backStack.add(new BackStackItem(selected.getAbsolutePath(), !item.parentItem)); wrapFiles(); } else { String filePath = selected.getAbsolutePath(); finishWithPath(filePath); } }