TrashCanView

public class TrashCanView extends ImageView

Drop target view for deleting blocks via a drag gesture, with animation.

This view has two layout attributes, closedIcon and openedIcon. Each is a reference to a drawable resource for one of the two trash states, closed (default/idle state) and opened (pending drop during drag). The TrashCanView assumes both drawables are the same size, so the overall view will not change size when the state changes.

Nested Class Summary

@interface TrashCanView.HoverState  

Inherited Constant Summary

Field Summary

protected Drawable mDefaultDrawable
protected Drawable mOnHoverDrawable
protected int mState

Inherited Field Summary

Public Constructor Summary

TrashCanView(Context context)
TrashCanView(Context context, AttributeSet attrs)
TrashCanView(Context context, AttributeSet attrs, int defStyleAttr)

Public Method Summary

void
setDefaultIcon(int drawableRes)
Assigns a drawable resource id for the default state, when no block is hovering with a pending drop.
void
setDefaultIcon(Drawable drawable)
Assigns a drawable resource if for the default state, when no block is hovering with a pending drop.
void
setOnDragListener(View.OnDragListener dragListener)
void
setOnHoverIcon(Drawable drawable)
Assigns a drawable for the hovered state, when a block has been dragged above this view.
void
setOnHoverIcon(int drawableRes)
Assigns a drawable resource id for the hovered state, when a block has been dragged above this view.
void
setState(int state)

Protected Method Summary

void

Inherited Method Summary

Fields

protected Drawable mDefaultDrawable

protected Drawable mOnHoverDrawable

protected int mState

Public Constructors

public TrashCanView (Context context)

Parameters
context

public TrashCanView (Context context, AttributeSet attrs)

Parameters
context
attrs

public TrashCanView (Context context, AttributeSet attrs, int defStyleAttr)

Parameters
context
attrs
defStyleAttr

Public Methods

public void setDefaultIcon (int drawableRes)

Assigns a drawable resource id for the default state, when no block is hovering with a pending drop. Usually, this is a closed trashcan.

Parameters
drawableRes Default drawable resource id.

public void setDefaultIcon (Drawable drawable)

Assigns a drawable resource if for the default state, when no block is hovering with a pending drop. Usually, this is a closed trashcan.

Parameters
drawable Default drawable.

public void setOnDragListener (View.OnDragListener dragListener)

Parameters
dragListener

public void setOnHoverIcon (Drawable drawable)

Assigns a drawable for the hovered state, when a block has been dragged above this view. Usually, this is a open trashcan.

public void setOnHoverIcon (int drawableRes)

Assigns a drawable resource id for the hovered state, when a block has been dragged above this view. Usually, this is a open trashcan.

Parameters
drawableRes Drawable resource id for the hovered

public void setState (int state)

Parameters
state

Protected Methods

protected void onAttachedToWindow ()