android.view.DragEvent#ACTION_DRAG_EXITED源码实例Demo

下面列出了android.view.DragEvent#ACTION_DRAG_EXITED 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PlusDemo   文件: DragListenerGridView.java
@Override
public boolean onDrag(View v, DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            if (event.getLocalState() == v) {
                v.setVisibility(INVISIBLE);
            }
            break;
        case DragEvent.ACTION_DRAG_ENTERED:
            System.out.println("draggg");
            if (event.getLocalState() != v) {
                sort(v);
            }
            break;
        case DragEvent.ACTION_DRAG_EXITED:
            break;
        case DragEvent.ACTION_DRAG_ENDED:
            v.setVisibility(VISIBLE);
            break;
    }
    return true;
}
 
源代码2 项目: AndroidChromium   文件: CompositorViewHolder.java
@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;
}
 
源代码3 项目: 365browser   文件: CompositorViewHolder.java
@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;
}
 
源代码4 项目: DistroHopper   文件: LauncherDragListener.java
@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 (ex);
		exh.show (this.appManager.getContext ());
	}

	return true;
}
 
@Override
public boolean onDrag(View view, DragEvent event) {
    // Change the color of the target for all events.
    // For the drop action, set the view to the dropped image.
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            setTargetColor(view, COLOR_ACTIVE);
            return true;

        case DragEvent.ACTION_DRAG_ENTERED:
            setTargetColor(view, COLOR_HOVER);
            return true;

        case DragEvent.ACTION_DRAG_LOCATION:
            processLocation(event.getX(), event.getY());
            return true;

        case DragEvent.ACTION_DRAG_EXITED:
            setTargetColor(view, COLOR_ACTIVE);
            return true;

        case DragEvent.ACTION_DROP:
            return processDrop(view, event);

        case DragEvent.ACTION_DRAG_ENDED:
            setTargetColor(view, COLOR_INACTIVE);
            return true;

        default:
            break;
    }

    return false;
}
 
@Override
public boolean onDrag(View view, DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            setTargetColor(view, COLOR_ACTIVE);
            return true;

        case DragEvent.ACTION_DRAG_ENTERED:
            setTargetColor(view, COLOR_HOVER);
            return true;

        case DragEvent.ACTION_DRAG_LOCATION:
            processLocation(event.getX(), event.getY());
            return true;

        case DragEvent.ACTION_DRAG_EXITED:
            setTargetColor(view, COLOR_ACTIVE);
            return true;

        case DragEvent.ACTION_DROP:
            return processDrop(view, event);

        case DragEvent.ACTION_DRAG_ENDED:
            setTargetColor(view, COLOR_INACTIVE);
            return true;

        default:
            break;
    }

    return false;
}
 
源代码7 项目: LaunchEnr   文件: DragDriver.java
@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;
    }
}
 
@Override
public boolean onDrag(View view, DragEvent event) {
    // Change the color of the target for all events.
    // For the drop action, set the view to the dropped image.
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            setTargetColor(view, COLOR_ACTIVE);
            return true;

        case DragEvent.ACTION_DRAG_ENTERED:
            setTargetColor(view, COLOR_HOVER);
            return true;

        case DragEvent.ACTION_DRAG_LOCATION:
            processLocation(event.getX(), event.getY());
            return true;

        case DragEvent.ACTION_DRAG_EXITED:
            setTargetColor(view, COLOR_ACTIVE);
            return true;

        case DragEvent.ACTION_DROP:
            return processDrop(view, event);

        case DragEvent.ACTION_DRAG_ENDED:
            setTargetColor(view, COLOR_INACTIVE);
            return true;

        default:
            break;
    }

    return false;
}
 
