當前位置: 首頁>>代碼示例>>Java>>正文


Java DragEvent.getAction方法代碼示例

本文整理匯總了Java中android.view.DragEvent.getAction方法的典型用法代碼示例。如果您正苦於以下問題:Java DragEvent.getAction方法的具體用法?Java DragEvent.getAction怎麽用?Java DragEvent.getAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.DragEvent的用法示例。


在下文中一共展示了DragEvent.getAction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: recordDragEvent

import android.view.DragEvent; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:25,代碼來源:FlingToDeleteHelper.java

示例2: dispatchDragEvent

import android.view.DragEvent; //導入方法依賴的package包/類
@Override
public boolean dispatchDragEvent(DragEvent e) {
    ContentViewCore contentViewCore = mTabVisible.getContentViewCore();
    if (contentViewCore == null) return false;

    if (mLayoutManager != null) mLayoutManager.getViewportPixel(mCacheViewport);
    contentViewCore.setCurrentTouchEventOffsets(-mCacheViewport.left, -mCacheViewport.top);
    boolean ret = super.dispatchDragEvent(e);

    int action = e.getAction();
    if (action == DragEvent.ACTION_DRAG_EXITED || action == DragEvent.ACTION_DRAG_ENDED
            || action == DragEvent.ACTION_DROP) {
        contentViewCore.setCurrentTouchEventOffsets(0.f, 0.f);
    }
    return ret;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:17,代碼來源:CompositorViewHolder.java

示例3: setOnDragListener

import android.view.DragEvent; //導入方法依賴的package包/類
@Override
public void setOnDragListener(final View.OnDragListener dragListener) {
    View.OnDragListener wrapper = new OnDragListener() {
        @Override
        public boolean onDrag(View view, DragEvent dragEvent) {
            int action = dragEvent.getAction();
            // Whether the dragged object can be handled by the trash.
            boolean result = dragListener.onDrag(view, dragEvent);
            if (action == DragEvent.ACTION_DRAG_ENDED) {
                setState(STATE_DEFAULT);
            } else  if (result) {
                switch (action) {
                    case DragEvent.ACTION_DRAG_ENTERED:
                        setState(STATE_ON_HOVER);
                        break;
                    case DragEvent.ACTION_DROP:
                    case DragEvent.ACTION_DRAG_EXITED:
                        setState(STATE_DEFAULT);
                        break;
                }
            }
            return result;
        }
    };
    super.setOnDragListener(wrapper);
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:27,代碼來源:TrashCanView.java

示例4: onDrag

import android.view.DragEvent; //導入方法依賴的package包/類
@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;
}
 
開發者ID:jruesga,項目名稱:rview,代碼行數:27,代碼來源:AttachmentDropView.java

示例5: onDragEvent

import android.view.DragEvent; //導入方法依賴的package包/類
/**
 * Handles drag event.
 */
@Override
public boolean onDragEvent(DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            // Only handle plain text drag and drop.
            return event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
        case DragEvent.ACTION_DRAG_ENTERED:
            requestFocus();
            return true;
        case DragEvent.ACTION_DROP:
            handlePasteClip(event.getClipData());
            return true;
    }
    return false;
}
 
開發者ID:jianliaoim,項目名稱:talk-android,代碼行數:19,代碼來源:RecipientEditTextView.java

示例6: dispatchDragEvent

import android.view.DragEvent; //導入方法依賴的package包/類
@Override
public boolean dispatchDragEvent(DragEvent ev) {
    final DragEvent event = ev;
    boolean r = super.dispatchDragEvent(ev);
    if (r && (ev.getAction() == DragEvent.ACTION_DRAG_STARTED || ev.getAction() == DragEvent.ACTION_DRAG_ENDED)) {
        // If we got a start or end and the return value is true, our
        // onDragEvent wasn't called by ViewGroup.dispatchDragEvent
        // So we do it here.
        this.post(new Runnable() {
            @Override
            public void run() {
                onDragEvent(event);
            }
        });


        // fix crash on older versions of android
        try {
            super.dispatchDragEvent(ev);
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    }
    return r;
}
 
開發者ID:OpenLauncherTeam,項目名稱:openlauncher,代碼行數:26,代碼來源:DragOptionView.java

示例7: handleDragEvent

import android.view.DragEvent; //導入方法依賴的package包/類
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;
    }
}
 
