Java Code Examples for android.view.View#OnLongClickListener

The following examples show how to use android.view.View#OnLongClickListener . These examples are extracted from open source projects. 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
private void addOnItemLongClickListener(@NonNull final VH holder){
    if (!itemLongClickEnable) return;
    if (onLongClickListener == null){
        onLongClickListener = new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                int position = (int) v.getTag();
                if (onItemLongClickListener != null) {
                    return onItemLongClickListener.onItemLongClick(v, position, getItemAt(position), getItemViewType(position));
                }
                return false;
            }
        };
    }
    holder.itemView.setOnLongClickListener(onLongClickListener);
}
 
Example 2
private View.OnLongClickListener getDefaultChildLongClickListener() {
    if (defaultChildLongClickListener == null)
        defaultChildLongClickListener = new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                ensureBoundedRecyclerView();
                View itemView = recyclerView.findContainingItemView(v);
                int position = itemView == null ? -1 : recyclerView.getChildAdapterPosition(itemView) - getCustomHeaderSize();
                int viewType = getItemViewType(position);
                switch (viewType) {
                    case TYPE_HEADER:
                        return getOnItemChildLongClickListener() != null && getOnItemChildLongClickListener().onHeaderItemChildLongClick(v, position, getHeaderAt(position));
                    case TYPE_DATA:
                        return getOnItemChildLongClickListener() != null && getOnItemChildLongClickListener().onDataItemChildLongClick(v, position, getDataAt(position));
                    case TYPE_FOOTER:
                        return getOnItemChildLongClickListener() != null && getOnItemChildLongClickListener().onFooterItemChildLongClick(v, position, getFooterAt(position));
                    case TYPE_EMPTY:
                        return getOnItemChildLongClickListener() != null && getOnItemChildLongClickListener().onEmptyItemChildLongClick(v, position, getEmptyAt(position));
                    case UNKNOWN:
                    default:
                        return false;
                }
            }
        };
    return defaultChildLongClickListener;
}
 
Example 3
Source Project: ChatKit   File: MessagesListAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private View.OnLongClickListener getMessageLongClickListener(final Wrapper<MESSAGE> wrapper) {
    return new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            if (selectionListener == null) {
                notifyMessageLongClicked(wrapper.item);
                notifyMessageViewLongClicked(view, wrapper.item);
                return true;
            } else {
                isSelectionModeEnabled = true;
                view.performClick();
                return true;
            }
        }
    };
}
 
Example 4
Source Project: openlauncher   File: DragHandler.java    License: Apache License 2.0 5 votes vote down vote up
public static View.OnLongClickListener getLongClick(final Item item, final DragAction.Action action, final DesktopCallback desktopCallback) {
    return new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            if (Setup.appSettings().getDesktopLock()) {
                return false;
            }
            if (Setup.appSettings().getGestureFeedback()) {
                Tool.vibrate(view);
            }
            startDrag(view, item, action, desktopCallback);
            return true;
        }
    };
}
 
Example 5
Source Project: DevUtils   File: ListenerUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置长按事件
 * @param activity            {@link Activity}
 * @param onLongClickListener {@link View.OnLongClickListener}
 * @param viewIds             View id 数组
 * @return {@code true} success, {@code false} fail
 */
public static boolean setOnLongClicks(final Activity activity, final View.OnLongClickListener onLongClickListener, @IdRes final int... viewIds) {
    if (activity != null && onLongClickListener != null && viewIds != null) {
        for (int i = 0, len = viewIds.length; i < len; i++) {
            View findView = ViewUtils.findViewById(activity, viewIds[i]);
            if (findView != null) {
                findView.setOnLongClickListener(onLongClickListener);
            }
        }
        return true;
    }
    return false;
}
 
Example 6
public GroupedRecyclerViewItemListItemView(
		@Nullable final Drawable icon,
		@NonNull final CharSequence text,
		final boolean hideDivider,
		@Nullable final View.OnClickListener clickListener,
		@Nullable final View.OnLongClickListener longClickListener) {

	mIcon = icon;
	mText = text;
	mHideDivider = hideDivider;
	mClickListener = clickListener;
	mLongClickListener = longClickListener;
}
 
