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


Java DragEvent.getLocalState方法代码示例

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


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

示例1: 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

示例2: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
public boolean onDrag(View v, DragEvent event) {
    int action = event.getAction();
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            v.setBackgroundColor(LIGHT_BLUE);
            v.invalidate();
            return true;
        case DragEvent.ACTION_DRAG_ENTERED:
            v.setBackgroundColor(LIGHT_GREEN);
            v.invalidate();
            return true;
        case DragEvent.ACTION_DRAG_EXITED:
            v.setBackgroundColor(LIGHT_BLUE);
            v.invalidate();
            return true;
        case DragEvent.ACTION_DRAG_ENDED:
            v.setBackgroundColor(Color.WHITE);
            v.invalidate();
            return true;
        case DragEvent.ACTION_DROP:
            // Dropped, reassign Tile to the target Layout
            LetterTile tile = (LetterTile) event.getLocalState();
            tile.moveToViewGroup((ViewGroup) v);
            if (stackedLayout.empty()) {
                TextView messageBox = (TextView) findViewById(R.id.message_box);
                messageBox.setText(word1 + " " + word2);
            }
            /**
             **
             **  YOUR CODE GOES HERE
             **
             **/
            return true;
    }
    return false;
}
 
开发者ID:bricam,项目名称:wordstack,代码行数:37,代码来源:MainActivity.java

示例3: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@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.setAlpha(0.5F);
		break;
	case DragEvent.ACTION_DRAG_EXITED:
		v.setAlpha(1F);
		break;
	case DragEvent.ACTION_DROP:
		View view = (View) event.getLocalState();
		View item = (View) view.getParent().getParent();
		for (int i = 0, j = videosScroll.getChildCount(); i < j; i++) {
			if (videosScroll.getChildAt(i).findViewById(R.id.editor_image) == v) {
				// 当前位置
				videosScroll.removeView(item);
				videosScroll.addView(item, i);
				break;
			}
		}
		RefreshVideosScroll(true);
		break;
	case DragEvent.ACTION_DRAG_ENDED:
		v.setAlpha(1F);
	default:
		break;
	}
	return true;
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:33,代码来源:HoDragVideo.java

示例4: getPendingDrag

import android.view.DragEvent; //导入方法依赖的package包/类
/**
 * @param event The DragEvent containing the PendingDrag.
 * @return The PendingDrag containing the dragged blocks.
 */
@Override
public PendingDrag getPendingDrag(DragEvent event) {
    if (!isBlockData(event.getClipDescription())) {
        return null;
    }
    // In the future, this will support drags across application boundaries, constructing a new
    // PendingDrag as necessary. For now, it just extracts the PendingData from the local state.
    return (PendingDrag) event.getLocalState();
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:14,代码来源:SingleMimeTypeClipDataHelper.java

示例5: onDrag

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

        int xLimit = (mWrapper.getWidth() / 2) - mImageOffset;
        int yLimit = (mWrapper.getHeight() / 2) - mImageOffset;

        float dropX = event.getX() - mImageOffset;
        float dropY = event.getY() - mImageOffset;

        view.setTranslationX(dropX);
        view.setTranslationY(dropY);
        view.setVisibility(View.VISIBLE);

        if (dropX < xLimit && dropY < yLimit) {
            // Top left corner
            view.animate().x(mCorner1.getX()).y(mCorner1.getY());
        } else if (dropX > xLimit && dropY < yLimit) {
            // Top right corner
            view.animate().x(mCorner2.getX()).y(mCorner2.getY());
        } else if (dropX < xLimit && dropY > yLimit) {
            // Bottom left corner
            view.animate().x(mCorner3.getX()).y(mCorner3.getY());
        } else if (dropX > xLimit && dropY > yLimit) {
            // Bottom right corner
            view.animate().x(mCorner4.getX()).y(mCorner4.getY());
        }
    }
    return true;
}
 
开发者ID:delizondo,项目名称:CursoAndroid,代码行数:32,代码来源:AnimationsActivity.java