開發者ID:toshiapp,項目名稱:toshi-android-client,代碼行數:19,代碼來源:DragAndDropView.java

示例8: onDragEvent

import android.view.DragEvent; //導入方法依賴的package包/類
@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;
    }
}
 
開發者ID:AungThiha,項目名稱:Tada,代碼行數:26,代碼來源:TextView.java

示例9: onDrag

import android.view.DragEvent; //導入方法依賴的package包/類
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;
}
 
開發者ID:affinitybridge,項目名稱:cordova-mapbox-android-sdk,代碼行數:23,代碼來源:Builder.java

示例10: onDrag

import android.view.DragEvent; //導入方法依賴的package包/類
@Override
public boolean onDrag (View view, DragEvent event)
{
	try
	{
		switch (event.getAction ())
		{
			case DragEvent.ACTION_DRAG_ENTERED:
				this.appManager.startedDraggingPinnedApp ();
				break;
			case DragEvent.ACTION_DROP:
			case DragEvent.ACTION_DRAG_EXITED:
				this.appManager.stoppedDraggingPinnedApp ();
				break;
		}
	}
	catch (Exception ex)
	{
		ExceptionHandler exh = new ExceptionHandler (this.appManager.getContext (), ex);
		exh.show ();
	}

	return true;
}
 
開發者ID:RobinJ1995,項目名稱:DistroHopper,代碼行數:25,代碼來源:LauncherDragListener.java

示例11: createNewTableRow

import android.view.DragEvent; //導入方法依賴的package包/類
private TableRow createNewTableRow() {
	TableRow row = new TableRow(getActivity()) {
		@Override
		public boolean dispatchDragEvent(DragEvent ev) {
			boolean r = super.dispatchDragEvent(ev);
			if (r && (ev.getAction() == DragEvent.ACTION_DRAG_STARTED || ev.getAction() == DragEvent.ACTION_DRAG_ENDED)) {
				// If we got a start or end and the return value is true,
				// our
				// onDragEvent wasn't called by ViewGroup.dispatchDragEvent
				// So we do it here.
				onDragEvent(ev);
			}
			return r;
		}
	};
	row.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
	row.setPadding(2, 5, 5, 2);
	return row;
}
 
開發者ID:markuskreth,項目名稱:ClubHelperAndroid,代碼行數:20,代碼來源:PersonDetailFragment.java

示例12: onDragEvent

import android.view.DragEvent; //導入方法依賴的package包/類
@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);
}
 
開發者ID:nichollyn,項目名稱:amddviews,代碼行數:25,代碼來源:AdaptableDragDropView.java

示例13: onDragEvent

import android.view.DragEvent; //導入方法依賴的package包/類
@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);
}
 
開發者ID:nichollyn,項目名稱:amddviews,代碼行數:25,代碼來源:DropableListView.java

示例14: onDragEvent

import android.view.DragEvent; //導入方法依賴的package包/類
@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);
}
 
開發者ID:nichollyn,項目名稱:amddviews,代碼行數:25,代碼來源:DropableGridView.java

示例15: onDrag

import android.view.DragEvent; //導入方法依賴的package包/類
@Override
public boolean onDrag(final View view, final DragEvent event) {
    //if (catView == null) return true;
    switch (event.getAction()) {
        case DragEvent.ACTION_DROP:
            final View dragView = (View)event.getLocalState();
            final int width = dragView.getWidth();
            final int height = dragView.getHeight();
            final int xPos = (int)(event.getX() - (width / 2));
            final int yPos = (int)(event.getY() - (height / 2));

            final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(width, height);
            layoutParams.setMargins(xPos, yPos, 0, 0);
            dragView.setLayoutParams(layoutParams);
            dragView.setVisibility(View.VISIBLE);
            catView = null;
            break;
    }
    return true;
}
 
開發者ID:birbeck,項目名稱:kitty-playground,代碼行數:21,代碼來源:MyActivity.java


注:本文中的android.view.DragEvent.getAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。