android.view.View.OnLongClickListener Java Examples
The following examples show how to use
android.view.View.OnLongClickListener.
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: TextInputLayoutActions.java From material-components-android with Apache License 2.0 | 8 votes |
public static ViewAction setEndIconOnLongClickListener( final OnLongClickListener onLongClickListener) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return isAssignableFrom(TextInputLayout.class); } @Override public String getDescription() { return "Set end icon OnLongClickListener"; } @Override public void perform(UiController uiController, View view) { TextInputLayout layout = (TextInputLayout) view; layout.setEndIconOnLongClickListener(onLongClickListener); } }; }
Example #2
Source File: TextInputLayoutActions.java From material-components-android with Apache License 2.0 | 6 votes |
public static ViewAction setStartIconOnLongClickListener( final OnLongClickListener onLongClickListener) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return isAssignableFrom(TextInputLayout.class); } @Override public String getDescription() { return "Set a long click listener for the start icon"; } @Override public void perform(UiController uiController, View view) { TextInputLayout layout = (TextInputLayout) view; layout.setStartIconOnLongClickListener(onLongClickListener); } }; }
Example #3
Source File: VaultsListFragment.java From secrecy with Apache License 2.0 | 6 votes |
void showTutorial() { if ((adapter.getCount() > 0 && PreferenceManager.getDefaultSharedPreferences(context) .getBoolean("showVaultLongClickTutorial", true))) { final View mView = context.getLayoutInflater().inflate(R.layout.vault_item_tutorial, mLinearView, false); TextView mInstructions = (TextView) mView.findViewById(R.id.Tutorial__instruction); if (mInstructions != null) mInstructions.setText(R.string.Tutorial__long_click_to_rename); mLinearView.addView(mView, 0); mView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { mLinearView.removeView(mView); SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); editor.putBoolean("showVaultLongClickTutorial", false); editor.apply(); return true; } }); } }
Example #4
Source File: CustomButtonParams.java From 365browser with Apache License 2.0 | 5 votes |
/** * Builds an {@link ImageButton} from the data in this params. Generated buttons should be * placed on the bottom bar. The button's tag will be its id. * @param parent The parent that the inflated {@link ImageButton}. * @param listener {@link OnClickListener} that should be used with the button. * @return Parsed list of {@link CustomButtonParams}, which is empty if the input is invalid. */ ImageButton buildBottomBarButton(Context context, ViewGroup parent, OnClickListener listener) { if (mIsOnToolbar) return null; ImageButton button = (ImageButton) LayoutInflater.from(context) .inflate(R.layout.custom_tabs_bottombar_item, parent, false); button.setId(mId); button.setImageBitmap(mIcon); button.setContentDescription(mDescription); if (mPendingIntent == null) { button.setEnabled(false); } else { button.setOnClickListener(listener); } button.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View view) { final int screenWidth = view.getResources().getDisplayMetrics().widthPixels; final int screenHeight = view.getResources().getDisplayMetrics().heightPixels; final int[] screenPos = new int[2]; view.getLocationOnScreen(screenPos); final int width = view.getWidth(); Toast toast = Toast.makeText( view.getContext(), view.getContentDescription(), Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM | Gravity.END, screenWidth - screenPos[0] - width / 2, screenHeight - screenPos[1]); toast.show(); return true; } }); return button; }
Example #5
Source File: PostActivity.java From Onosendai with Apache License 2.0 | 5 votes |
protected void extraMenuSetup () { final View mnuPost = findViewById(R.id.mnuPost); mnuPost.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick (final View v) { askPost(true); return true; } }); }
Example #6
Source File: BaseTile.java From GravityBox with Apache License 2.0 | 5 votes |
@Override public void onDualModeSet(View tileView, boolean enabled) { if (enabled) { View bgView = (View) XposedHelpers.getObjectField(tileView, "mTopBackgroundView"); bgView.setOnLongClickListener((OnLongClickListener) XposedHelpers.getObjectField(tileView, "mLongClick")); } }
Example #7
Source File: CustomButtonParams.java From delion with Apache License 2.0 | 5 votes |
/** * Builds an {@link ImageButton} from the data in this params. Generated buttons should be * placed on the bottom bar. The button's tag will be its id. * @param parent The parent that the inflated {@link ImageButton}. * @param listener {@link OnClickListener} that should be used with the button. * @return Parsed list of {@link CustomButtonParams}, which is empty if the input is invalid. */ ImageButton buildBottomBarButton(Context context, ViewGroup parent, OnClickListener listener) { if (mIsOnToolbar) return null; ImageButton button = (ImageButton) LayoutInflater.from(context) .inflate(R.layout.custom_tabs_bottombar_item, parent, false); button.setId(mId); button.setImageBitmap(mIcon); button.setContentDescription(mDescription); if (mPendingIntent == null) { button.setEnabled(false); } else { button.setOnClickListener(listener); } button.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View view) { final int screenWidth = view.getResources().getDisplayMetrics().widthPixels; final int screenHeight = view.getResources().getDisplayMetrics().heightPixels; final int[] screenPos = new int[2]; view.getLocationOnScreen(screenPos); final int width = view.getWidth(); Toast toast = Toast.makeText( view.getContext(), view.getContentDescription(), Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM | Gravity.END, screenWidth - screenPos[0] - width / 2, screenHeight - screenPos[1]); toast.show(); return true; } }); return button; }
Example #8
Source File: CustomButtonParams.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Builds an {@link ImageButton} from the data in this params. Generated buttons should be * placed on the bottom bar. The button's tag will be its id. * @param parent The parent that the inflated {@link ImageButton}. * @param listener {@link OnClickListener} that should be used with the button. * @return Parsed list of {@link CustomButtonParams}, which is empty if the input is invalid. */ ImageButton buildBottomBarButton(Context context, ViewGroup parent, OnClickListener listener) { if (mIsOnToolbar) return null; ImageButton button = (ImageButton) LayoutInflater.from(context) .inflate(R.layout.custom_tabs_bottombar_item, parent, false); button.setId(mId); button.setImageBitmap(mIcon); button.setContentDescription(mDescription); if (mPendingIntent == null) { button.setEnabled(false); } else { button.setOnClickListener(listener); } button.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View view) { final int screenWidth = view.getResources().getDisplayMetrics().widthPixels; final int screenHeight = view.getResources().getDisplayMetrics().heightPixels; final int[] screenPos = new int[2]; view.getLocationOnScreen(screenPos); final int width = view.getWidth(); Toast toast = Toast.makeText( view.getContext(), view.getContentDescription(), Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM | Gravity.END, screenWidth - screenPos[0] - width / 2, screenHeight - screenPos[1]); toast.show(); return true; } }); return button; }
Example #9
Source File: HintedImageBtn.java From android-discourse with Apache License 2.0 | 5 votes |
@Override public void setOnLongClickListener(OnLongClickListener l) { if (l == this) { super.setOnLongClickListener(l); return; } mOnLongClickListener = l; }
Example #10
Source File: FixedLinkMovementMethod.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
@Override public void initialize(TextView widget, final Spannable text) { widget.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { skipNextClick = true; Selection.removeSelection(text); return false; } }); super.initialize(widget, text); }
Example #11
Source File: MessageAdapter.java From school_shop with MIT License | 5 votes |
/** * 文本消息 * * @param message * @param holder * @param position */ private void handleTextMessage(EMMessage message, ViewHolder holder, final int position) { TextMessageBody txtBody = (TextMessageBody) message.getBody(); Spannable span = SmileUtils.getSmiledText(context, txtBody.getMessage()); // 设置内容 holder.tv.setText(span, BufferType.SPANNABLE); // 设置长按事件监听 holder.tv.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult( (new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type", EMMessage.Type.TXT.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU); return true; } }); if (message.direct == EMMessage.Direct.SEND) { switch (message.status) { case SUCCESS: // 发送成功 holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: // 发送失败 holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: // 发送中 holder.pb.setVisibility(View.VISIBLE); holder.staus_iv.setVisibility(View.GONE); break; default: // 发送消息 sendMsgInBackground(message, holder); } } }
Example #12
Source File: OnLongClickDecorator.java From Decor with Apache License 2.0 | 5 votes |
@Override protected void apply(View view, final TypedArray typedArray) { view.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { onAction(typedArray.getString(R.styleable.OnLongClickDecorator_decorOnLongClick)); return true; } }); }
Example #13
Source File: PhotoViewAttacher.java From BlackLight with GNU General Public License v3.0 | 4 votes |
@Override public void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #14
Source File: PhotoViewAttacher.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 4 votes |
@Override public void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #15
Source File: CropPhotoViewAttacher.java From ImageSelector with Apache License 2.0 | 4 votes |
@Override public void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #16
Source File: LauncherClings.java From LB-Launcher with Apache License 2.0 | 4 votes |
public void showLongPressCling(boolean showWelcome) { ViewGroup root = (ViewGroup) mLauncher.findViewById(R.id.launcher); View cling = mInflater.inflate(R.layout.longpress_cling, root, false); cling.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { mLauncher.getWorkspace().enterOverviewMode(); dismissLongPressCling(); return true; } }); final ViewGroup content = (ViewGroup) cling.findViewById(R.id.cling_content); mInflater.inflate(showWelcome ? R.layout.longpress_cling_welcome_content : R.layout.longpress_cling_content, content); content.findViewById(R.id.cling_dismiss_longpress_info).setOnClickListener(this); if (TAG_CROP_TOP_AND_SIDES.equals(content.getTag())) { Drawable bg = new BorderCropDrawable(mLauncher.getResources().getDrawable(R.drawable.cling_bg), true, true, true, false); content.setBackground(bg); } root.addView(cling); if (showWelcome) { // This is the first cling being shown. No need to animate. return; } // Animate content.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { content.getViewTreeObserver().removeOnGlobalLayoutListener(this); ObjectAnimator anim; if (TAG_CROP_TOP_AND_SIDES.equals(content.getTag())) { content.setTranslationY(-content.getMeasuredHeight()); anim = LauncherAnimUtils.ofFloat(content, "translationY", 0); } else { content.setScaleX(0); content.setScaleY(0); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1); anim = LauncherAnimUtils.ofPropertyValuesHolder(content, scaleX, scaleY); } anim.setDuration(SHOW_CLING_DURATION); anim.setInterpolator(new LogDecelerateInterpolator(100, 0)); anim.start(); } }); }
Example #17
Source File: PhotoViewAttacher.java From RotatePhotoView with Apache License 2.0 | 4 votes |
@Override public void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #18
Source File: PhotoViewAttacher.java From UltimateAndroid with Apache License 2.0 | 4 votes |
@Override public void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #19
Source File: ImageViewScaler.java From MultiView with Apache License 2.0 | 4 votes |
@Override public void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #20
Source File: PhotoViewAttacher.java From zen4android with MIT License | 4 votes |
@Override public final void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #21
Source File: PhotoViewAttacher.java From Favorite-Android-Client with Apache License 2.0 | 4 votes |
@Override public final void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #22
Source File: PhotoViewAttacher.java From school_shop with MIT License | 4 votes |
@Override public final void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #23
Source File: PhotoViewAttacher.java From iBeebo with GNU General Public License v3.0 | 4 votes |
@Override public final void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #24
Source File: PhotoViewAttacher.java From WifiChat with GNU General Public License v2.0 | 4 votes |
@Override public final void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #25
Source File: PhotoViewAttacher.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
@Override public final void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #26
Source File: PhotoViewAttacher.java From MoeGallery with GNU General Public License v3.0 | 4 votes |
@Override public void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #27
Source File: PhotoViewAttacher.java From jmessage-android-uikit with MIT License | 4 votes |
@Override public final void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #28
Source File: PhotoViewAttacher.java From jmessage-android-uikit with MIT License | 4 votes |
@Override public final void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #29
Source File: PhotoViewAttacher.java From Dashboard with MIT License | 4 votes |
@Override public final void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }
Example #30
Source File: PhotoViewAttacher.java From GalleryFinal with Apache License 2.0 | 4 votes |
@Override public void setOnLongClickListener(OnLongClickListener listener) { mLongClickListener = listener; }