Java Code Examples for android.view.DragEvent#ACTION_DRAG_ENDED
The following examples show how to use
android.view.DragEvent#ACTION_DRAG_ENDED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DragListenerGridView.java From PlusDemo with Apache License 2.0 | 6 votes |
@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; }
Example 2
Source File: FlingToDeleteHelper.java From LaunchEnr with GNU General Public License v3.0 | 6 votes |
/** * 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(); }
Example 3
Source File: DragDropTouchDragListener.java From RecyclerViewExtensions with MIT License | 6 votes |
@Override public boolean onDrag(View view, DragEvent event) { switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: intercept = false; startTime = SystemClock.uptimeMillis(); dispatchTouchEvent(view, MotionEvent.ACTION_DOWN, event.getX(), event.getY()); // Return true to receive further events. return true; case DragEvent.ACTION_DRAG_LOCATION: dispatchTouchEvent(view, MotionEvent.ACTION_MOVE, event.getX(), event.getY()); return false; case DragEvent.ACTION_DRAG_ENDED: dispatchTouchEvent(view, MotionEvent.ACTION_UP, event.getX(), event.getY()); return false; default: return false; } }
Example 4
Source File: CompositorViewHolder.java From 365browser with Apache License 2.0 | 6 votes |
@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; }
Example 5
Source File: CompositorViewHolder.java From AndroidChromium with Apache License 2.0 | 6 votes |
@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; }
Example 6
Source File: PasswordButton.java From Yahala-Messenger with MIT License | 6 votes |
@Override public boolean onDragEvent(DragEvent event) { PasswordStateObject state = (PasswordStateObject) event.getLocalState(); if (event.getAction() == DragEvent.ACTION_DRAG_LOCATION) { if (!state.toString().contains((String) getTag())) { state.append((String) getTag()); ((PasswordListener) getParent()).onPasswordButtonTouched(this); setBackgroundResource(R.drawable.loginbuttonpressed); } } if (event.getAction() == DragEvent.ACTION_DRAG_ENDED) if (state != null) { state.passwordComplete(); } return true; }
Example 7
Source File: ImageDragListener.java From user-interface-samples with Apache License 2.0 | 5 votes |
@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; }
Example 8
Source File: DragActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@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; }
Example 9
Source File: AppLauncherDragListener.java From DistroHopper with GNU General Public License v3.0 | 5 votes |
@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; }
Example 10
Source File: StoreExampleActivity.java From android-profile with Apache License 2.0 | 5 votes |
@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; }
Example 11
Source File: HomeActivityDelegate.java From Taskbar with Apache License 2.0 | 5 votes |
@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; }
Example 12
Source File: DragActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@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; }
Example 13
Source File: ImageDragListener.java From android-DragAndDropAcrossApps with Apache License 2.0 | 5 votes |
@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; }
Example 14
Source File: ImageDragListener.java From android-DragAndDropAcrossApps with Apache License 2.0 | 5 votes |
@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; }
Example 15
Source File: DragActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@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; }
Example 16
Source File: ImageDragListener.java From user-interface-samples with Apache License 2.0 | 5 votes |
@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; }
Example 17
Source File: PipeOnDragListener.java From ssj with GNU General Public License v3.0 | 4 votes |
/** * @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; }
Example 18
Source File: ViewDragListenerView.java From Android_UE with Apache License 2.0 | 4 votes |
@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; }
Example 19
Source File: EditFragment.java From Passbook with Apache License 2.0 | 4 votes |
@Override public boolean onDrag(View v, DragEvent event) { final int action = event.getAction(); switch(action) { case DragEvent.ACTION_DRAG_STARTED: return true; case DragEvent.ACTION_DRAG_ENTERED: if(v==mDeleteView) { mDeleteView.setColorFilter(C.ThemedColors[C.colorAccent]); mDeleteView.setScaleX(1.2f); mDeleteView.setScaleY(1.2f); } else { mDeleteView.setColorFilter(C.ThemedColors[C.colorTextNormal]); mDeleteView.setScaleX(1.0f); mDeleteView.setScaleY(1.0f); EntryHolder eh = (EntryHolder) v.getTag(); if (mDragged.mEntryLayout != eh.mEntryLayout) { int index = mEntries.indexOf(eh); mDeleteView.animate().setDuration(300).y(v.getY() + (mItemHeight - mDeleteView.getMeasuredHeight())/2); eh = mEntries.get(mIndex); mEntries.remove(mIndex); mEntries.add(index, eh); mContainer.removeViewAt(mIndex); mContainer.addView(eh.mEntryLayout,index); mIndex = index; } } return true; case DragEvent.ACTION_DRAG_ENDED: mDeleteView.setVisibility(View.INVISIBLE); if(v!=mDeleteView) { mDragged.mEntryContainer.setVisibility(View.VISIBLE); mDragged.mEntryLayout.setAlpha(1.0f); } return true; case DragEvent.ACTION_DRAG_LOCATION: int yPosition = (int)v.getY(); int scrollY = mScroll.getScrollY(); if(yPosition < scrollY) { mScroll.smoothScrollBy(0, -mItemHeight); } if(yPosition - scrollY > mAdjustScrollY) { mScroll.smoothScrollBy(0, mItemHeight); } return true; case DragEvent.ACTION_DROP: if(v==mDeleteView) { delete(mDragged); } return true; } return false; }
Example 20
Source File: DraggableDot.java From codeexamples-android with Eclipse Public License 1.0 | 4 votes |
/** * 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; }