DropHelper.Options.Builder
public final class DropHelper.Options.Builder
Builder for constructing a DropHelper.Options instance.
Summary
Public constructors |
|---|
Builder() |
Public methods |
|
|---|---|
@NonNull DropHelper.Options.Builder |
addInnerEditTexts(@NonNull EditText[] editTexts)Enables you to specify the |
@NonNull DropHelper.Options |
build()Builds a new |
@NonNull DropHelper.Options.Builder |
setAcceptDragsWithLocalState(boolean acceptDragsWithLocalState)Sets whether or not the app should respond to drag events when the drag operation contains |
@NonNull DropHelper.Options.Builder |
setHighlightColor(@ColorInt int highlightColor)Sets the color of the drop target highlight. |
@NonNull DropHelper.Options.Builder |
setHighlightCornerRadiusPx(int highlightCornerRadiusPx)Sets the corner radius of the drop target highlight. |
Public constructors
Public methods
addInnerEditTexts
public @NonNull DropHelper.Options.Builder addInnerEditTexts(@NonNull EditText[] editTexts)
Enables you to specify the EditText elements contained within the drop target. 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.
If the user is dragging text data and URI data in the drag and drop ClipData, one of the EditText elements in the drop target is selected to handle the text data. Selection is based on the following order of precedence:
- The
EditText(if any) on which theClipDatawas dropped - The
EditText(if any) that contains the text cursor (caret) - The first
EditTextprovided ineditTexts
To set the default EditText, make it the first argument of the editTexts parameter. For example, if your drop target handles images and contains two editable text fields, T1 and T2, make T2 the default by calling addInnerEditTexts(T2, T1).
Note: Behavior is undefined if EditTexts are added to or removed from the drop target after this method has been called.
See DropHelper for more information.
| Parameters | |
|---|---|
@NonNull EditText[] editTexts |
The |
| Returns | |
|---|---|
@NonNull DropHelper.Options.Builder |
This |
build
public @NonNull DropHelper.Options build()
Builds a new DropHelper.Options instance.
| Returns | |
|---|---|
@NonNull DropHelper.Options |
A new |
setAcceptDragsWithLocalState
public @NonNull DropHelper.Options.Builder setAcceptDragsWithLocalState(boolean acceptDragsWithLocalState)
Sets whether or not the app should respond to drag events when the drag operation contains local state. By default, the app does not respond to drag events that have local state. Setting local state is only possible when the drag operation originated from the current activity.
Note: To elicit the default behavior of ignoring drags from the same activity as the drop target, the local state supplied when starting the drag (via startDragAndDrop or using androidx.core.view.DragStartHelper) must be non-null.
| Parameters | |
|---|---|
boolean acceptDragsWithLocalState |
Whether or not to accept drag events with non-null local state. |
| Returns | |
|---|---|
@NonNull DropHelper.Options.Builder |
This |
setHighlightColor
public @NonNull DropHelper.Options.Builder setHighlightColor(@ColorInt int highlightColor)
Sets the color of the drop target highlight. The highlight is shown during a drag and drop operation when data is dragged over the drop target and a MIME type in the ClipDescription matches a MIME type provided to DropHelper#configureView.
Note: Opacity, if provided, is ignored.
| Parameters | |
|---|---|
@ColorInt int highlightColor |
The highlight color. |
| Returns | |
|---|---|
@NonNull DropHelper.Options.Builder |
This |
setHighlightCornerRadiusPx
public @NonNull DropHelper.Options.Builder setHighlightCornerRadiusPx(int highlightCornerRadiusPx)
Sets the corner radius of the drop target highlight. The highlight is shown during a drag and drop operation when data is dragged over the drop target and a MIME type in the ClipDescription matches a MIME type provided to DropHelper#configureView.
| Parameters | |
|---|---|
int highlightCornerRadiusPx |
The highlight corner radius in pixels. |
| Returns | |
|---|---|
@NonNull DropHelper.Options.Builder |
This |