Created
February 20, 2018 09:24
-
-
Save vorobeij/18e2b39399f1e4a0115a53f317a2b13e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // set on long click listener | |
| launcherGrid.setOnItemLongClickListener { parent, view, position, id -> | |
| Timber.d("jsp grid item id=$id pos=$position long clicked") | |
| launcherAdapter().startDrag(view, position) | |
| false | |
| } | |
| data class DragData(val view: View, | |
| val position: Int) | |
| private fun startDrag(view:View, pos:Int) { | |
| val dragData = DragData(view, pos) | |
| val clipData = ClipData.newPlainText("", "") | |
| val v = dragData.view | |
| val shadowBuilder = View.DragShadowBuilder(v) | |
| @Suppress("DEPRECATION") // by now compile for api > 21 why do i need to check here? | |
| v.startDrag(clipData, shadowBuilder, dragData, 0) | |
| Timber.d("mc drag drop activated") | |
| } | |
| private fun startDrag(dragData: DragData) { | |
| dragDataX = dragData | |
| Timber.i("mc onDragEventStart(dragData=(container=${dragData.containerId}, " + "pos=${dragData.position}, type=${dragData.type}, " + "appItemId=${dragData.appItemId}, " + "folder=${dragData.folderItemId})") | |
| val clipData = ClipData.newPlainText("", "") | |
| val v = dragData.dragShadow | |
| val shadowBuilder = View.DragShadowBuilder(v) | |
| @Suppress("DEPRECATION") // by now compile for api > 21 why do i need to check here? | |
| v.startDrag(clipData, shadowBuilder, dragData, 0) | |
| Timber.d("mc drag drop activated") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment