blob: 29cf15a5c7a26e5297754d186015436d4bcc61bc [file] [log] [blame]
The Android Open Source Project31dd5032009-03-03 19:32:27 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.launcher;
18
19import android.view.View;
20
21/**
22 * Interface for initiating a drag within a view or across multiple views.
23 *
24 */
25public interface DragController {
26
27 /**
28 * Interface to receive notifications when a drag starts or stops
29 */
30 interface DragListener {
31
32 /**
33 * A drag has begun
34 *
35 * @param v The view that is being dragged
36 * @param source An object representing where the drag originated
37 * @param info The data associated with the object that is being dragged
38 * @param dragAction The drag action: either {@link DragController#DRAG_ACTION_MOVE}
39 * or {@link DragController#DRAG_ACTION_COPY}
40 */
41 void onDragStart(View v, DragSource source, Object info, int dragAction);
42
43 /**
44 * The drag has eneded
45 */
46 void onDragEnd();
47 }
48
49 /**
50 * Indicates the drag is a move.
51 */
52 public static int DRAG_ACTION_MOVE = 0;
53
54 /**
55 * Indicates the drag is a copy.
56 */
57 public static int DRAG_ACTION_COPY = 1;
58
59 /**
60 * Starts a drag
61 *
62 * @param v The view that is being dragged
63 * @param source An object representing where the drag originated
64 * @param info The data associated with the object that is being dragged
65 * @param dragAction The drag action: either {@link #DRAG_ACTION_MOVE} or
66 * {@link #DRAG_ACTION_COPY}
67 */
68 void startDrag(View v, DragSource source, Object info, int dragAction);
69
70 /**
71 * Sets the drag listner which will be notified when a drag starts or ends.
72 */
73 void setDragListener(DragListener l);
74
75 /**
76 * Remove a previously installed drag listener.
77 */
78 void removeDragListener(DragListener l);
79}