Search in sources :

Example 6 with GestureDetector

use of android.view.GestureDetector in project android by owncloud.

the class TouchImageViewCustom method sharedConstructing.

private void sharedConstructing(Context context) {
    super.setClickable(true);
    this.context = context;
    mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
    mGestureDetector = new GestureDetector(context, new GestureListener());
    matrix = new Matrix();
    prevMatrix = new Matrix();
    m = new float[9];
    normalizedScale = 1;
    if (mScaleType == null) {
        mScaleType = ScaleType.FIT_CENTER;
    }
    minScale = 1;
    maxScale = 3;
    superMinScale = SUPER_MIN_MULTIPLIER * minScale;
    superMaxScale = SUPER_MAX_MULTIPLIER * maxScale;
    setImageMatrix(matrix);
    setScaleType(ScaleType.MATRIX);
    setState(State.NONE);
    onDrawReady = false;
    super.setOnTouchListener(new PrivateOnTouchListener());
}
Also used : Matrix(android.graphics.Matrix) GestureDetector(android.view.GestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector)

Example 7 with GestureDetector

use of android.view.GestureDetector in project superCleanMaster by joyoyao.

the class RippleView method init.

@SuppressLint("Recycle")
private void init(final Context context, final AttributeSet attrs) {
    if (isInEditMode())
        return;
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleView);
    rippleColor = typedArray.getColor(R.styleable.RippleView_rv_color, getResources().getColor(R.color.white));
    rippleType = typedArray.getInt(R.styleable.RippleView_rv_type, 0);
    hasToZoom = typedArray.getBoolean(R.styleable.RippleView_rv_zoom, false);
    isCentered = typedArray.getBoolean(R.styleable.RippleView_rv_centered, false);
    DURATION = typedArray.getInteger(R.styleable.RippleView_rv_rippleDuration, DURATION);
    FRAME_RATE = typedArray.getInteger(R.styleable.RippleView_rv_framerate, FRAME_RATE);
    PAINT_ALPHA = typedArray.getInteger(R.styleable.RippleView_rv_alpha, PAINT_ALPHA);
    ripplePadding = typedArray.getDimensionPixelSize(R.styleable.RippleView_rv_ripplePadding, 0);
    canvasHandler = new Handler();
    zoomScale = typedArray.getFloat(R.styleable.RippleView_rv_zoomScale, 1.03f);
    zoomDuration = typedArray.getInt(R.styleable.RippleView_rv_zoomDuration, 200);
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(rippleColor);
    paint.setAlpha(PAINT_ALPHA);
    this.setWillNotDraw(false);
    gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            return true;
        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            return true;
        }
    });
    this.setDrawingCacheEnabled(true);
}
Also used : TypedArray(android.content.res.TypedArray) Handler(android.os.Handler) GestureDetector(android.view.GestureDetector) Paint(android.graphics.Paint) MotionEvent(android.view.MotionEvent) SuppressLint(android.annotation.SuppressLint)

Example 8 with GestureDetector

use of android.view.GestureDetector in project android_frameworks_base by ResurrectionRemix.

the class OverlayDisplayWindow method createWindow.

private void createWindow() {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    mWindowContent = inflater.inflate(com.android.internal.R.layout.overlay_display_window, null);
    mWindowContent.setOnTouchListener(mOnTouchListener);
    mTextureView = (TextureView) mWindowContent.findViewById(com.android.internal.R.id.overlay_display_window_texture);
    mTextureView.setPivotX(0);
    mTextureView.setPivotY(0);
    mTextureView.getLayoutParams().width = mWidth;
    mTextureView.getLayoutParams().height = mHeight;
    mTextureView.setOpaque(false);
    mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
    mTitleTextView = (TextView) mWindowContent.findViewById(com.android.internal.R.id.overlay_display_window_title);
    mTitleTextView.setText(mTitle);
    mWindowParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY);
    mWindowParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
    if (mSecure) {
        mWindowParams.flags |= WindowManager.LayoutParams.FLAG_SECURE;
    }
    if (DISABLE_MOVE_AND_RESIZE) {
        mWindowParams.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
    }
    mWindowParams.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
    mWindowParams.alpha = WINDOW_ALPHA;
    mWindowParams.gravity = Gravity.TOP | Gravity.LEFT;
    mWindowParams.setTitle(mTitle);
    mGestureDetector = new GestureDetector(mContext, mOnGestureListener);
    mScaleGestureDetector = new ScaleGestureDetector(mContext, mOnScaleGestureListener);
    // Set the initial position and scale.
    // The position and scale will be clamped when the display is first shown.
    mWindowX = (mGravity & Gravity.LEFT) == Gravity.LEFT ? 0 : mDefaultDisplayInfo.logicalWidth;
    mWindowY = (mGravity & Gravity.TOP) == Gravity.TOP ? 0 : mDefaultDisplayInfo.logicalHeight;
    mWindowScale = INITIAL_SCALE;
}
Also used : LayoutInflater(android.view.LayoutInflater) GestureDetector(android.view.GestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) WindowManager(android.view.WindowManager)

Example 9 with GestureDetector

use of android.view.GestureDetector in project YourEyes by SevenLJY.

the class HelpActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);
    SpeechUtility.createUtility(HelpActivity.this, SpeechConstant.APPID + "=58593564");
    detector = new GestureDetector(this, this);
}
Also used : GestureDetector(android.view.GestureDetector)

Example 10 with GestureDetector

use of android.view.GestureDetector in project android_frameworks_base by ResurrectionRemix.

the class SystemGesturesPointerEventListener method systemReady.

public void systemReady() {
    Handler h = new Handler(Looper.myLooper());
    mGestureDetector = new GestureDetector(mContext, new FlingGestureDetector(), h);
    mOverscroller = new OverScroller(mContext);
}
Also used : Handler(android.os.Handler) GestureDetector(android.view.GestureDetector) OverScroller(android.widget.OverScroller)

Aggregations

GestureDetector (android.view.GestureDetector)220 MotionEvent (android.view.MotionEvent)90 View (android.view.View)53 ScaleGestureDetector (android.view.ScaleGestureDetector)42 Paint (android.graphics.Paint)30 TextView (android.widget.TextView)29 Handler (android.os.Handler)20 ImageView (android.widget.ImageView)20 Matrix (android.graphics.Matrix)18 SuppressLint (android.annotation.SuppressLint)17 Scroller (android.widget.Scroller)16 WindowManager (android.view.WindowManager)15 TypedArray (android.content.res.TypedArray)12 SimpleOnGestureListener (android.view.GestureDetector.SimpleOnGestureListener)11 ViewGroup (android.view.ViewGroup)10 AdapterView (android.widget.AdapterView)10 Intent (android.content.Intent)9 SharedPreferences (android.content.SharedPreferences)9 PointF (android.graphics.PointF)9 OverScroller (android.widget.OverScroller)9