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


Java DragEvent.getY方法代码示例

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


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

示例1: findAppropriateDropHandle

import android.view.DragEvent; //导入方法依赖的package包/类
private boolean findAppropriateDropHandle(DragEvent event) {
    Log.i(TAG, "Loc of parent: x:" + mLocationOnScreen[0] + " y:"
            + mLocationOnScreen[1]);
    mDragLocationOnScreen[0] = (int) (mLocationOnScreen[0] + event.getX());
    mDragLocationOnScreen[1] = (int) (mLocationOnScreen[1] + event.getY());
    Log.i(TAG, "DLV Drag location relative, x: " + mDragLocationOnScreen[0]
            + " y: " + mDragLocationOnScreen[1]);

    if (mCurrentDropHandleView != null) {
        ((DropAcceptable) mCurrentDropHandleView).onDrop(event);
        mCurrentDropHandleView = null;
        return true;
    } else {
        return false;
    }
}
 
开发者ID:nichollyn,项目名称:amddviews,代码行数:17,代码来源:DropableListView.java

示例2: findAppropriateDropHandle

import android.view.DragEvent; //导入方法依赖的package包/类
private boolean findAppropriateDropHandle(DragEvent event) {
    Log.i(TAG, "Loc of parent: x:" + mLocationOnScreen[0] + " y:"
            + mLocationOnScreen[1]);
    mDragLocationOnScreen[0] = (int) (mLocationOnScreen[0] + event.getX());
    mDragLocationOnScreen[1] = (int) (mLocationOnScreen[1] + event.getY());
    Log.i(TAG, "DGV Drag location relative, x: " + mDragLocationOnScreen[0]
            + " y: " + mDragLocationOnScreen[1]);

    if (mCurrentDropHandleView != null) {
        ((DropAcceptable) mCurrentDropHandleView).onDrop(event);
        mCurrentDropHandleView = null;
        return true;
    } else {
        return false;
    }
}
 
开发者ID:nichollyn,项目名称:amddviews,代码行数:17,代码来源:DropableGridView.java

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

示例4: onDragEvent

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

示例5: scrollOnDrag

import android.view.DragEvent; //导入方法依赖的package包/类
private void scrollOnDrag(View view, DragEvent event, ScrollView scrollView) {
    float ty = view.getTop() + event.getY();

    if (isAncestor(scrollView, view)) {

        int thresh = scrollView.getHeight() / 6;

        if (ty < scrollView.getScrollY() + thresh) {
            scrollView.smoothScrollBy(0, -10);
        } else if (ty > scrollView.getScrollY() + scrollView.getHeight() - thresh) {
            scrollView.smoothScrollBy(0, 10);
        }
    }
}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:15,代码来源:MainActivity.java

示例6: handleSystemDragStart

import android.view.DragEvent; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.N)
private void handleSystemDragStart(DragEvent event) {
    if (!FeatureFlags.LAUNCHER3_USE_SYSTEM_DRAG_DRIVER || !Utilities.isNycOrAbove()) {
        return;
    }
    if (mLauncher.isWorkspaceLocked()) {
        return;
    }

    ClipDescription description = event.getClipDescription();
    if (!description.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
        return;
    }
    ShortcutInfo info = new ShortcutInfo();
    // Set a dummy intent until we get the final value
    info.intent = new Intent();

    // Since we are not going through the workspace for starting the drag, set drag related
    // information on the workspace before starting the drag.
    ExternalDragPreviewProvider previewProvider =
            new ExternalDragPreviewProvider(mLauncher, info);
    mLauncher.getWorkspace().prepareDragWithProvider(previewProvider);

    DragOptions options = new DragOptions();
    options.systemDndStartPoint = new Point((int) event.getX(), (int) event.getY());

    int halfPadding = previewProvider.previewPadding / 2;
    mDragController.startDrag(
            Bitmap.createBitmap(1, 1, Config.ARGB_8888),
            0, 0,
            new AnotherWindowDragSource(mLauncher), info,
            new Point(- halfPadding, halfPadding),
            previewProvider.getPreviewBounds(), 1f, options);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:35,代码来源:DragLayer.java

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

示例8: setState

import android.view.DragEvent; //导入方法依赖的package包/类
private void setState(DragEvent event) {
    float translation = event.getY() - mStatePanelTrack.getTouchPoint().y;
    float alpha = 1.0f - (Math.abs(translation)
            / mStatePanelTrack.getCurrentView().getHeight());
    if (mStatePanelTrack.getOrientation() == LinearLayout.VERTICAL) {
        translation = event.getX() - mStatePanelTrack.getTouchPoint().x;
        alpha = 1.0f - (Math.abs(translation)
                / mStatePanelTrack.getCurrentView().getWidth());
        mStatePanelTrack.getCurrentView().setTranslationX(translation);
    } else {
        mStatePanelTrack.getCurrentView().setTranslationY(translation);
    }
    mStatePanelTrack.getCurrentView().setBackgroundAlpha(alpha);
}
 
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:15,代码来源:DragListener.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: onDragStart

import android.view.DragEvent; //导入方法依赖的package包/类
private boolean onDragStart(DragEvent event) {
    if (!mRequest.isValid()) {
        return false;
    }
    ClipDescription desc =  event.getClipDescription();
    if (desc == null || !desc.hasMimeType(getMimeType())) {
        return false;
    }

    final PendingAddItemInfo item;
    if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT) {
        item = new PendingAddShortcutInfo(
                new PinShortcutRequestActivityInfo(mRequest, mLauncher));
    } else {
        // mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_APPWIDGET
        LauncherAppWidgetProviderInfo providerInfo =
                LauncherAppWidgetProviderInfo.fromProviderInfo(
                        mLauncher, mRequest.getAppWidgetProviderInfo(mLauncher));
        final PinWidgetFlowHandler flowHandler =
                new PinWidgetFlowHandler(providerInfo, mRequest);
        item = new PendingAddWidgetInfo(providerInfo) {
            @Override
            public WidgetAddFlowHandler getHandler() {
                return flowHandler;
            }
        };
    }
    View view = new View(mLauncher);
    view.setTag(item);

    Point downPos = new Point((int) event.getX(), (int) event.getY());
    DragOptions options = new DragOptions();
    options.systemDndStartPoint = downPos;
    options.preDragCondition = this;

    // We use drag event position as the screenPos for the preview image. Since mPreviewRect
    // already includes the view position relative to the drag event on the source window,
    // and the absolute position (position relative to the screen) of drag event is same
    // across windows, using drag position here give a good estimate for relative position
    // to source window.
    PendingItemDragHelper dragHelper = new PendingItemDragHelper(view);
    if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_APPWIDGET) {
        dragHelper.setPreview(getPreview(mRequest));
    }

    dragHelper.startDrag(new Rect(mPreviewRect),
            mPreviewBitmapWidth, mPreviewViewWidth, downPos,  this, options);
    mDragStartTime = SystemClock.uptimeMillis();
    return true;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:51,代码来源:PinItemDragListener.java

