performLongClick ( )源码实例Demo

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

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

源代码1 项目: iGap-Android   文件: MessagesAdapter.java
@Override
public boolean onLongClick(View v, IAdapter<Item> adapter, Item item, int position) {

    if (item instanceof TimeItem || item instanceof LogItem || item instanceof LogWallet) {
        if (item.isSelected()) v.performLongClick();
    } else {
        if (iMessageItem != null && item.mMessage != null && item.mMessage.senderID != null && !item.mMessage.senderID.equalsIgnoreCase("-1")) {

            if (item.mMessage.status.equalsIgnoreCase(ProtoGlobal.RoomMessageStatus.SENDING.toString()) || item.mMessage.status.equalsIgnoreCase(ProtoGlobal.RoomMessageStatus.FAILED.toString())) {

                if (item.isSelected()) v.performLongClick();
                return true;
            }

            if (onChatMessageSelectionChanged != null) {
                onChatMessageSelectionChanged.onChatMessageSelectionChanged(getSelectedItems().size(), getSelectedItems());
            }
        }
    }

    return true;
}
 
源代码2 项目: VCL-Android   文件: BaseBrowserFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
    if (!AndroidUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }
    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    setContextMenu(popupMenu.getMenuInflater(), popupMenu.getMenu(), position);

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 
源代码3 项目: VCL-Android   文件: AudioAlbumsSongsFragment.java
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
    if (!AndroidUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu());
    setContextMenuItems(popupMenu.getMenu(), anchor, position);

    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 
源代码4 项目: VCL-Android   文件: AudioAlbumFragment.java
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
    if (!AndroidUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu());
    setContextMenuItems(popupMenu.getMenu(), anchor, position);

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 
源代码5 项目: VCL-Android   文件: AudioBrowserFragment.java
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
    if (!AndroidUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu());
    setContextMenuItems(popupMenu.getMenu(), anchor);

    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 
