@Override public boolean onTouchEvent(MotionEvent ev) { final int action = ev.getAction(); if (action == MotionEvent.ACTION_DOWN) { final ClipData clip = mClipping; if (clip != null) { final Bitmap icon = clip.getIcon(); DragShadowBuilder shadow; if (icon != null) { shadow = new DragShadowBuilder(this) { public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) { shadowSize.set(icon.getWidth(), icon.getHeight()); shadowTouchPoint.set(shadowSize.x / 2, shadowSize.y / 2); } public void onDrawShadow(Canvas canvas) { canvas.drawBitmap(icon, 0, 0, new Paint()); } }; } else { // uhhh, what now? shadow = new DragShadowBuilder(this); } startDrag(clip, shadow, null, 0); // TODO: only discard the clipping if it was accepted stash(null); return true; } } return false; }
private void stash(ClipData clipping) { mClipping = clipping; if (mClipping != null) { setVisibility(View.VISIBLE); Bitmap icon = mClipping.getIcon(); // mDescription.setText(mClipping.getDescription().getLabel()); if (icon != null) { setImageBitmap(icon); } else { if (mClipping.getItemCount() > 0) { // TODO: figure out how to visualize every kind of ClipData! // mAltText.setText(mClipping.getItemAt(0).coerceToText(getContext())); } } } else { setVisibility(View.GONE); } }