android.view.View.isInTouchMode()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(280)

本文整理了Java中android.view.View.isInTouchMode()方法的一些代码示例,展示了View.isInTouchMode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。View.isInTouchMode()方法的具体详情如下:
包路径:android.view.View
类名称:View
方法名:isInTouchMode

View.isInTouchMode介绍

暂无

代码示例

代码示例来源:origin: square/assertj-android

public S isInTouchMode() {
 isNotNull();
 assertThat(actual.isInTouchMode()) //
   .overridingErrorMessage("Expected to be in touch mode but was not") //
   .isTrue();
 return myself;
}

代码示例来源:origin: square/assertj-android

public S isNotInTouchMode() {
 isNotNull();
 assertThat(actual.isInTouchMode()) //
   .overridingErrorMessage("Expected to not be in touch mode but was") //
   .isFalse();
 return myself;
}

代码示例来源:origin: com.squareup.assertj/assertj-android

public S isNotInTouchMode() {
 isNotNull();
 assertThat(actual.isInTouchMode()) //
   .overridingErrorMessage("Expected to not be in touch mode but was") //
   .isFalse();
 return myself;
}

代码示例来源:origin: com.squareup.assertj/assertj-android

public S isInTouchMode() {
 isNotNull();
 assertThat(actual.isInTouchMode()) //
   .overridingErrorMessage("Expected to be in touch mode but was not") //
   .isTrue();
 return myself;
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

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);
  beginDragShared(child, this);
}

代码示例来源:origin: fookwood/Launcher3

@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);
}

代码示例来源:origin: fookwood/Launcher3

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;
}

代码示例来源:origin: klinker24/launcher3

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);
  CellLayout layout = (CellLayout) child.getParent().getParent();
  layout.prepareChildForDrag(child);
  if (options.isAccessibleDrag) {
    mDragController.addDragListener(new AccessibileDragListenerAdapter(
        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);
}

代码示例来源:origin: enricocid/LaunchEnr

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);
}

代码示例来源:origin: fookwood/Launcher3

@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;
}

代码示例来源:origin: enricocid/LaunchEnr

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;
}

代码示例来源:origin: klinker24/launcher3

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 AccessibileDragListenerAdapter(
          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;
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

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;
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

@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
  return mLauncher.isDraggingEnabled() && beginDragging(v);
}

代码示例来源:origin: fookwood/Launcher3

@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;
}

代码示例来源:origin: klinker24/launcher3

@Override
public boolean onLongClick(View v) {
  if (LOGD) {
    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
  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 (LOGD) {
      Log.d(TAG, String.format("preloading widget [status=%s]", preloadStatus));
    }
    mLauncher.getDragController().addDragListener(hostLoader);
  }
  return status;
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

@Override
public boolean onLongClick(View v) {
  if (LOGD) {
    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
  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 (LOGD) {
      Log.d(TAG, String.format("preloading widget [status=%s]", preloadStatus));
    }
    mLauncher.getDragController().addDragListener(hostLoader);
  }
  return status;
}

代码示例来源:origin: klinker24/launcher3

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 if global dragging is not enabled
  if (!mLauncher.isDraggingEnabled()) return false;
  // Long clicked on a shortcut.
  mDeferContainerRemoval = true;
  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.getBubbleText(), this, 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
  mLauncher.closeFolder();
  return false;
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

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 if global dragging is not enabled
  if (!mLauncher.isDraggingEnabled()) return false;
  // Long clicked on a shortcut.
  mDeferContainerRemoval = true;
  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.getBubbleText(), this, 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
  mLauncher.closeFolder();
  return false;
}

代码示例来源:origin: enricocid/LaunchEnr

@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;
}

相关文章

微信公众号

最新文章

更多

View类方法