源代码6 项目: VCL-Android   文件: VideoGridFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onContextPopupMenu(View anchor, final int position) {
    if (!AndroidUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu());
    MediaWrapper media = mVideoAdapter.getItem(position);
    if (media == null)
        return;
    setContextMenuItems(popupMenu.getMenu(), media);
    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 
源代码7 项目: butterknife   文件: OnLongClickTest.java
@UiThreadTest
@Test public void simple() {
  View tree = ViewTree.create(1);
  View view1 = tree.findViewById(1);

  Simple target = new Simple();
  Unbinder unbinder = ButterKnife.bind(target, tree);
  assertEquals(0, target.clicks);

  assertTrue(view1.performLongClick());
  assertEquals(1, target.clicks);

  target.returnValue = false;
  assertFalse(view1.performLongClick());
  assertEquals(2, target.clicks);

  unbinder.unbind();
  view1.performLongClick();
  assertEquals(2, target.clicks);
}
 
源代码8 项目: butterknife   文件: OnLongClickTest.java
@UiThreadTest
@Test public void returnVoid() {
  View tree = ViewTree.create(1);
  View view1 = tree.findViewById(1);

  ReturnVoid target = new ReturnVoid();
  Unbinder unbinder = ButterKnife.bind(target, tree);
  assertEquals(0, target.clicks);

  assertTrue(view1.performLongClick());
  assertEquals(1, target.clicks);

  unbinder.unbind();
  view1.performLongClick();
  assertEquals(1, target.clicks);
}
 
源代码9 项目: butterknife   文件: OnLongClickTest.java
@UiThreadTest
@Test public void visibilities() {
  View tree = ViewTree.create(1, 2, 3);
  View view1 = tree.findViewById(1);
  View view2 = tree.findViewById(2);
  View view3 = tree.findViewById(3);

  Visibilities target = new Visibilities();
  ButterKnife.bind(target, tree);
  assertEquals(0, target.clicks);

  view1.performLongClick();
  assertEquals(1, target.clicks);

  view2.performLongClick();
  assertEquals(2, target.clicks);

  view3.performLongClick();
  assertEquals(3, target.clicks);
}
 
源代码10 项目: butterknife   文件: OnLongClickTest.java
@UiThreadTest
@Test public void multipleIds() {
  View tree = ViewTree.create(1, 2);
  View view1 = tree.findViewById(1);
  View view2 = tree.findViewById(2);

  MultipleIds target = new MultipleIds();
  Unbinder unbinder = ButterKnife.bind(target, tree);
  assertEquals(0, target.clicks);

  view1.performLongClick();
  assertEquals(1, target.clicks);

  view2.performLongClick();
  assertEquals(2, target.clicks);

  unbinder.unbind();
  view1.performLongClick();
  view2.performLongClick();
  assertEquals(2, target.clicks);
}
 
源代码11 项目: butterknife   文件: OnLongClickTest.java
@UiThreadTest
@Test public void optionalIdPresent() {
  View tree = ViewTree.create(1);
  View view1 = tree.findViewById(1);

  OptionalId target = new OptionalId();
  Unbinder unbinder = ButterKnife.bind(target, tree);
  assertEquals(0, target.clicks);

  view1.performLongClick();
  assertEquals(1, target.clicks);

  unbinder.unbind();
  view1.performLongClick();
  assertEquals(1, target.clicks);
}
 
源代码12 项目: butterknife   文件: OnLongClickTest.java
@UiThreadTest
@Test public void optionalIdAbsent() {
  View tree = ViewTree.create(2);
  View view2 = tree.findViewById(2);

  OptionalId target = new OptionalId();
  Unbinder unbinder = ButterKnife.bind(target, tree);
  assertEquals(0, target.clicks);

  view2.performLongClick();
  assertEquals(0, target.clicks);

  unbinder.unbind();
  view2.performLongClick();
  assertEquals(0, target.clicks);
}
 
源代码13 项目: LaunchEnr   文件: LauncherAppWidgetHostView.java
@Override
public boolean onLongClick(View view) {
    if (mIsScrollable) {
        DragLayer dragLayer = Launcher.getLauncher(getContext()).getDragLayer();
        dragLayer.requestDisallowInterceptTouchEvent(false);
    }
    view.performLongClick();
    return true;
}
 
源代码14 项目: Virtual-Hosts   文件: DonationActivity.java
/**
 * Donate with bitcoin by opening a bitcoin: intent if available.
 */
public void donateBitcoinOnClick(View view) {
    try {
        startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("bitcoin:" + BITCOIN_ADDRESS)));
    } catch (ActivityNotFoundException e) {
        view.performLongClick();
    }
}
 
源代码15 项目: AndroidUtilCode   文件: TouchUtils.java
public boolean onUtilsStop(View view, MotionEvent event) {
    int x = (int) event.getRawX();
    int y = (int) event.getRawY();

    int vx = 0, vy = 0;

    if (velocityTracker != null) {
        velocityTracker.computeCurrentVelocity(1000, maximumFlingVelocity);
        vx = (int) velocityTracker.getXVelocity();
        vy = (int) velocityTracker.getYVelocity();
        velocityTracker.recycle();
        if (Math.abs(vx) < minimumFlingVelocity) {
            vx = 0;
        }
        if (Math.abs(vy) < minimumFlingVelocity) {
            vy = 0;
        }
        velocityTracker = null;
    }

    view.setPressed(false);
    boolean consumeStop = onStop(view, direction, x, y, x - downX, y - downY, vx, vy, event);

    if (event.getAction() == MotionEvent.ACTION_UP) {
        if (state == STATE_DOWN) {
            if (event.getEventTime() - event.getDownTime() <= MIN_TAP_TIME) {
                view.performClick();
            } else {
                view.performLongClick();
            }
        }
    }

    resetTouch(-1, -1);

    return consumeStop;
}
 
