private void drawCanUseSpace(Canvas canvas) {
try {
if (cellPosition != null && cellPosition.length >= 2 && workspace.isScrollerFinished()) {
CellLayout current = (CellLayout) workspace.getCurrentCellLayout();
if (current != null && !current.isOpenFolder()) {
Drawable canUseSpace = getResources().getDrawable(R.drawable.can_use_space);
current.cellToPoint(cellPosition[0], cellPosition[1], position);
int x = position[0];
int y = position[1] + GREEN_RECT_TOP_OFFSET;
int w = x + current.getCellWidth() * dragObjectInfo.spanX
+ (current.getLongAxisCells() - dragObjectInfo.cellX) * current.getWidthGap();
int h = position[1] + (current.getCellHeight()) * dragObjectInfo.spanY
+ (current.getShortAxisCells() - dragObjectInfo.cellY) * current.getHeightGap();
matrix.setScale(CellLayout.REDUCE_FINAL_VALUE, CellLayout.REDUCE_FINAL_VALUE,
getWidth() / 2, getHeight() / 2);
canvas.save();
canvas.concat(matrix);
canUseSpace.setBounds(x, y, w, h);
canUseSpace.draw(canvas);
canvas.restore();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void startWingsAnimation(float start, float end, float increment, long sleepTime) {
if (transferAt != null) {
transferAt.stopAnimation();
}
transferAt = new AnimationThread(this, start, end, increment, sleepTime);
transferAt.setOnListener(transferAtListener);
transferAt.start();
}
private class DragLayerAnimationThread implements AnimationThread.AnimationListener {
public static final int MOVE_IN = 0;
public static final int MOVE_OUT = 1;
public static final int MOVE_FINISH = 2;
private int animationState = MOVE_IN;
public void onEnd() {
animationState++;
if (!mDragging || animationState == MOVE_FINISH) {
changeWingsAnimationState = false;
clearAnimationState();
}
if (!changeWingsAnimationState) {
doNotWingsAnimation();
}
}
public void onError() {
}
public void onStart() {
}
public void clearAnimationState() {
animationState = MOVE_IN;
}
public int getAnimationState() {
return animationState;
}
}
try {
if (cellPosition != null && cellPosition.length >= 2 && workspace.isScrollerFinished()) {
CellLayout current = (CellLayout) workspace.getCurrentCellLayout();
if (current != null && !current.isOpenFolder()) {
Drawable canUseSpace = getResources().getDrawable(R.drawable.can_use_space);
current.cellToPoint(cellPosition[0], cellPosition[1], position);
int x = position[0];
int y = position[1] + GREEN_RECT_TOP_OFFSET;
int w = x + current.getCellWidth() * dragObjectInfo.spanX
+ (current.getLongAxisCells() - dragObjectInfo.cellX) * current.getWidthGap();
int h = position[1] + (current.getCellHeight()) * dragObjectInfo.spanY
+ (current.getShortAxisCells() - dragObjectInfo.cellY) * current.getHeightGap();
matrix.setScale(CellLayout.REDUCE_FINAL_VALUE, CellLayout.REDUCE_FINAL_VALUE,
getWidth() / 2, getHeight() / 2);
canvas.save();
canvas.concat(matrix);
canUseSpace.setBounds(x, y, w, h);
canUseSpace.draw(canvas);
canvas.restore();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void startWingsAnimation(float start, float end, float increment, long sleepTime) {
if (transferAt != null) {
transferAt.stopAnimation();
}
transferAt = new AnimationThread(this, start, end, increment, sleepTime);
transferAt.setOnListener(transferAtListener);
transferAt.start();
}
private class DragLayerAnimationThread implements AnimationThread.AnimationListener {
public static final int MOVE_IN = 0;
public static final int MOVE_OUT = 1;
public static final int MOVE_FINISH = 2;
private int animationState = MOVE_IN;
public void onEnd() {
animationState++;
if (!mDragging || animationState == MOVE_FINISH) {
changeWingsAnimationState = false;
clearAnimationState();
}
if (!changeWingsAnimationState) {
doNotWingsAnimation();
}
}
public void onError() {
}
public void onStart() {
}
public void clearAnimationState() {
animationState = MOVE_IN;
}
public int getAnimationState() {
return animationState;
}
}