Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Android Drag and Drop framework in My custom Launcher app

I am trying to develop custom launcher app (with unlimited number of home pages)and i need to implement Drag and Drop as done in Launcher2(android 4.2).

So i found two approaches

1) Drag and Drop framework
2) Use the android launcher2 way like implementation DragController, DragSource as explained here.

But i am struggling to understand why didn't Android guys didn't use the Drag and Drop framework developed by them in their own application. Can anyone brief regarding possible rationale behind their approach?( i mean in terms of memory/performance)

Thanks in advance.

like image 908
manjusg Avatar asked Jan 21 '13 18:01

manjusg


People also ask

How do I add drag and drop to Android?

After the user releases the drag shadow, and after the system sends out (if necessary) a drag event with action type ACTION_DROP , the system sends a drag event with action type ACTION_DRAG_ENDED to indicate that the drag and drop operation is over. This is done regardless of where the user released the drag shadow.

What is drag listener?

The drag event listener receives a ACTION_DRAG_EXITED action after the user has moved the drag shadow outside the bounding box of the View. Dropped − The user releases the dragged item within the bounding box of a View. The system sends the View object's listener a drag event with action type ACTION_DROP.

How do I drag an image in Android Studio?

There is no direct way to do drag and drop in Android. You have to write some classes. Look into DragController. java, DragLayer.


2 Answers

The Android drag and drop framework is very basic as compared to the one used in the Launcher app.

The Launcher app has a myriad of "layers" and the drag and drop occurs accross these layers, namely the DragLayer, Workspace and the All Apps view etc. It uses window flags and dynamically adds/removes views to the DragLayer when a drag is in progress and a multitude of activities monitor the drag. For more details look at the DragLayer.java and Workspace.java files particularly.

like image 111
Jignesh Shah Avatar answered Sep 21 '22 13:09

Jignesh Shah


Drag and Drop in Android Launcher is done as Overlay drawing within the same ViewGroup and in same window . But android drag and drop approach creates a separate window with a separate window type altogether .

Resource and memory wise standard android drag and drop approach is costlier.

If performance is very critical my suggestion is go as per Android launcher way else prefer standard android approach its easy and simple.

like image 45
manjusg Avatar answered Sep 20 '22 13:09

manjusg