源代码16 项目: butterknife   文件: OnLongClickTest.java
@UiThreadTest
@Test public void argumentCast() {
  class MyView extends Button implements ArgumentCast.MyInterface {
    MyView(Context context) {
      super(context);
    }
  }

  View view1 = new MyView(InstrumentationRegistry.getContext());
  view1.setId(1);
  View view2 = new MyView(InstrumentationRegistry.getContext());
  view2.setId(2);
  View view3 = new MyView(InstrumentationRegistry.getContext());
  view3.setId(3);
  View view4 = new MyView(InstrumentationRegistry.getContext());
  view4.setId(4);
  ViewGroup tree = new FrameLayout(InstrumentationRegistry.getContext());
  tree.addView(view1);
  tree.addView(view2);
  tree.addView(view3);
  tree.addView(view4);

  ArgumentCast target = new ArgumentCast();
  ButterKnife.bind(target, tree);

  view1.performLongClick();
  assertSame(view1, target.last);

  view2.performLongClick();
  assertSame(view2, target.last);

  view3.performLongClick();
  assertSame(view3, target.last);

  view4.performLongClick();
  assertSame(view4, target.last);
}
 
源代码17 项目: libcommon   文件: ViewTransformDelegater.java
/**
	 * View#onTouchEventの処理
	 * falseを返したときにはView#super.onTouchEventでデフォルトの処理をすること
	 * @param event
	 * @return
	 */
	@SuppressLint("SwitchIntDef")
	public boolean onTouchEvent(final MotionEvent event) {
//		if (DEBUG) Log.v(TAG, "onTouchEvent:");

		if (mHandleTouchEvent == TOUCH_DISABLED) {
			return false;
		}

		final View view = getTargetView();
		final int actionCode = event.getActionMasked();	// >= API8

		switch (actionCode) {
		case MotionEvent.ACTION_DOWN:
			// single touch
			startWaiting(event);
			return true;
		case MotionEvent.ACTION_POINTER_DOWN:
		{	// マルチタッチ時の処理
			switch (mState) {
			case STATE_WAITING:
				// 最初のマルチタッチ → 拡大縮小・回転操作待機開始
				view.removeCallbacks(mWaitImageReset);
				// pass through
			case STATE_DRAGGING:
				if (event.getPointerCount() > 1) {
					startCheck(event);
					return true;
				}
				break;
			}
			break;
		}
		case MotionEvent.ACTION_MOVE:
		{
			// moving with single and multi touch
			switch (mState) {
			case STATE_WAITING:
				if (((mHandleTouchEvent & TOUCH_ENABLED_MOVE) == TOUCH_ENABLED_MOVE)
					&& checkTouchMoved(event)) {

					view.removeCallbacks(mWaitImageReset);
					setState(STATE_DRAGGING);
					return true;
				}
				break;
			case STATE_DRAGGING:
				if (processDrag(event))
					return true;
				break;
			case STATE_CHECKING:
				if (checkTouchMoved(event)
					&& ((mHandleTouchEvent & TOUCH_ENABLED_ZOOM) == TOUCH_ENABLED_ZOOM)) {

					startZoom(event);
					return true;
				}
				break;
			case STATE_ZOOMING:
				if (processZoom(event))
					return true;
				break;
			case STATE_ROTATING:
				if (processRotate(event))
					return true;
				break;
			}
			break;
		}
		case MotionEvent.ACTION_CANCEL:
			// pass through
		case MotionEvent.ACTION_UP:
			view.removeCallbacks(mWaitImageReset);
			view.removeCallbacks(mStartCheckRotate);
			if ((actionCode == MotionEvent.ACTION_UP) && (mState == STATE_WAITING)) {
				final long downTime = SystemClock.uptimeMillis() - event.getDownTime();
				if (downTime > LONG_PRESS_TIMEOUT) {
					view.performLongClick();
				} else if (downTime < TAP_TIMEOUT) {
					view.performClick();
				}
			}
			// pass through
		case MotionEvent.ACTION_POINTER_UP:
			setState(STATE_NON);
			break;
		}
		return false;
	}
 
源代码评论
动弹
沙发等你来抢
 方法所在类
 同类方法