本文整理汇总了Java中android.view.DragEvent.ACTION_DRAG_LOCATION属性的典型用法代码示例。如果您正苦于以下问题:Java DragEvent.ACTION_DRAG_LOCATION属性的具体用法?Java DragEvent.ACTION_DRAG_LOCATION怎么用?Java DragEvent.ACTION_DRAG_LOCATION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.DragEvent
的用法示例。
在下文中一共展示了DragEvent.ACTION_DRAG_LOCATION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recordDragEvent
/**
* Same as {@link #recordMotionEvent}. It creates a temporary {@link MotionEvent} object
* using {@param event} for tracking velocity.
*/
void recordDragEvent(long dragStartTime, DragEvent event) {
final int motionAction;
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
motionAction = MotionEvent.ACTION_DOWN;
break;
case DragEvent.ACTION_DRAG_LOCATION:
motionAction = MotionEvent.ACTION_MOVE;
break;
case DragEvent.ACTION_DRAG_ENDED:
motionAction = MotionEvent.ACTION_UP;
break;
default:
return;
}
MotionEvent emulatedEvent = MotionEvent.obtain(dragStartTime, SystemClock.uptimeMillis(),
motionAction, event.getX(), event.getY(), 0);
recordMotionEvent(emulatedEvent);
emulatedEvent.recycle();
}
示例2: onDrag
@Override
public boolean onDrag(View view, DragEvent dragEvent) {
switch (dragEvent.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
AttachmentsProvider provider =
AttachmentsProviderFactory.getAttachmentProvider(getContext());
return mCallback != null && provider.isSupported();
case DragEvent.ACTION_DRAG_ENTERED:
setBackgroundColor(ContextCompat.getColor(getContext(), R.color.attachmentOverlay));
return isValidDragEvent(dragEvent.getClipData());
case DragEvent.ACTION_DRAG_ENDED:
setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent));
return true;
case DragEvent.ACTION_DRAG_EXITED:
case DragEvent.ACTION_DRAG_LOCATION:
return true;
case DragEvent.ACTION_DROP:
if (isValidDragEvent(dragEvent.getClipData())) {
final List<Attachment> attachments = extractAttachments(dragEvent.getClipData());
post(() -> mCallback.onAttachmentsDropped(attachments));
return true;
}
// Fallback
}
return false;
}
示例3: handleDragEvent
private boolean handleDragEvent(final View v, final DragEvent event) {
switch(event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
case DragEvent.ACTION_DRAG_ENTERED:
case DragEvent.ACTION_DRAG_LOCATION:
case DragEvent.ACTION_DRAG_EXITED:
case DragEvent.ACTION_DRAG_ENDED:
return true;
case DragEvent.ACTION_DROP:
final String phrase = event.getClipData().getItemAt(0).getText().toString();
moveViewToCorrectLocationFromDrag(v, phrase);
return true;
default:
return false;
}
}
示例4: onDragEvent
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
return mEditor != null && mEditor.hasInsertionController();
case DragEvent.ACTION_DRAG_ENTERED:
TextView.this.requestFocus();
return true;
case DragEvent.ACTION_DRAG_LOCATION:
final int offset = getOffsetForPosition(event.getX(), event.getY());
Selection.setSelection((Spannable)mText, offset);
return true;
case DragEvent.ACTION_DROP:
if (mEditor != null) mEditor.onDrop(event);
return true;
case DragEvent.ACTION_DRAG_ENDED:
case DragEvent.ACTION_DRAG_EXITED:
default:
return true;
}
}
示例5: onDrag
public boolean onDrag(View v, DragEvent event) {
final int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_STARTED:
return dragStart(v, event);
case DragEvent.ACTION_DRAG_ENTERED:
return true;
case DragEvent.ACTION_DRAG_LOCATION:
return this.dragLocation(v, event);
case DragEvent.ACTION_DRAG_EXITED:
return true;
case DragEvent.ACTION_DROP:
return this.dragDrop(v, event);
case DragEvent.ACTION_DRAG_ENDED:
return true;
default:
Log.e("MarkerDragEventListener", "Unknown action type received by OnDragListener.");
break;
}
return false;
}
示例6: onDragEvent
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
//Log.i(TAG, "Drag Started.");
return onDragStarted(event);
case DragEvent.ACTION_DRAG_ENTERED:
Log.i(TAG, "Drag entered ADDV");
return onDragEntered(event);
case DragEvent.ACTION_DRAG_LOCATION:
return onDragMoveOn(event);
case DragEvent.ACTION_DRAG_EXITED:
Log.i(TAG, "Drag exited ADDV");
return onDragExited(event);
case DragEvent.ACTION_DROP:
Log.i(TAG, "Drag droped ADDV");
return onDrop(event);
case DragEvent.ACTION_DRAG_ENDED:
//Log.i(TAG, "Drag ended ADDV.");
return onDragEnded(event);
}
return super.onDragEvent(event);
}
示例7: onDragEvent
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
//Log.i(TAG, "DropLV Drag Started.");
return onDragStarted(event);
case DragEvent.ACTION_DRAG_ENTERED:
Log.i(TAG, "Drag entered DropLV.");
return onDragEntered(event);
case DragEvent.ACTION_DRAG_LOCATION:
return onDragMoveOn(event);
case DragEvent.ACTION_DRAG_EXITED:
Log.i(TAG, "Drag exited DropLV.");
return onDragExited(event);
case DragEvent.ACTION_DROP:
Log.i(TAG, "Drag droped DropLV.");
return onDrop(event);
case DragEvent.ACTION_DRAG_ENDED:
//Log.i(TAG, "DropLV Drag ended.");
return onDragEnded(event);
}
return super.onDragEvent(event);
}
示例8: onDragEvent
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
//Log.i(TAG, "DropGV Drag Started.");
return onDragStarted(event);
case DragEvent.ACTION_DRAG_ENTERED:
Log.i(TAG, "Drag entered DropGV.");
return onDragEntered(event);
case DragEvent.ACTION_DRAG_LOCATION:
return onDragMoveOn(event);
case DragEvent.ACTION_DRAG_EXITED:
Log.i(TAG, "Drag exited DropGV");
return onDragExited(event);
case DragEvent.ACTION_DROP:
Log.i(TAG, "Drag droped DropGV");
return onDrop(event);
case DragEvent.ACTION_DRAG_ENDED:
//Log.i(TAG, "Drag ended DropGV.");
return onDragEnded(event);
}
return super.onDragEvent(event);
}
示例9: onDragEvent
@Override
public boolean onDragEvent (DragEvent event) {
final int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_STARTED:
mLastX = event.getX();
mLastY = event.getY();
return true;
case DragEvent.ACTION_DRAG_ENTERED:
return true;
case DragEvent.ACTION_DRAG_LOCATION:
mLastX = event.getX();
mLastY = event.getY();
mEventListener.onDriverDragMove(event.getX(), event.getY());
return true;
case DragEvent.ACTION_DROP:
mLastX = event.getX();
mLastY = event.getY();
mEventListener.onDriverDragMove(event.getX(), event.getY());
mEventListener.onDriverDragEnd(mLastX, mLastY);
return true;
case DragEvent.ACTION_DRAG_EXITED:
mEventListener.onDriverDragExitWindow();
return true;
case DragEvent.ACTION_DRAG_ENDED:
mEventListener.onDriverDragCancel();
return true;
default:
return false;
}
}
示例10: onDrag
@Override
public boolean onDrag(View v, DragEvent event) {
switch(event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
onDropListener.onDragStarted();
return true;
case DragEvent.ACTION_DRAG_ENTERED:
return true;
case DragEvent.ACTION_DRAG_LOCATION:
// Ignore the event
onDropListener.onDragLocation(event.getX(), event.getY());
return true;
case DragEvent.ACTION_DRAG_EXITED:
return true;
case DragEvent.ACTION_DROP:
onDropListener.onDrop();
return true;
case DragEvent.ACTION_DRAG_ENDED:
onDropListener.onDragEnded();
return true;
default:
break;
}
return false;
}
示例11: onDrag
@Override
public boolean onDrag(View v, DragEvent event) {
final int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_STARTED: // 拖拽开始
Log.i("拖拽事件", "拖拽开始");
return event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
case DragEvent.ACTION_DRAG_ENTERED: // 被拖拽View进入目标区域
Log.i("拖拽事件", "被拖拽View进入目标区域");
return true;
case DragEvent.ACTION_DRAG_LOCATION: // 被拖拽View在目标区域移动
Log.i("拖拽事件", "被拖拽View在目标区域移动___X:" + event.getX() + "___Y:" + event.getY());
tvTip.setText("X:" + event.getX() + " Y:" + event.getY());
return true;
case DragEvent.ACTION_DRAG_EXITED: // 被拖拽View离开目标区域
Log.i("拖拽事件", "被拖拽View离开目标区域");
return true;
case DragEvent.ACTION_DROP: // 放开被拖拽View
Log.i("拖拽事件", "放开被拖拽View");
// 释放拖拽阴影,并获取移动数据
ClipData.Item item = event.getClipData().getItemAt(0);
String content = item.getText().toString();
Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
return true;
case DragEvent.ACTION_DRAG_ENDED: // 拖拽完成
Log.i("拖拽事件", "拖拽完成");
return true;
default:
break;
}
return false;
}
示例12: onDragEvent
@Override
public boolean onDragEvent(DragEvent event) {
int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_STARTED:
this.animate()
.alpha(1f)
.setDuration(mShortAnimTime)
.setListener(null);
break;
case DragEvent.ACTION_DRAG_LOCATION:
setShadowPosition((int) event.getX());
break;
case DragEvent.ACTION_DRAG_ENDED:
if (mDragFinishListener != null) {
mDragFinishListener.onDragFinished(mPositionX);
}
mPositionX = 0;
mMinLeft = 0;
this.animate()
.alpha(0f)
.setDuration(mShortAnimTime)
.setListener(null);
break;
}
return true;
}
示例13: onDrag
@Override
public boolean onDrag(View view, DragEvent dragEvent) {
Log.d("dragEvent", dragEvent.toString());
switch (dragEvent.getAction()) {
case DragEvent.ACTION_DRAG_ENDED:
Log.d("event", "ACTION_DRAG_ENDED");
dragLayout.setVisibility(View.GONE);
dragLayout.setBackgroundResource(R.drawable.drag_background);
return true;
case DragEvent.ACTION_DRAG_ENTERED:
Log.d("event", "ACTION_DRAG_ENTERED");
dragLayout.setBackgroundResource(R.drawable.drag_background_active);
return true;
case DragEvent.ACTION_DRAG_EXITED:
Log.d("event", "ACTION_DRAG_EXITED");
dragLayout.setBackgroundResource(R.drawable.drag_background);
return true;
case DragEvent.ACTION_DRAG_LOCATION:
Log.d("event", "ACTION_DRAG_LOCATION");
return true;
case DragEvent.ACTION_DRAG_STARTED:
Log.d("event", "ACTION_DRAG_STARTED");
dragLayout.setVisibility(View.VISIBLE);
return true;
case DragEvent.ACTION_DROP:
Log.d("event", "ACTION_DRAG_DROP");
handleDropEvent(view, dragEvent);
return true;
default:
Log.e("event", "unknown");
}
return false;
}
示例14: onDrag
@Override
public boolean onDrag(View view, DragEvent event) {
// Defines a variable to store the action type for the incoming event
final int action = event.getAction();
// Handles each of the expected events
switch(action) {
case DragEvent.ACTION_DRAG_STARTED:
return true;
case DragEvent.ACTION_DRAG_ENTERED:
return true;
case DragEvent.ACTION_DRAG_LOCATION:
return true;
case DragEvent.ACTION_DRAG_EXITED:
return true;
case DragEvent.ACTION_DROP:
ClipData cd = event.getClipData();
String tag = cd.getItemAt(0).getText().toString();
int id = Integer.parseInt(tag);
View marker = findViewWithTag(tag);
//marker.setX(event.getX());
float x = event.getX() - marker.getWidth()/2;
float pos = mMarkerMediator.onPositionRequested(id, x);
mMarkerMediator.onPositionChanged(id, pos);
invalidate();
return true;
case DragEvent.ACTION_DRAG_ENDED:
return true;
// An unknown action type was received.
default:
Log.e("DragDrop Example","Unknown action type received by OnDragListener.");
break;
}
return false;
}
示例15: onDragEvent
@Override
public boolean onDragEvent(DragEvent event) {
if (event.getAction() == DragEvent.ACTION_DRAG_LOCATION) {
return magicListAdapter.onDragEventLocation(event, getPosition((int) event.getY(), true));
}
return magicListAdapter.onDragEvent(event);
}