@Override
public boolean onDrag(View view, DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            setTargetColor(view, COLOR_ACTIVE);
            return true;

        case DragEvent.ACTION_DRAG_ENTERED:
            setTargetColor(view, COLOR_HOVER);
            return true;

        case DragEvent.ACTION_DRAG_LOCATION:
            processLocation(event.getX(), event.getY());
            return true;

        case DragEvent.ACTION_DRAG_EXITED:
            setTargetColor(view, COLOR_ACTIVE);
            return true;

        case DragEvent.ACTION_DROP:
            return processDrop(view, event);

        case DragEvent.ACTION_DRAG_ENDED:
            setTargetColor(view, COLOR_INACTIVE);
            return true;

        default:
            break;
    }

    return false;
}
 
@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 项目: Taskbar   文件: HomeActivityDelegate.java
@Override
public boolean onDrag(View v, DragEvent event) {
    switch(event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
        default:
            // do nothing
            break;
        case DragEvent.ACTION_DRAG_ENTERED:
            FrameLayout container = (FrameLayout) v;
            if(container.getChildCount() == 0
                    || startDragIndex == desktopIcons.indexOfChild(container)) {
                v.setBackgroundColor(U.getAccentColor(HomeActivityDelegate.this));
                v.setAlpha(0.5f);
            }
            break;
        case DragEvent.ACTION_DRAG_ENDED:
            View view = (View) event.getLocalState();
            view.setVisibility(View.VISIBLE);
            // fall through
        case DragEvent.ACTION_DRAG_EXITED:
            v.setBackground(null);
            v.setAlpha(1);
            break;
        case DragEvent.ACTION_DROP:
            FrameLayout container2 = (FrameLayout) v;
            if(container2.getChildCount() == 0) {
                // Dropped, reassign View to ViewGroup
                View view2 = (View) event.getLocalState();
                ViewGroup owner = (ViewGroup) view2.getParent();
                owner.removeView(view2);
                container2.addView(view2);

                endDragIndex = desktopIcons.indexOfChild(container2);
                reassignDroppedIcon();
            }
            break;
    }
    return true;
}
 
源代码12 项目: android-profile   文件: StoreExampleActivity.java
@Override
        public boolean onDrag(View v, DragEvent event) {
            View view = (View) event.getLocalState();
//            ViewGroup owner = (ViewGroup) view.getParent();
//            LinearLayout container = (LinearLayout) v;
            switch (event.getAction()) {
                case DragEvent.ACTION_DRAG_STARTED:
                    break;
                case DragEvent.ACTION_DRAG_ENTERED:
                    v.setBackgroundDrawable(enterShape);
                    break;
                case DragEvent.ACTION_DRAG_EXITED:
                    v.setBackgroundDrawable(normalShape);
                    break;
                case DragEvent.ACTION_DROP:

                    // Dropped, reassign View to ViewGroup

                    ViewGroup left = (ViewGroup)findViewById(R.id.leftbox);
                    ViewGroup right = (ViewGroup)findViewById(R.id.rightbox);

                    if (right == v){
                        left.removeView(view);
                        right.addView(view);
                        view.setVisibility(View.VISIBLE);

                        // Once the user drags the SOOMBOT to the empty box, we open the store.
                        openStore();
                    }
                    break;
                case DragEvent.ACTION_DRAG_ENDED:
                    view.setVisibility(View.VISIBLE);

                    v.setBackgroundDrawable(normalShape);
                default:
                    break;
            }
            return true;
        }
 
