Java Code Examples for android.view.View#OnLongClickListener

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: MessagesListAdapter.java    From ChatKit with 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 2
Source File: BaseRecyclerViewAdapter.java    From CameraMaskDemo with Apache License 2.0 6 votes vote down vote up
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 3
Source File: BaseHeaderFooterAdapter.java    From SimpleAdapterDemo with Apache License 2.0 6 votes vote down vote up
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 4
Source File: EfficientViewHolder.java    From EfficientAdapter with Apache License 2.0 5 votes vote down vote up
/**
 * 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 5
Source File: ViewHolder.java    From likequanmintv with 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 6
Source File: GroupedRecyclerViewItemListItemView.java    From RedReader with GNU General Public License v3.0 5 votes vote down vote up
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 File: DragHandler.java    From openlauncher with 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 8
Source File: ListenerUtils.java    From DevUtils with 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 9
Source File: SMSConversationsListCursorAdapter.java    From BlackList with Apache License 2.0 4 votes vote down vote up
public void setOnLongClickListener(View.OnLongClickListener onLongClickListener) {
    this.outerOnLongClickListener = onLongClickListener;
}
 
Example 10
Source File: PhotoView.java    From imsdk-android with MIT License 4 votes vote down vote up
@Override
public void setOnLongClickListener(View.OnLongClickListener l) {
    mAttacher.setOnLongClickListener(l);
}
 
Example 11
Source File: ContactsCursorAdapter.java    From BlackList with Apache License 2.0 4 votes vote down vote up
public void setOnLongClickListener(View.OnLongClickListener onLongClickListener) {
    this.outerOnLongClickListener = onLongClickListener;
}
 
Example 12
Source File: PersonAboutItem.java    From EasyAbout with MIT License 4 votes vote down vote up
public Builder setOnLongClickListener(View.OnLongClickListener onLongClickListener) {
    this.onLongClickListener = onLongClickListener;
    return this;
}
 
Example 13
Source File: Attacher.java    From PhotoDraweeView with Apache License 2.0 4 votes vote down vote up
@Override public void setOnLongClickListener(View.OnLongClickListener listener) {
    mLongClickListener = listener;
}
 
Example 14
Source File: BaldImageButton.java    From BaldPhone with 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 15
Source File: RVAdapter.java    From RecyclerViewAdapter with 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 16
Source File: EffectsAdapter.java    From TouchEffects with MIT License 4 votes vote down vote up
public abstract boolean onTouch(View view, MotionEvent motionEvent,
View.OnClickListener onClickListener,
View.OnLongClickListener onLongClickListener);
 
Example 17
Source File: IPhotoView.java    From BlackLight with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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 18
Source File: IPhotoView.java    From Favorite-Android-Client with Apache License 2.0 2 votes vote down vote up
/**
 * 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
Source File: IPhotoView.java    From AndroidPickPhotoDialog with Apache License 2.0 2 votes vote down vote up
/**
 * 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
Source File: ViewHelper.java    From DevUtils with 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;
}