Search in sources :

Example 26 with TouchDelegate

use of android.view.TouchDelegate in project Signal-Android by WhisperSystems.

the class GiphyActivityToolbar method expandTapArea.

private void expandTapArea(final View container, final View child) {
    final int padding = getResources().getDimensionPixelSize(R.dimen.contact_selection_actions_tap_area);
    container.post(() -> {
        Rect rect = new Rect();
        child.getHitRect(rect);
        rect.top -= padding;
        rect.left -= padding;
        rect.right += padding;
        rect.bottom += padding;
        container.setTouchDelegate(new TouchDelegate(rect, child));
    });
}
Also used : Rect(android.graphics.Rect) TouchDelegate(android.view.TouchDelegate)

Example 27 with TouchDelegate

use of android.view.TouchDelegate in project ListViewTipsAndTricks by cyrilmottier.

the class TouchDelegateGroup method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    TouchDelegate delegate = null;
    switch(event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (mTouchDelegates != null) {
                for (TouchDelegate touchDelegate : mTouchDelegates) {
                    if (touchDelegate != null) {
                        if (touchDelegate.onTouchEvent(event)) {
                            mCurrentTouchDelegate = touchDelegate;
                            return true;
                        }
                    }
                }
            }
            break;
        case MotionEvent.ACTION_MOVE:
            delegate = mCurrentTouchDelegate;
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            delegate = mCurrentTouchDelegate;
            mCurrentTouchDelegate = null;
            break;
    }
    return delegate == null ? false : delegate.onTouchEvent(event);
}
Also used : TouchDelegate(android.view.TouchDelegate)

Example 28 with TouchDelegate

use of android.view.TouchDelegate in project ListViewTipsAndTricks by cyrilmottier.

the class LargeTouchableAreasView method addTouchDelegate.

private void addTouchDelegate(Rect rect, int color, View delegateView) {
    mTouchDelegateGroup.addTouchDelegate(new TouchDelegate(rect, delegateView));
    mTouchDelegateRecords.add(new TouchDelegateRecord(rect, color));
}
Also used : TouchDelegate(android.view.TouchDelegate)

Aggregations

TouchDelegate (android.view.TouchDelegate)28 Rect (android.graphics.Rect)21 View (android.view.View)12 TextView (android.widget.TextView)9 CheckBox (android.widget.CheckBox)4 OnClickListener (android.view.View.OnClickListener)3 ViewGroup (android.view.ViewGroup)2 SuppressLint (android.annotation.SuppressLint)1 Drawable (android.graphics.drawable.Drawable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 AdapterView (android.widget.AdapterView)1 ImageButton (android.widget.ImageButton)1 ImageView (android.widget.ImageView)1 Before (org.junit.Before)1 Test (org.junit.Test)1