源代码13 项目: DistroHopper   文件: AppLauncherDragListener.java
@Override
public boolean onDrag (View view, DragEvent event)
{
	try
	{
		AppLauncher appLauncher = (AppLauncher) view;
		App app = appLauncher.getApp ();

		switch (event.getAction ())
		{
			case DragEvent.ACTION_DRAG_ENTERED:
				appLauncher.animate ().setStartDelay (0).setDuration (120).alpha (0.2F);
				break;
			case DragEvent.ACTION_DROP: // Falls through //
				int oldIndex = Integer.parseInt (event.getClipData ().getDescription ().getLabel ().toString ());
				int newIndex = this.appManager.indexOfPinned (app);

				this.appManager.movePinnedApp (oldIndex, newIndex);
				this.appManager.refreshPinnedView ();

				this.appManager.savePinnedApps ();
			case DragEvent.ACTION_DRAG_ENDED: // Falls through //
				this.appManager.stoppedDraggingPinnedApp ();
			case DragEvent.ACTION_DRAG_EXITED:
				if (Build.VERSION.SDK_INT >= 14)
					appLauncher.animate ().setStartDelay (0).setDuration (120).alpha (0.9F);
				else
					appLauncher.setAlpha (0.9F);
				break;
		}
	}
	catch (Exception ex)
	{
		ExceptionHandler exh = new ExceptionHandler (ex);
		exh.show (this.appManager.getContext ());
	}

	return true;
}
 
源代码14 项目: DistroHopper   文件: TrashDragListener.java
@Override
public boolean onDrag (View view, DragEvent event)
{
	try
	{
		AppLauncher lalTrash = (AppLauncher) view;
		if (this.colour == -1)
			this.colour = lalTrash.getColour ();

		switch (event.getAction ())
		{
			case DragEvent.ACTION_DRAG_ENTERED:
				this.appManager.startedDraggingPinnedApp();
				lalTrash.setColour (Color.rgb (255, 40, 40));
				break;
			case DragEvent.ACTION_DROP: // Falls through //
				int index = Integer.parseInt (event.getClipData ().getDescription ().getLabel ().toString ());
				this.appManager.unpin (index);

				this.appManager.stoppedDraggingPinnedApp ();
			case DragEvent.ACTION_DRAG_EXITED:
				lalTrash.setColour (this.colour);
				break;
		}
	}
	catch (Exception ex)
	{
		ExceptionHandler exh = new ExceptionHandler (ex);
		exh.show (this.appManager.getContext ());
	}

	return true;
}
 
源代码15 项目: codeexamples-android   文件: DragActivity.java
@Override
public boolean onDrag(View v, DragEvent event) {
	int action = event.getAction();
	switch (event.getAction()) {
	case DragEvent.ACTION_DRAG_STARTED:
		// Do nothing
		break;
	case DragEvent.ACTION_DRAG_ENTERED:
		v.setBackgroundDrawable(enterShape);
		break;
	case DragEvent.ACTION_DRAG_EXITED:
		v.setBackgroundDrawable(normalShape);
		break;
	case DragEvent.ACTION_DROP:
		// Dropped, reassign View to ViewGroup
		View view = (View) event.getLocalState();
		ViewGroup owner = (ViewGroup) view.getParent();
		// TODO 1 removeView from owner
		// TODO 2 add to v which is a LinearLayout
		// TODO 3 set view to View.Visible
		
		break;
	case DragEvent.ACTION_DRAG_ENDED:
		v.setBackgroundDrawable(normalShape);
	default:
		break;
	}
	return true;
}
 
源代码16 项目: codeexamples-android   文件: DragActivity.java
@Override
public boolean onDrag(View v, DragEvent event) {
	switch (event.getAction()) {
	case DragEvent.ACTION_DRAG_STARTED:
		// Do nothing
		break;
	case DragEvent.ACTION_DRAG_ENTERED:
		v.setBackground(enterShape);
		break;
	case DragEvent.ACTION_DRAG_EXITED:
		v.setBackground(normalShape);
		break;
	case DragEvent.ACTION_DROP:
		// view dropped, reassign the view to the new ViewGroup
		View view = (View) event.getLocalState();
		ViewGroup owner = (ViewGroup) view.getParent();
		owner.removeView(view);
		LinearLayout container = (LinearLayout) v;
		container.addView(view);
		view.setVisibility(View.VISIBLE);
		break;
	case DragEvent.ACTION_DRAG_ENDED:
		v.setBackground(normalShape);
	default:
		break;
	}
	return true;
}
 
