private final static PorterDuffXfermode sAddBlendMode =
new PorterDuffXfermode(PorterDuff.Mode.ADD);
+ private final static Paint sPaint = new Paint();
public CellLayout(Context context) {
this(context, null);
}
public void enableHardwareLayers() {
- mShortcutsAndWidgets.setLayerType(LAYER_TYPE_HARDWARE, null);
+ mShortcutsAndWidgets.setLayerType(LAYER_TYPE_HARDWARE, sPaint);
}
public void disableHardwareLayers() {
- mShortcutsAndWidgets.setLayerType(LAYER_TYPE_NONE, null);
+ mShortcutsAndWidgets.setLayerType(LAYER_TYPE_NONE, sPaint);
}
public void buildHardwareLayer() {
public void show(int touchX, int touchY) {
mDragLayer.addView(this);
- // Enable hw-layers on this view
- setLayerType(View.LAYER_TYPE_HARDWARE, null);
-
// Start the pick-up animation
DragLayer.LayoutParams lp = new DragLayer.LayoutParams(0, 0);
lp.width = mBitmap.getWidth();
setLayoutParams(lp);
setTranslationX(touchX - mRegistrationX);
setTranslationY(touchY - mRegistrationY);
- mAnim.start();
+ // Post the animation to skip other expensive work happening on the first frame
+ post(new Runnable() {
+ public void run() {
+ mAnim.start();
+ }
+ });
}
public void cancelAnimation() {
void remove() {
if (getParent() != null) {
- // Disable hw-layers on this view
- setLayerType(View.LAYER_TYPE_NONE, null);
-
mDragLayer.removeView(DragView.this);
}
}