Back to project page 101AndroidApps.
The source code is released under:
Licenced under the Creative Commons Attribution 4.0 licence. For full text see http://creativecommons.org/licenses/by/4.0/
If you think the Android project 101AndroidApps listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.hulzenga.ioi.android.app_005; // ww w .jav a2s . co m import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.view.View; import android.widget.ImageView; import com.hulzenga.ioi.android.R; class ElementView extends ImageView { private int mPosition; public ElementView(Context context) { this(context, 0); } public ElementView(Context context, int position) { super(context); mPosition = position; } public int getPosition() { return mPosition; } public void setPosition(int position) { mPosition = position; } public static class DragShadowBuilder extends View.DragShadowBuilder { private BitmapDrawable shadow; public DragShadowBuilder(ElementView view, Element element) { shadow = new BitmapDrawable(view.getContext().getResources(), element.getShadow()); shadow.setBounds(0, 0, shadow.getBitmap().getWidth(), shadow.getBitmap().getHeight()); } @Override public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) { shadowSize.set(shadow.getBounds().right, shadow.getBounds().bottom); shadowTouchPoint.set(shadow.getBounds().right, shadow.getBounds().bottom); } @Override public void onDrawShadow(Canvas canvas) { shadow.draw(canvas); } } }