2 * This is a modified version of a class from the Android Open Source Project.
3 * The original copyright and license information follows.
5 * Copyright (C) 2008 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 package com.blahti.drag;
22 import android.graphics.Rect;
25 * Interface defining an object that can receive a view at the end of a drag operation.
28 public interface DropTarget {
31 * Handle an object being dropped on the DropTarget
33 * @param source DragSource where the drag started
34 * @param x X coordinate of the drop location
35 * @param y Y coordinate of the drop location
36 * @param xOffset Horizontal offset with the object being dragged where the original
38 * @param yOffset Vertical offset with the object being dragged where the original
40 * @param dragView The DragView that's being dragged around on screen.
41 * @param dragInfo Data associated with the object being dragged
44 void onDrop(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo);
46 void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo);
48 void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo);
50 void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo);
53 * Check if a drop action can occur at, or near, the requested location.
54 * This may be called repeatedly during a drag, so any calls should return
57 * @param source DragSource where the drag started
58 * @param x X coordinate of the drop location
59 * @param y Y coordinate of the drop location
60 * @param xOffset Horizontal offset with the object being dragged where the
61 * original touch happened
62 * @param yOffset Vertical offset with the object being dragged where the
63 * original touch happened
64 * @param dragView The DragView that's being dragged around on screen.
65 * @param dragInfo Data associated with the object being dragged
66 * @return True if the drop will be accepted, false otherwise.
68 boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo);
71 * Estimate the surface area where this object would land if dropped at the
74 * @param source DragSource where the drag started
75 * @param x X coordinate of the drop location
76 * @param y Y coordinate of the drop location
77 * @param xOffset Horizontal offset with the object being dragged where the
78 * original touch happened
79 * @param yOffset Vertical offset with the object being dragged where the
80 * original touch happened
81 * @param dragView The DragView that's being dragged around on screen.
82 * @param dragInfo Data associated with the object being dragged
83 * @param recycle {@link Rect} object to be possibly recycled.
84 * @return Estimated area that would be occupied if object was dropped at
85 * the given location. Should return null if no estimate is found,
86 * or if this target doesn't provide estimations.
88 Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo, Rect recycle);
90 // These methods are implemented in Views
91 void getHitRect(Rect outRect);
92 void getLocationOnScreen(int[] loc);