示例6: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@Override
public boolean onDrag(View view, DragEvent event) {
    if(event.getAction() == DragEvent.ACTION_DROP) {
        final View sourceView = (View) event.getLocalState();
        view.setVisibility(View.VISIBLE);

        final int sourceTag = (int) sourceView.getTag();
        if(sourceTag != mTargetTag && sourceView.getId() == R.id.column_card) {
            mParent.moveColumn(sourceTag, mTargetTag, event.getX() < view.getWidth() / 2);
        }
    }
    return true;
}
 
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:14,代码来源:ColumnFragment.java

示例7: processDrop

import android.view.DragEvent; //导入方法依赖的package包/类
private void processDrop(DragEvent event) {
    final ClipData data = event.getClipData();
    final int N = data.getItemCount();
    for (int i = 0; i < N; i++) {
        ClipData.Item item = data.getItemAt(i);
        Log.i(TAG, "Dropped item " + i + " : " + item);
        if (mReportView != null) {
            String text = item.coerceToText(getContext()).toString();
            if (event.getLocalState() == (Object) this) {
                text += " : Dropped on self!";
            }
            mReportView.setText(text);
        }
    }
}
 
开发者ID:luoqii,项目名称:ApkLauncher,代码行数:16,代码来源:DraggableDot.java

示例8: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@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;
        }
 
开发者ID:soomla,项目名称:android-profile,代码行数:40,代码来源:StoreExampleActivity.java

示例9: onDrag

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

            switch (dragEvent) {
                case DragEvent.ACTION_DRAG_ENTERED:
                    Log.i("DragEvent", "Entered");
                    break;
                case DragEvent.ACTION_DRAG_ENDED:
                    Log.i("DragEvent", "Ended");
                    break;
                case DragEvent.ACTION_DRAG_STARTED:
                    GraphicUnitWidget draggedView = (GraphicUnitWidget) event.getLocalState();
                    Log.i("DragEvent", "Started at LAMP = " + draggedView.getX() + "/" + draggedView.getY() + "   EVENT = " + event.getX() + "/" + event.getY());
                    dragXDiff = event.getX() - draggedView.getX();
                    dragYDiff = event.getY() - draggedView.getY();
                    //stop displaying the view where it was before it was dragged
                    draggedView.setVisibility(View.INVISIBLE);
                    break;
                case DragEvent.ACTION_DROP:
                    GraphicUnitWidget droppedView = (GraphicUnitWidget) event.getLocalState();
                    Log.i("DragEvent", "Dropped at LAMP = " + Math.round(event.getX() + dragXDiff) + "/" + Math.round(event.getY() + dragYDiff) + "   EVENT = " + event.getX() + "/" + event.getY());
                    Log.i("DragEvent", "Drop target at TOP = " + v.getTop() + "   LEFT = " + v.getLeft());
//                    droppedView.setX(Math.round(event.getX() + dragXDiff + v.getLeft() - 70));
//                    droppedView.setY(Math.round(event.getY() + dragYDiff/* + v.getTop()*/ - 50));
                    //TODO - Fix this temporary hard coded adjustment
                    droppedView.setX(Math.round(event.getX())-30);
                    droppedView.setY(Math.round(event.getY())-30);

                    droppedView.setVisibility(View.VISIBLE);

                    setRoomRelativePositions(droppedView);

                    Log.d("Unit", "Dropped view pos X/Y = " + droppedView.getX() + "/" + droppedView.getY());
                    Log.d("UnitPos", "dropped REL: " + droppedView.getgUnit().getRoomRelativeX() + "/" + droppedView.getgUnit().getRoomRelativeY() + "   Calc: X=(" + mRoomView.getScaledBitmapWidth() + "/(" + droppedView.getX() + "-" + mRoomView.getScaledBitmapX() + ")  Y=(" + mRoomView.getScaledBitmapHeight() + "/(" + droppedView.getY() + "-" + mRoomView.getScaledBitmapY() + ")");
                    break;
            }
            return true;
        }
 
开发者ID:tonyalpskog,项目名称:OpenHAB_Room_Flipper,代码行数:40,代码来源:UnitPlacementFragment.java

