当前位置: 首页>>代码示例>>Java>>正文


Java DragEvent.getResult方法代码示例

本文整理汇总了Java中android.view.DragEvent.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java DragEvent.getResult方法的具体用法?Java DragEvent.getResult怎么用?Java DragEvent.getResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.DragEvent的用法示例。


在下文中一共展示了DragEvent.getResult方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDragEnded

import android.view.DragEvent; //导入方法依赖的package包/类
@Override
public boolean onDragEnded(DragEvent event) {
    boolean success = event.getResult();

    if (mOnDropDelegate != null) {
        if (!success) {
            mOnDropDelegate.onDropFailed(this);
        }
    }

    return false;
}
 
开发者ID:nichollyn,项目名称:amddviews,代码行数:13,代码来源:AdaptableDragDropView.java

示例2: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@Override
public boolean onDrag(View workspaceView, DragEvent event) {
    final int action = event.getAction();

    if (LOG_DRAG_EVENTS) {
        String actionName = (action == DragEvent.ACTION_DRAG_STARTED) ? "DRAG_STARTED" :
                (action == DragEvent.ACTION_DRAG_LOCATION) ? "DRAG_LOCATION" :
                (action == DragEvent.ACTION_DRAG_ENDED) ? "DRAG_ENDED" :
                (action == DragEvent.ACTION_DROP) ? "DROP" :
                "UNKNOWN ACTION #" + action;
        Log.d(TAG, "onDrag: " + actionName + ", " + event);

        mMainHandler.removeCallbacks(mLogPending);  // Only log once per event tick
        mMainHandler.post(mLogPending);
    }

    // ClipDescription is always null on DRAG_ENDED.
    if (action != DragEvent.ACTION_DRAG_ENDED &&
            !mClipHelper.isBlockData(event.getClipDescription()))
    {
        if (LOG_DRAG_EVENTS) {
            Log.d(TAG, "onDrag: Not a block.");
        }
        return false;
    }

    if (mPendingDrag != null && mPendingDrag.isDragging()) {
        switch (action) {
            case DragEvent.ACTION_DRAG_STARTED:
                // Triggered in maybeStartDrag(..).
                // The rest of the drag data is already captured in mPendingDrag.
                // NOTE: This event position does not respect view scale.

                BlockView rootDraggedBlockView = mPendingDrag.getRootDraggedBlockView();
                if(rootDraggedBlockView.getBlock().isMovable()) {
                    BlockGroup dragGroup = mPendingDrag.getDragGroup();
                    if (dragGroup.getParent() == mWorkspaceView) {
                        // Hide the view on the workspace
                        mPendingDrag.getDragGroup().setVisibility(View.INVISIBLE);
                    }

                    // TODO(#35): This might be better described as "selected".
                    ((View) rootDraggedBlockView).setPressed(true);
                    return true;    // We want to keep listening for drag events
                } else {
                    return false;   // We don't want to keep listening for drag events
                }
            case DragEvent.ACTION_DRAG_LOCATION:
                // If we're still finishing up a previous drag we may have missed the
                // start of the drag, in which case we shouldn't do anything.
                continueDragging(event);
                break;
            case DragEvent.ACTION_DRAG_ENDED:
                // TODO(#202): Cancel pending drag?
                if (event.getResult()) {
                    break;
                }
                // Otherwise fall through
            case DragEvent.ACTION_DROP:
                // Finalize dragging and reset dragging state flags.
                // These state flags are still used in the initial phase of figuring out if
                // a drag has started.
                maybeConnectDragGroup();
                finishDragging(FINISH_BEHAVIOR_DROP);
                return true;    // The drop succeeded.
            default:
                break;
        }
    }
    return false;   // In every case that gets here, the return value won't be checked.
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:72,代码来源:Dragger.java

示例3: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@Override
public boolean onDrag(View view, DragEvent event) {

    // Handles each of the expected events
    switch (event.getAction()) {

        //signal for the start of a drag and drop operation.
        case DragEvent.ACTION_DRAG_STARTED:
            break;

        //the drag point has entered the bounding box of the View
        case DragEvent.ACTION_DRAG_ENTERED:
            ((ImageView) view).setColorFilter(Color.YELLOW);
            break;

        //the user has moved the drag shadow outside the bounding box of the View
        case DragEvent.ACTION_DRAG_EXITED:
            ((ImageView) view).clearColorFilter();
            break;

        //drag shadow has been released,the drag point is within the bounding box of the View
        case DragEvent.ACTION_DROP:
            GridView targetGrid = (GridView) view.getParent();
            int index = targetGrid.indexOfChild(view);

            int droppedStartIndex;
            if (targetGrid.equals(mSourceGridView)) {
                droppedStartIndex = mPuzzle.getSize();
            } else {
                droppedStartIndex = 0;
            }
            mPuzzle.setTile(droppedStartIndex, index, mDraggedTile);
            ((BoardAdapter) targetGrid.getAdapter()).notifyDataSetChanged();

            // validate the board now the tile has been dropped
            if (mPuzzle.isSolved()) {
                puzzleSolvedActions();
            }
            break;

        //the drag and drop operation has concluded.
        case DragEvent.ACTION_DRAG_ENDED:
            if (!event.getResult()) {
                // tile dropped in an invalid area of the screen; put it back
                mPuzzle.setTile(mDraggedTileStartingX, mDraggedTilePosition, mDraggedTile);
                ((BoardAdapter) mTargetGridView.getAdapter()).notifyDataSetChanged();
                ((BoardAdapter) mSourceGridView.getAdapter()).notifyDataSetChanged();
            }
            break;
        default:
            break;
    }
    return true;
}
 
开发者ID:jahunt1,项目名称:tetravex-android,代码行数:55,代码来源:PuzzleActivity.java

示例4: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
      @Override
public boolean onDrag(View hoverView, DragEvent event) {
    View draggedView = (View) event.getLocalState();
		
		switch (event.getAction()) {
			case DragEvent.ACTION_DRAG_STARTED:
			    GameActivityLinearLayout.this.requestLayout(); // this is temporary fix for drag error
				break;
	
			case DragEvent.ACTION_DRAG_ENTERED:
				// Change the background of droplayout(purely style)
				hoverView.setBackgroundDrawable(enterShape);
				hoverView.invalidate();
				break;
	
			case DragEvent.ACTION_DRAG_EXITED:
				// Change the background back when exiting droplayout(purely
				// style)
				hoverView.setBackgroundDrawable(normalShape);
				hoverView.invalidate();
				break;
	
			case DragEvent.ACTION_DROP:
				// Dropped, assigns the draggedview to the dropcontainer if
				// the container does not already contain a view.
				ViewGroup ownerContainer = (ViewGroup) draggedView.getParent();
	
				PictoFrameLayout dropContainer = (PictoFrameLayout) hoverView;
				Object tag = hoverView.getTag();
				if (tag == null) {
					ownerContainer.removeView(draggedView);
					ownerContainer.setTag(null);
					ownerContainer.invalidate();
					dropContainer.addView(draggedView);
					dropContainer.setTag("filled");
					dropContainer.invalidate();
				}
				draggedView.setVisibility(View.VISIBLE);
				draggedView.invalidate();
				break;
	
			case DragEvent.ACTION_DRAG_ENDED:
				// Makes the draggedview visible again after the view has
				// been moved or the drop wasn't valid.
				hoverView.setBackgroundDrawable(normalShape);
				hoverView.invalidate();
				if(event.getResult() == false){
					draggedView.setVisibility(View.VISIBLE);
					draggedView.invalidate();
				}
				break;
		}
		return true;
}
 
开发者ID:figa12,项目名称:sw606f13,代码行数:56,代码来源:GameActivityLinearLayout.java

示例5: dropEventNotHandled

import android.view.DragEvent; //导入方法依赖的package包/类
private boolean dropEventNotHandled(DragEvent event) {
    return !event.getResult();
}
 
开发者ID:durka,项目名称:HallMonitor,代码行数:4,代码来源:CallDragListener.java

示例6: dropEventNotHandled

import android.view.DragEvent; //导入方法依赖的package包/类
private boolean dropEventNotHandled(DragEvent dragEvent) {

            return !dragEvent.getResult();

        }
 
开发者ID:jvbeltra,项目名称:JavaIsFun,代码行数:6,代码来源:Vetores9.java

示例7: dropEventNotHandled

import android.view.DragEvent; //导入方法依赖的package包/类
private boolean dropEventNotHandled(DragEvent dragEvent) {

        return !dragEvent.getResult();

    }
 
开发者ID:jvbeltra,项目名称:JavaIsFun,代码行数:6,代码来源:Calculos6.java


注:本文中的android.view.DragEvent.getResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。