Example 7
Source Project: likequanmintv   File: ViewHolder.java    License: Apache License 2.0 5 votes vote down vote up
public ViewHolder setOnLongClickListener(int viewId,
                                         View.OnLongClickListener listener)
{
    View view = getView(viewId);
    view.setOnLongClickListener(listener);
    return this;
}
 
Example 8
/**
 * Get the OnLongClickListener to call when the user long-click on the item.
 * @param adapterHasListener true if the calling adapter has a global listener on the item.
 * @return the long-click listener to be put into the view.
 */
public View.OnLongClickListener getOnLongClickListener(boolean adapterHasListener) {
    if (isLongClickable() && adapterHasListener) {
        if (mViewHolderLongClickListener == null) {
            mViewHolderLongClickListener = new ViewHolderLongClickListener<>(this);
        }
    } else {
        mViewHolderLongClickListener = null;
    }
    return mViewHolderLongClickListener;
}
 
Example 9
Source Project: imsdk-android   File: PhotoView.java    License: MIT License 4 votes vote down vote up
@Override
public void setOnLongClickListener(View.OnLongClickListener l) {
    mAttacher.setOnLongClickListener(l);
}
 
Example 10
Source Project: TouchEffects   File: EffectsAdapter.java    License: MIT License 4 votes vote down vote up
public abstract boolean onTouch(View view, MotionEvent motionEvent,
View.OnClickListener onClickListener,
View.OnLongClickListener onLongClickListener);
 
Example 11
Source Project: RecyclerViewAdapter   File: RVAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnLongClickListener(int res_id, View.OnLongClickListener onLongClickListener) {
    getView(res_id).setOnLongClickListener(onLongClickListener);
}
 
Example 12
Source Project: BaldPhone   File: BaldImageButton.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * use {@link BaldButton#setOnLongClickListener(android.view.View.OnLongClickListener)} instead
 */
@Deprecated
@Override
public void setOnLongClickListener(View.OnLongClickListener onLongClickListener) {
    throw new RuntimeException("use setOnClickListener(View.OnClickListener onClickListener) instead");
}
 
Example 13
Source Project: PhotoDraweeView   File: Attacher.java    License: Apache License 2.0 4 votes vote down vote up
@Override public void setOnLongClickListener(View.OnLongClickListener listener) {
    mLongClickListener = listener;
}
 
Example 14
Source Project: EasyAbout   File: PersonAboutItem.java    License: MIT License 4 votes vote down vote up
public Builder setOnLongClickListener(View.OnLongClickListener onLongClickListener) {
    this.onLongClickListener = onLongClickListener;
    return this;
}
 
Example 15
Source Project: BlackList   File: ContactsCursorAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnLongClickListener(View.OnLongClickListener onLongClickListener) {
    this.outerOnLongClickListener = onLongClickListener;
}
 
Example 16
public void setOnLongClickListener(View.OnLongClickListener onLongClickListener) {
    this.outerOnLongClickListener = onLongClickListener;
}
 
Example 17
Source Project: DevUtils   File: ViewHelper.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 设置长按事件
 * @param onLongClickListener {@link View.OnLongClickListener}
 * @param views               View 数组
 * @return {@link ViewHelper}
 */
public ViewHelper setOnLongClicks(final View.OnLongClickListener onLongClickListener, final View... views) {
    ListenerUtils.setOnLongClicks(onLongClickListener, views);
    return this;
}
 
Example 18
/**
 * Register a callback to be invoked when the Photo displayed by this view is long-pressed.
 *
 * @param listener - Listener to be registered.
 */
void setOnLongClickListener(View.OnLongClickListener listener);
 
Example 19
/**
 * Register a callback to be invoked when the Photo displayed by this view is long-pressed.
 *
 * @param listener - Listener to be registered.
 */
void setOnLongClickListener(View.OnLongClickListener listener);
 
Example 20
/**
 * Register a callback to be invoked when the Photo displayed by this view is long-pressed.
 *
 * @param listener - Listener to be registered.
 */
void setOnLongClickListener(View.OnLongClickListener listener);