示例10: onCardsDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@Override
protected boolean onCardsDrag(View v, DragEvent event) {
	Card draggedCard = (Card) event.getLocalState();
	if (draggedCard==null || draggedCard.getParent() == null || this==draggedCard.getParent()) {
		return false;
	}
	BasePile draggedParent = (BasePile) draggedCard.getParent();

	switch (event.getAction()) {
	case DragEvent.ACTION_DRAG_STARTED:
		break;
	case DragEvent.ACTION_DRAG_ENTERED:
		setHighlight(true);
		break;
	case DragEvent.ACTION_DRAG_EXITED:

		setHighlight(false);
		break;
	case DragEvent.ACTION_DROP:
		setHighlight(false);

		if(!fitOnEachother(getLastCard(), draggedCard)){
			break;
		}
		moveCards(draggedParent,draggedCard);
		return true;
	case DragEvent.ACTION_DRAG_ENDED:
		setHighlight(false);
		int indexOfDragged = draggedParent.indexOfCard(draggedCard);
		for (int i = indexOfDragged; i < draggedParent.getCardsCount(); i++) {
			Card card = draggedParent.getCardAt(i);
			card.setVisibility(View.VISIBLE);
		}
		return false;
	default:
		break;
	}
	return true;
}
 
开发者ID:xklakoux,项目名称:spider-solitaire,代码行数:40,代码来源:Pile.java

示例11: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@Override
public boolean onDrag(View v, DragEvent event) {
	switch (event.getAction()) {
	case DragEvent.ACTION_DRAG_STARTED:
		break;
	case DragEvent.ACTION_DRAG_ENTERED:
		break;
	case DragEvent.ACTION_DRAG_EXITED:
		break;
	case DragEvent.ACTION_DROP:
		Log.v("Test", "Entered drop");
		final View view = (View) event.getLocalState();
		if (view != null && (view instanceof ImageView)) {
			ImageView castedView = (ImageView) view;
			if (castedView.getContentDescription().toString() == "grid") {
				final ViewGroup owner = (ViewGroup) view.getParent();
				owner.removeView(v);
			}
		}
		break;
	case DragEvent.ACTION_DRAG_ENDED:
		trash.setVisibility(View.INVISIBLE);
		break;
	default:
		break;
	}
	return true;
}
 
开发者ID:FAU-Inf2,项目名称:rpgpack-android,代码行数:29,代码来源:MapActivity.java

示例12: onDragEvent

import android.view.DragEvent; //导入方法依赖的package包/类
public boolean onDragEvent(DragEvent event) {
	if (!dragManager.onDragEvent(event)) {
		switch (event.getAction()) {
			case DragEvent.ACTION_DRAG_ENTERED:
				DragDataContainer<T> data = (DragDataContainer<T>) event.getLocalState();
				if (data.isReady()) {
					lastDragDataContainer = data;
					add(data.getData().get(0));
					startDragging(innerAdapter.getCount() - 1);
				}
				break;
			case DragEvent.ACTION_DRAG_LOCATION:
				break;
			case DragEvent.ACTION_DRAG_EXITED:
				if (lastDragDataContainer != null) {
					remove(innerAdapter.getCount() - 1);
					stopDragging();
				}
				break;
			case DragEvent.ACTION_DROP:
				if (lastDragDataContainer != null) {
					stopDraggingAfterInsert();
				}
				break;
		}
	}
	return true;
}
 
开发者ID:kuhnmi,项目名称:jukefox,代码行数:29,代码来源:MagicListAdapter.java

示例13: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@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;
}
 
开发者ID:vogellacompany,项目名称:codeexamples-android,代码行数:30,代码来源:DragActivity.java

示例14: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@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;
}
 
开发者ID:vogellacompany,项目名称:codeexamples-android,代码行数:29,代码来源:DragActivity.java

示例15: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@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();
    owner.removeView(view);
    LinearLayout container = (LinearLayout) v;
    container.addView(view);
    view.setVisibility(View.VISIBLE);
    break;
  case DragEvent.ACTION_DRAG_ENDED:
    v.setBackgroundDrawable(normalShape);
  default:
    break;
  }
  return true;
}
 
开发者ID:figa12,项目名称:sw606f13,代码行数:30,代码来源:MainActivity.java


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