源代码17 项目: codeexamples-android   文件: DragActivity.java
@Override
public boolean onDrag(View v, DragEvent event) {
	switch (event.getAction()) {
	case DragEvent.ACTION_DRAG_STARTED:
		// Do nothing
		break;
	case DragEvent.ACTION_DRAG_ENTERED:
		v.setBackground(enterShape);
		break;
	case DragEvent.ACTION_DRAG_EXITED:
		v.setBackground(normalShape);
		break;
	case DragEvent.ACTION_DROP:
		// view dropped, reassign the view to the new ViewGroup
		View view = (View) event.getLocalState();
		ViewGroup owner = (ViewGroup) view.getParent();
		owner.removeView(view);
		LinearLayout container = (LinearLayout) v;
		container.addView(view);
		view.setVisibility(View.VISIBLE);
		break;
	case DragEvent.ACTION_DRAG_ENDED:
		v.setBackground(normalShape);
	default:
		break;
	}
	return true;
}
 
源代码18 项目: Android_UE   文件: ViewDragListenerView.java
@Override
    public boolean onDrag(View view, DragEvent dragEvent) {
        switch (dragEvent.getAction()) {
            case DragEvent.ACTION_DRAG_STARTED:
                if (dragEvent.getLocalState() == view) {
                    view.setVisibility(View.INVISIBLE);
                }
                // 开始拖拽
                Log.e(TAG, "开始拖拽");
                break;
            case DragEvent.ACTION_DRAG_LOCATION:
                // 主要是感觉是在拖动中就会回调
//                Log.e(TAG, "主要是感觉是在拖动中就会回调");
                break;
            case DragEvent.ACTION_DROP:
                // 向用户已释放拖动阴影的视图发出信号,拖动点位于视图的边界框内,而不在可接受数据的后代视图中。
                Log.e(TAG, "向用户已释放拖动阴影的视图发出信号,拖动点位于视图的边界框内,而不在可接受数据的后代视图中。");
                break;
            case DragEvent.ACTION_DRAG_ENDED:
                // 拖拽已结束
                Log.e(TAG, "拖拽已结束");
                if (dragEvent.getLocalState() == view) {
                    view.setVisibility(View.VISIBLE);
                }
                break;
            case DragEvent.ACTION_DRAG_ENTERED:
                // 拖拽的View已经到了其他View的范围,判断点为手指触摸的位置
                if (dragEvent.getLocalState() != view) {
                    // 每个View都会收到的,所以要排除掉自己
                    sortView(view);
                    Log.e(TAG, "拖拽的View已经到了其他View的范围");

                }
                break;
            case DragEvent.ACTION_DRAG_EXITED:
                // 移出了当前View的范围,判断点为手指触摸的位置
                Log.e(TAG, "移出了当前View的范围");
                break;
        }
        return true;
    }
 
