android.view.View#isInTouchMode ( )源码实例Demo

下面列出了android.view.View#isInTouchMode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LaunchEnr   文件: ShortcutsItemView.java
@Override
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch or not the correct view
    if (!v.isInTouchMode() || !(v.getParent() instanceof DeepShortcutView)) return false;
    // Return early if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;
    // Return early if an item is already being dragged (e.g. when long-pressing two shortcuts)
    if (mLauncher.getDragController().isDragging()) return false;

    // Long clicked on a shortcut.
    DeepShortcutView sv = (DeepShortcutView) v.getParent();
    sv.setWillDrawIcon(false);

    // Move the icon to align with the center-top of the touch point
    mIconShift.x = mIconLastTouchPos.x - sv.getIconCenter().x;
    mIconShift.y = mIconLastTouchPos.y - mLauncher.getDeviceProfile().iconSizePx;

    DragView dv = mLauncher.getWorkspace().beginDragShared(sv.getIconView(),
            (PopupContainerWithArrow) getParent(), sv.getFinalInfo(),
            new ShortcutDragPreviewProvider(sv.getIconView(), mIconShift), new DragOptions());
    dv.animateShift(-mIconShift.x, -mIconShift.y);

    // TODO: support dragging from within folder without having to close it
    AbstractFloatingView.closeOpenContainer(mLauncher, AbstractFloatingView.TYPE_FOLDER);
    return false;
}
 
源代码2 项目: Trebuchet   文件: Folder.java
private boolean beginDrag(View v, boolean accessible) {
    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }

        mLauncher.getWorkspace().beginDragShared(v, new Point(), this, accessible);

        mCurrentDragInfo = item;
        mEmptyCellRank = item.rank;
        mCurrentDragView = v;

        mContent.removeItem(mCurrentDragView);
        mInfo.remove(mCurrentDragInfo);
        mDragInProgress = true;
        mItemAddedBackToSelfViaIcon = false;
    }
    return true;
}
 
源代码3 项目: Trebuchet   文件: AllAppsContainerView.java
@Override
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!mLauncher.isAppsViewVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    // Start the drag
    mLauncher.getWorkspace().beginDragShared(v, mIconLastTouchPos, this, false);
    // Enter spring loaded mode
    mLauncher.enterSpringLoadedDragMode();

    return false;
}
 
源代码4 项目: Trebuchet   文件: Workspace.java
@Override
public void startDrag(CellLayout.CellInfo cellInfo, boolean accessible) {
    View child = cellInfo.cell;

    // Make sure the drag was started by a long press as opposed to a long click.
    if (!child.isInTouchMode()) {
        return;
    }

    mDragInfo = cellInfo;
    child.setVisibility(INVISIBLE);
    CellLayout layout = (CellLayout) child.getParent().getParent();
    layout.prepareChildForDrag(child);

    beginDragShared(child, this, accessible);
}
 
源代码5 项目: Trebuchet   文件: WidgetsContainerView.java
@Override
public boolean onLongClick(View v) {
    if (DEBUG) {
        Log.d(TAG, String.format("onLonglick [v=%s]", v));
    }
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!mLauncher.isWidgetsViewVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled
    Log.d(TAG, String.format("onLonglick dragging enabled?.", v));
    if (!mLauncher.isDraggingEnabled()) return false;

    boolean status = beginDragging(v);
    if (status && v.getTag() instanceof PendingAddWidgetInfo) {
        WidgetHostViewLoader hostLoader = new WidgetHostViewLoader(mLauncher, v);
        boolean preloadStatus = hostLoader.preloadWidget();
        if (DEBUG) {
            Log.d(TAG, String.format("preloading widget [status=%s]", preloadStatus));
        }
        mLauncher.getDragController().addDragListener(hostLoader);
    }
    return status;
}
 
源代码6 项目: TurboLauncher   文件: Folder.java
public boolean onLongClick(View v) {
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return true;

    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }

        mLauncher.getWorkspace().onDragStartedWithItem(v);
        mLauncher.getWorkspace().beginDragShared(v, this);

        mCurrentDragInfo = item;
        mEmptyCell[0] = item.cellX;
        mEmptyCell[1] = item.cellY;
        mCurrentDragView = v;

        mContent.removeView(mCurrentDragView);
        mInfo.remove(mCurrentDragInfo);
        mDragInProgress = true;
        mItemAddedBackToSelfViaIcon = false;
    }
    return true;
}
 