示例11: onDragEvent

import android.view.DragEvent; //导入方法依赖的package包/类
@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();
            mReceivedDropEvent =
                    updateInfoFromClipData(event.getClipData(), event.getClipDescription());
            return mReceivedDropEvent;

        case DragEvent.ACTION_DRAG_EXITED:
            mEventListener.onDriverDragExitWindow();
            return true;

        case DragEvent.ACTION_DRAG_ENDED:
            if (mReceivedDropEvent) {
                mEventListener.onDriverDragEnd(mLastX, mLastY, null);
            } else {
                mEventListener.onDriverDragCancel();
            }
            return true;

        default:
            return false;
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:43,代码来源:DragDriver.java

示例12: onDragEvent

import android.view.DragEvent; //导入方法依赖的package包/类
@Override
public boolean onDragEvent(@NonNull DragEvent event) {
    PlenProgramAdapter adapter = mAdapter.orElseThrow(AssertionError::new);

    ClipDescription clipDescription = event.getClipDescription();
    if (clipDescription == null || !DRAG_DATA_LABEL.equals(clipDescription.getLabel())) {
        return false;
    }

    int x = (int) event.getX();
    int y = (int) event.getY();
    int position = pointToPosition(x, y);

    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_ENTERED:
            if (adapter.positionOfBlankRow() == INVALID_POSITION) {
                adapter.moveBlankRowToLast();
            }
            break;

        case DragEvent.ACTION_DRAG_LOCATION:
            removeCallbacks(mRemoveBlankRowCallback);
            // ドロップ予定地に空白行
            if (position != INVALID_POSITION) {
                View view = getChildAt(position - getFirstVisiblePosition());
                double viewCenter = view.getY() + view.getHeight() / 2.;
                if (Math.abs(y - viewCenter) < view.getHeight() / 2.) {
                    adapter.moveBlankRow(position);
                }
            }
            // 端にドラッグすると自動スクロール
            View child = getChildAt(0);
            double scrollZone = child != null ? child.getHeight() : 0;
            final int firstPosition = getFirstVisiblePosition();
            final int lastPosition = getLastVisiblePosition();
            if (y < scrollZone) smoothScrollToPosition(firstPosition - 1);
            if (y > getHeight() - scrollZone) smoothScrollToPosition(lastPosition + 1);
            break;

        case DragEvent.ACTION_DROP:
            getDragData(event.getClipData()).ifPresent(adapter::dropToBlankRow);
            break;

        case DragEvent.ACTION_DRAG_ENDED:
        case DragEvent.ACTION_DRAG_EXITED:
            adapter.removeBlankRow();
            break;
    }
    return true;
}
 
开发者ID:plenprojectcompany,项目名称:plen-Scenography_Android,代码行数:51,代码来源:PlenProgramView.java