源代码19 项目: ssj   文件: PipeOnDragListener.java
/**
     * @param v     View
     * @param event DragEvent
     * @return boolean
     */
    @Override
    public boolean onDrag(final View v, final DragEvent event)
    {
        if (v instanceof PipeView)
        {
            final PipeView pipeView = (PipeView) v;
            switch (event.getAction())
            {
                case DragEvent.ACTION_DRAG_STARTED:
                {
                    //init values
                    xCoord = 0;
                    yCoord = 0;
                    dropped = false;
                    createRecycleBin(pipeView);
                    break;
                }
                case DragEvent.ACTION_DRAG_ENTERED:
                    break;
                case DragEvent.ACTION_DRAG_EXITED:
                    break;
                case DragEvent.ACTION_DROP:
                    //update drop location
                    xCoord = event.getX();
                    yCoord = event.getY();
                    dropped = true;
                    ComponentView view = (ComponentView) event.getLocalState();
                    pipeView.getGrid().setGridValue(view.getGridX(), view.getGridY(), false);
                    break;
                case DragEvent.ACTION_DRAG_ENDED:
                    cleanup(pipeView, event);
                    break;
                case DragEvent.ACTION_DRAG_LOCATION:
                {
//                    //@todo add scroll behaviour to drag and drop
//                    HorizontalScrollView horizontalScrollView = (HorizontalScrollView) pipeView.getParent();
//                    if (horizontalScrollView != null)
//                    {
//                        ScrollView scrollView = (ScrollView) horizontalScrollView.getParent();
//                        if (scrollView != null)
//                        {
//                            //way one
//                            int y = Math.round(event.getY());
//                            int translatedY = y - scrollView.getScrollY();
//                            int threshold = 50;
//                            // make a scrolling up due the y has passed the threshold
//                            if (translatedY < threshold) {
//                                // make a scroll up by 30 px
//                                scrollView.smoothScrollBy(0, -30);
//                            }
//                            // make a autoscrolling down due y has passed the 500 px border
//                            if (translatedY + threshold > 500) {
//                                // make a scroll down by 30 px
//                                scrollView.smoothScrollBy(0, 30);
//                            }
//                            //way two
//                            int topOfDropZone = pipeView.getTop();
//                            int bottomOfDropZone = pipeView.getBottom();
//                            int scrollY = scrollView.getScrollY();
//                            int scrollViewHeight = scrollView.getMeasuredHeight();
//                            Log.d("location: Scroll Y: " + scrollY + " Scroll Y+Height: " + (scrollY + scrollViewHeight));
//                            Log.d(" top: " + topOfDropZone + " bottom: " + bottomOfDropZone);
//                            if (bottomOfDropZone > (scrollY + scrollViewHeight - 100))
//                            {
//                                scrollView.smoothScrollBy(0, 30);
//                            }
//                            if (topOfDropZone < (scrollY + 100))
//                            {
//                                scrollView.smoothScrollBy(0, -30);
//                            }
//                        }
//                    }
                    break;
                }
                default:
                    break;
            }
            return true;
        }
        return false;
    }
 
源代码20 项目: codeexamples-android   文件: DraggableDot.java
/**
 * Drag and drop
 */
@Override
public boolean onDragEvent(DragEvent event) {
    boolean result = false;
    switch (event.getAction()) {
    case DragEvent.ACTION_DRAG_STARTED: {
        // claim to accept any dragged content
        Log.i(TAG, "Drag started, event=" + event);
        // cache whether we accept the drag to return for LOCATION events
        mDragInProgress = true;
        mAcceptsDrag = result = true;
        // Redraw in the new visual state if we are a potential drop target
        if (mAcceptsDrag) {
            invalidate();
        }
    } break;

    case DragEvent.ACTION_DRAG_ENDED: {
        Log.i(TAG, "Drag ended.");
        if (mAcceptsDrag) {
            invalidate();
        }
        mDragInProgress = false;
        mHovering = false;
    } break;

    case DragEvent.ACTION_DRAG_LOCATION: {
        // we returned true to DRAG_STARTED, so return true here
        Log.i(TAG, "... seeing drag locations ...");
        result = mAcceptsDrag;
    } break;

    case DragEvent.ACTION_DROP: {
        Log.i(TAG, "Got a drop! dot=" + this + " event=" + event);
        if (mAnrType == ANR_DROP) {
            sleepSixSeconds();
        }
        processDrop(event);
        result = true;
    } break;

    case DragEvent.ACTION_DRAG_ENTERED: {
        Log.i(TAG, "Entered dot @ " + this);
        mHovering = true;
        invalidate();
    } break;

    case DragEvent.ACTION_DRAG_EXITED: {
        Log.i(TAG, "Exited dot @ " + this);
        mHovering = false;
        invalidate();
    } break;

    default:
        Log.i(TAG, "other drag event: " + event);
        result = mAcceptsDrag;
        break;
    }

    return result;
}