源代码7 项目: TurboLauncher   文件: Workspace.java
void startDrag(CellLayout.CellInfo cellInfo) {
    View child = cellInfo.cell;

    // Make sure the drag was started by a long press as opposed to a long click.
    if (!child.isInTouchMode()) {
        return;
    }

    mDragInfo = cellInfo;
    child.setVisibility(INVISIBLE);
    CellLayout layout = (CellLayout) child.getParent().getParent();
    layout.prepareChildForDrag(child);

    child.clearFocus();
    child.setPressed(false);

    final Canvas canvas = new Canvas();

    // The outline is used to visualize where the item will land if dropped
    mDragOutline = createDragOutline(child, canvas, DRAG_BITMAP_PADDING);
    beginDragShared(child, this);
}
 
源代码8 项目: LB-Launcher   文件: Folder.java
public boolean onLongClick(View v) {
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return true;

    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }

        mLauncher.getWorkspace().beginDragShared(v, this);

        mCurrentDragInfo = item;
        mEmptyCell[0] = item.cellX;
        mEmptyCell[1] = item.cellY;
        mCurrentDragView = v;

        mContent.removeView(mCurrentDragView);
        mInfo.remove(mCurrentDragInfo);
        mDragInProgress = true;
        mItemAddedBackToSelfViaIcon = false;
    }
    return true;
}
 
源代码9 项目: LaunchEnr   文件: AllAppsContainerView.java
@Override
public boolean onLongClick(final View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // When we have exited all apps or are in transition, disregard long clicks

    if (!mLauncher.isAppsViewVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled or we are already dragging
    if (!mLauncher.isDraggingEnabled()) return false;
    if (mLauncher.getDragController().isDragging()) return false;

    // Start the drag
    final DragController dragController = mLauncher.getDragController();
    dragController.addDragListener(new DragController.DragListener() {
        @Override
        public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
            v.setVisibility(INVISIBLE);
        }

        @Override
        public void onDragEnd() {
            v.setVisibility(VISIBLE);
            dragController.removeDragListener(this);
        }
    });
    mLauncher.getWorkspace().beginDragShared(v, this, new DragOptions());
    return false;
}
 
源代码10 项目: LaunchEnr   文件: Folder.java
public boolean startDrag(View v, DragOptions options) {
    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }

        mEmptyCellRank = item.rank;
        mCurrentDragView = v;

        mDragController.addDragListener(this);
        if (options.isAccessibleDrag) {
            mDragController.addDragListener(new AccessibleDragListenerAdapter(
                    mContent, CellLayout.FOLDER_ACCESSIBILITY_DRAG) {

                @Override
                protected void enableAccessibleDrag(boolean enable) {
                    super.enableAccessibleDrag(enable);
                    mFooter.setImportantForAccessibility(enable
                            ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                            : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
                }
            });
        }

        mLauncher.getWorkspace().beginDragShared(v, this, options);
    }
    return true;
}
 
源代码11 项目: LaunchEnr   文件: Workspace.java
public void startDrag(CellLayout.CellInfo cellInfo, DragOptions options) {
    View child = cellInfo.cell;

    // Make sure the drag was started by a long press as opposed to a long click.
    if (!child.isInTouchMode()) {
        return;
    }

    mDragInfo = cellInfo;
    child.setVisibility(INVISIBLE);

    if (options.isAccessibleDrag) {
        mDragController.addDragListener(new AccessibleDragListenerAdapter(
                this, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG) {
            @Override
            protected void enableAccessibleDrag(boolean enable) {
                super.enableAccessibleDrag(enable);
                setEnableForLayout(mLauncher.getHotseat().getLayout(),enable);

                // We need to allow our individual children to become click handlers in this
                // case, so temporarily unset the click handlers.
                setOnClickListener(enable ? null : mLauncher);
            }
        });
    }

    beginDragShared(child, this, options);
}
 
源代码12 项目: LaunchEnr   文件: WidgetsContainerView.java
public boolean handleLongClick(View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // When we  are in transition, disregard long clicks
    if (mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    return beginDragging(v);
}
 
源代码13 项目: zapp   文件: MainActivity.java
private void onSearchQueryTextFocusChangeListener(View searchView, boolean hasFocus) {
	if (hasFocus && !searchView.isInTouchMode()) {
		searchView.post(() -> {
			InputMethodManager imm = (InputMethodManager) MainActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
			imm.showSoftInput(searchView.findFocus(), InputMethodManager.SHOW_FORCED);
		});
	}
}
 
@Override
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // Return early if we are still animating the pages
    if (mNextPage != INVALID_PAGE) return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!mLauncher.isAllAppsVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    return beginDragging(v);
}
 
源代码15 项目: LB-Launcher   文件: PagedViewWithDraggableItems.java
@Override
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // Return early if we are still animating the pages
    if (mNextPage != INVALID_PAGE) return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!mLauncher.isAllAppsVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    return beginDragging(v);
}
 
 方法所在类
 同类方法