示例13: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@Override
public boolean onDrag(View view, DragEvent event) {
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    if(event.getAction() == DragEvent.ACTION_DRAG_ENTERED && view
            .getId() == R.id.viewholder_card) {
        final RecyclerView rv = (RecyclerView) view.getParent();
        final CardAdapter ca = (CardAdapter) rv.getAdapter();
        final Rect r = new Rect();
        ((NestedScrollView) rv.getParent().getParent()).getHitRect(r);
        int first = -1;
        int last = -1;
        for(int i = 0; i < rv.getAdapter().getItemCount(); i++) {
            if(rv.getChildAt(i).getLocalVisibleRect(r)) {
                if(first == -1) {
                    first = i;
                } else if(i == rv.getAdapter().getItemCount() - 1) {
                    last = i;
                }
            } else if(first != -1) {
                last = i - 1;
                break;
            }
        }
        final int tp = ca.indexOf((int) view.getTag());
        final float relativePos = event.getY() - view.getY();
        final int[] pos = new int[2];
        if(tp == first) {
            rv.getChildAt(first).getLocationOnScreen(pos);
            if(pos[1] + relativePos < 0.1 * metrics.heightPixels) {
                dragUp();
            }

        } else if(tp == last) {
            rv.getChildAt(last).getLocationOnScreen(pos);
            if(pos[1] + relativePos > 0.9 * metrics.heightPixels) {
                dragDown();
            }

        }

    } else if(event.getAction() == DragEvent.ACTION_DRAG_LOCATION) {
        if(event.getX() / metrics.widthPixels > 0.85f && System
                .nanoTime() - mLastPageChange > 5E8) {
            dragRight();
            mLastPageChange = System.nanoTime();
        } else if(event.getX() / metrics.widthPixels < 0.15f && System
                .nanoTime() - mLastPageChange > 5E8) {
            dragLeft();
            mLastPageChange = System.nanoTime();
        }
    }
    return true;
}
 
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:54,代码来源:ProjectActivity.java

示例14: onDrag

import android.view.DragEvent; //导入方法依赖的package包/类
@Override
public boolean onDrag(View v, DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            mStart = new double[]{event.getX(), event.getY()};
            Log.i(TAG, "ACTION_DRAG_STARTED");
            // do nothing
            break;
        case DragEvent.ACTION_DRAG_ENTERED:
            Log.i(TAG, "ACTION_DRAG_ENTERED");
            v.setBackgroundResource(enterShape);
            break;
        case DragEvent.ACTION_DRAG_EXITED:
            Log.i(TAG, "ACTION_DRAG_EXITED");
            v.setBackgroundResource(normalShape);
            break;
        case DragEvent.ACTION_DROP:
            Log.i(TAG, "ACTION_DROP");
            // Dropped, reassign View to ViewGroup
            View view = (View) event.getLocalState();
            ViewGroup owner = (ViewGroup) view.getParent();
            owner.removeView(view);
            TileView container = (TileView) v;

            mFinal = new double[]{event.getX(), event.getY()};
            double[] newPos = coordinatesAfterDragging(container.getScale(), (String) view.getTag());
            mTileView.addMarker(view, newPos[0], newPos[1]);
            view.setTag(newPos[0]+":"+newPos[1]);
            view.setVisibility(View.VISIBLE);

            mFinal=null;
            mStart=null;
            break;
        case DragEvent.ACTION_DRAG_ENDED:
            Log.i(TAG, "ACTION_DRAG_ENDED");
            v.setBackgroundResource(normalShape);
        default:
            break;
    }
    return true;
}
 
开发者ID:bnsantos,项目名称:android-tiling-example,代码行数:42,代码来源:MyDragListener.java

示例15: onDrag

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

    View view = (View) event.getLocalState();

    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            // do nothing
            break;
        case DragEvent.ACTION_DRAG_ENTERED:
            break;
        case DragEvent.ACTION_DRAG_EXITED:
            break;

        case DragEvent.ACTION_DROP:
            if(!(v instanceof FrameLayout)){
                view.setVisibility(View.VISIBLE);
                return false;
            }
            if(!(((FrameLayout) v).getChildAt(0) instanceof MapView)){
                view.setVisibility(View.VISIBLE);
                return false;
            }

            MapView mapView = (MapView) ((FrameLayout) v).getChildAt(0);

            int x = (int) event.getX();
            int y = (int) event.getY();

            Point point = new Point(x,y);

            LatLng latLng = mapView.getMap().getProjection().fromScreenLocation(point);

            Resource resource;

            ClipData clipData = event.getClipData();
            ClipData.Item item = clipData.getItemAt(0);
            Bundle extras = item.getIntent().getExtras();
            if (extras!=null){
                resource = (Resource) extras.getSerializable("resource");
                int position = extras.getInt("position");
                if (!ResourceCategory.dragabledata.equals(resource.getResourceCategory())){
                    firstFragment.getResourceList().remove(resource);
                    firstFragment.getIconBitmapResourceList().remove(position);
                    firstFragment.getResourceImageAdapter().notifyDataSetChanged();
                }
                else{
                    resource.setIdRes(-1);
                }
                updateResourceOnDrop(resource, latLng, State.planned);
            }

            break;
        case DragEvent.ACTION_DRAG_ENDED:
            view.setVisibility(View.VISIBLE);
            break;
        default:
            v.setVisibility(View.VISIBLE);
            break;
    }
    return true;
}
 
开发者ID:IsticGLA,项目名称:SIT,代码行数:63,代码来源:AgentInterventionActivity.java


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