Skip to content

Instantly share code, notes, and snippets.

@pflammertsma
Last active December 16, 2021 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pflammertsma/941ce0e283fb2d792715bd46ebef0d66 to your computer and use it in GitHub Desktop.
Save pflammertsma/941ce0e283fb2d792715bd46ebef0d66 to your computer and use it in GitHub Desktop.
Sample of DropHelper
/* Copyright 2021 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
DropHelper.configureView(
// Activity that will handle the drop
this,
// Target drop view to be highlighted
outerDropTarget,
// Supported MIME types
arrayOf(MIMETYPE_TEXT_PLAIN, "image/*"),
// Options for configuring drop targets
DropHelper.Options.Builder()
// To ensure proper drop target highlighting, all EditText elements in
// the drop target view hierarchy must be included in a call to this
// method. Otherwise, an EditText within the target, rather than the
// target view itself, acquires focus during the drag and drop operation.
.addInnerEditTexts(innerEditText)
.build()
) { _, payload ->
// Process the payload here, returning any content that should be delegated to
// the platform.
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment