Java Code Examples for android.view.View.OnTouchListener

The following are Jave code examples for showing how to use OnTouchListener of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: FlickLauncher   File: Launcher.java   View Source Code Vote up 5 votes
public View.OnTouchListener getHapticFeedbackTouchListener() {
    if (mHapticFeedbackTouchListener == null) {
        mHapticFeedbackTouchListener = new View.OnTouchListener() {
            @SuppressLint("ClickableViewAccessibility")
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
                    v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                }
                return false;
            }
        };
    }
    return mHapticFeedbackTouchListener;
}
 
Example 2
Project: DMS   File: Listeners.java   View Source Code Vote up 5 votes
/**
 * returns OnTouchListener that change color of TextView on touch View.
 * @param context
 * @param textView TextView to change text color
 * @return
 */
public static View.OnTouchListener changeTextColorOnTouchListener(
        final Context context, final TextView textView) {

    return new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    textView.setTextColor(
                            ContextCompat.getColor(context, R.color.colorPrimary));
                    break;
                case MotionEvent.ACTION_MOVE:
                    Rect rect = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
                    if (!rect.contains(
                            v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) {
                        textView.setTextColor(Color.BLACK);
                    }
                    break;
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL:
                    textView.setTextColor(Color.BLACK);
                    break;
                default: break;
            }

            return false;
        }
    };
}
 
Example 3
Project: GitHub   File: ViewHolder.java   View Source Code Vote up 5 votes
public ViewHolder setOnTouchListener(int viewId,
                                     View.OnTouchListener listener)
{
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 4
Project: JueDiQiuSheng   File: ViewHolder.java   View Source Code Vote up 5 votes
public ViewHolder setOnTouchListener(int viewId,
                                     View.OnTouchListener listener)
{
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 5
Project: buildAPKsSamples   File: StableArrayAdapter.java   View Source Code Vote up 5 votes
public StableArrayAdapter(Context context, int textViewResourceId,
        List<String> objects, View.OnTouchListener listener) {
    super(context, textViewResourceId, objects);
    mTouchListener = listener;
    for (int i = 0; i < objects.size(); ++i) {
        mIdMap.put(objects.get(i), i);
    }
}
 
Example 6
Project: BlueTape   File: BlueTapeDslTest.java   View Source Code Vote up 5 votes
@Test
public void onTouch() throws Exception {
    // Given
    View.OnTouchListener listener = mock(View.OnTouchListener.class);

    // When
    BlueTapeDsl
            .onTouch(listener)
            .bind(view);

    // Then
    verify(view).setOnTouchListener(listener);
}
 
Example 7
Project: XFrame   File: XViewHolder.java   View Source Code Vote up 5 votes
public XViewHolder setOnTouchListener(@IdRes int viewId,
                                      View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 8
Project: AndroidBackendlessChat   File: ChatSDKBaseActivity.java   View Source Code Vote up 4 votes
public void setupTouchUIToDismissKeyboard(View view, View.OnTouchListener onTouchListener, final Integer... exceptIDs) {
    ChatSDKUiHelper.setupTouchUIToDismissKeyboard(view, onTouchListener, exceptIDs);
}
 
Example 9
Project: Make-A-Pede-Android-App   File: ArrowKeyFragment.java   View Source Code Vote up 4 votes
private void setTouchListenerOnView(int id, View.OnTouchListener listener) {
	layout.findViewById(id).setOnTouchListener(listener);
}
 
Example 10
Project: YCBaseAdapter   File: BaseViewHolder.java   View Source Code Vote up 4 votes
public BaseViewHolder setOnTouchListener(int viewId, View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 11
Project: MVVM-JueJin   File: ViewHolder.java   View Source Code Vote up 4 votes
public ViewHolder setOnTouchListener(int viewId,
                                     View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 12
Project: RLibrary   File: ViewHolder.java   View Source Code Vote up 4 votes
public ViewHolder setOnTouchListener(int viewId,
                                     View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 13
Project: SuperRecyclerViewAdapter   File: SuperRecyclerHolder.java   View Source Code Vote up 4 votes
public SuperRecyclerHolder setOnItemTouchListener(boolean isListener,
    @NonNull View.OnTouchListener listener) {
    getItemView().setOnTouchListener(isListener ? listener : null);
    return this;
}
 
Example 14
Project: GitHub   File: CustomPopWindow.java   View Source Code Vote up 4 votes
public PopupWindowBuilder setTouchIntercepter(View.OnTouchListener touchIntercepter){
    mCustomPopWindow.mOnTouchListener = touchIntercepter;
    return this;
}
 
Example 15
Project: LaunchEnr   File: CellLayout.java   View Source Code Vote up 4 votes
public void setOnInterceptTouchListener(View.OnTouchListener listener) {
    mInterceptTouchListener = listener;
}
 
Example 16
Project: YCDialog   File: CustomPopupWindow.java   View Source Code Vote up 4 votes
/**
 * 设置触摸拦截
 * @param touchIntercepter  拦截器
 */
public CustomPopupWindow.PopupWindowBuilder setTouchIntercepter(View.OnTouchListener touchIntercepter) {
    this.mCustomPopWindow.mOnTouchListener = touchIntercepter;
    return this;
}
 
Example 17
Project: Sega   File: TouchImageView.java   View Source Code Vote up 4 votes
@Override
public void setOnTouchListener(View.OnTouchListener l) {
    userTouchListener = l;
}
 
Example 18
Project: JD-Test   File: BaseViewHolder.java   View Source Code Vote up 3 votes
/**
 * Sets the on touch listener of the view.
 *
 * @param viewId   The view id.
 * @param listener The on touch listener;
 * @return The BaseViewHolder for chaining.
 */
@Deprecated
public BaseViewHolder setOnTouchListener(int viewId, View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 19
Project: GitHub   File: BaseAdapterHelper.java   View Source Code Vote up 3 votes
/**
 * Sets the on touch listener of the view.
 *
 * @param viewId   The view id.
 * @param listener The on touch listener;
 * @return The BaseAdapterHelper for chaining.
 */
public BaseAdapterHelper setOnTouchListener(int viewId,
                                            View.OnTouchListener listener) {
    View view = retrieveView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 20
Project: yjPlay   File: ExoPlayerViewListener.java   View Source Code Vote up 2 votes
/***
 * 手势操作OnTouch 事件
 * @param listener 实例
 */
void setPlatViewOnTouchListener(View.OnTouchListener listener);