本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}