Search in sources :

Example 1 with GestureDetector

use of android.view.GestureDetector in project photo-picker-plus-android by chute.

the class RippleView method init.

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(android.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 void onLongPress(MotionEvent event) {
            super.onLongPress(event);
            animateRipple(event);
            sendClickEvent(true);
        }

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

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

Example 2 with GestureDetector

use of android.view.GestureDetector in project TouchImageView by MikeOrtiz.

the class TouchImageView 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 3 with GestureDetector

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

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 (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 4 with GestureDetector

use of android.view.GestureDetector in project Anki-Android by Ramblurr.

the class PreviewClass method initLayout.

private void initLayout(Integer layout) {
    setContentView(layout);
    mMainLayout = findViewById(R.id.main_layout);
    Themes.setContentStyle(mMainLayout, Themes.CALLER_REVIEWER);
    mCardContainer = (FrameLayout) findViewById(R.id.flashcard_frame);
    //setInAnimation(false);
    mCardFrame = (FrameLayout) findViewById(R.id.flashcard);
    mTouchLayer = (FrameLayout) findViewById(R.id.touch_layer);
    mTouchLayer.setOnTouchListener(mGestureListener);
    gestureDetector = new GestureDetector(new MyGestureDetector());
    mCardFrame.removeAllViews();
    mCardFrame.setVisibility(View.GONE);
    mTouchLayer.setVisibility(View.GONE);
    if (!mChangeBorderStyle) {
        ((View) findViewById(R.id.flashcard_border)).setVisibility(View.VISIBLE);
    }
    // hunt for input issue 720, like android issue 3341
    if (AnkiDroidApp.SDK_VERSION <= 7 && (mCard != null)) {
        mCard.setFocusableInTouchMode(true);
    }
    Resources res = getResources();
    mEase1Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease1);
    mEase2Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease2);
    mEase3Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease3);
    mEase4Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease4);
    mNext1 = (TextView) findViewById(R.id.nextTime1);
    mNext2 = (TextView) findViewById(R.id.nextTime2);
    mNext3 = (TextView) findViewById(R.id.nextTime3);
    mNext4 = (TextView) findViewById(R.id.nextTime4);
    mNext1.setTextColor(res.getColor(R.color.next_time_failed_color));
    mNext2.setTextColor(res.getColor(R.color.next_time_usual_color));
    if (!mshowNextReviewTime) {
        ((TextView) findViewById(R.id.nextTimeflip)).setVisibility(View.GONE);
        mNext1.setVisibility(View.GONE);
        mNext2.setVisibility(View.GONE);
        mNext3.setVisibility(View.GONE);
        mNext4.setVisibility(View.GONE);
    }
    mFlipCard = (Button) findViewById(R.id.flip_card);
    mFlipCardLayout = (LinearLayout) findViewById(R.id.flashcard_layout_flip);
    mFlipCardLayout.setOnClickListener(mFlipCardListener);
    mFlipCard.setVisibility(View.GONE);
    mFlipCardLayout.setVisibility(View.GONE);
    mChosenAnswer = (TextView) findViewById(R.id.choosen_answer);
    if (mPrefWhiteboard) {
        mWhiteboard = new Whiteboard(this, mInvertedColors, mBlackWhiteboard);
        FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        mWhiteboard.setLayoutParams(lp2);
        FrameLayout fl = (FrameLayout) findViewById(R.id.whiteboard);
        fl.addView(mWhiteboard);
    }
    mAnswerField = (EditText) findViewById(R.id.answer_field);
    mNextTimeTextColor = getResources().getColor(R.color.next_time_usual_color);
    mNextTimeTextRecomColor = getResources().getColor(R.color.next_time_recommended_color);
    mForegroundColor = getResources().getColor(R.color.next_time_usual_color);
    try {
        top_bar = (RelativeLayout) findViewById(R.id.top_bar);
        top_bar.setVisibility(View.GONE);
    } catch (Exception er) {
        er.printStackTrace();
    }
    initControls();
}
Also used : LayoutParams(android.widget.FrameLayout.LayoutParams) LayoutParams(android.widget.FrameLayout.LayoutParams) FrameLayout(android.widget.FrameLayout) GestureDetector(android.view.GestureDetector) MyGestureDetector(com.ichi2.anki.Reviewer.MyGestureDetector) TextView(android.widget.TextView) ScrollTextView(com.ichi2.anki.Reviewer.ScrollTextView) Resources(android.content.res.Resources) MyGestureDetector(com.ichi2.anki.Reviewer.MyGestureDetector) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) ScrollTextView(com.ichi2.anki.Reviewer.ScrollTextView) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 5 with GestureDetector

use of android.view.GestureDetector in project subsampling-scale-image-view by davemorrissey.

the class AdvancedEventHandlingActivity method initialiseImage.

private void initialiseImage() {
    final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) findViewById(id.imageView);
    final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (imageView.isReady()) {
                PointF sCoord = imageView.viewToSourceCoord(e.getX(), e.getY());
                Toast.makeText(getApplicationContext(), "Single tap: " + ((int) sCoord.x) + ", " + ((int) sCoord.y), Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), "Single tap: Image not ready", Toast.LENGTH_SHORT).show();
            }
            return true;
        }

        @Override
        public void onLongPress(MotionEvent e) {
            if (imageView.isReady()) {
                PointF sCoord = imageView.viewToSourceCoord(e.getX(), e.getY());
                Toast.makeText(getApplicationContext(), "Long press: " + ((int) sCoord.x) + ", " + ((int) sCoord.y), Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), "Long press: Image not ready", Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            if (imageView.isReady()) {
                PointF sCoord = imageView.viewToSourceCoord(e.getX(), e.getY());
                Toast.makeText(getApplicationContext(), "Double tap: " + ((int) sCoord.x) + ", " + ((int) sCoord.y), Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), "Double tap: Image not ready", Toast.LENGTH_SHORT).show();
            }
            return true;
        }
    });
    imageView.setImage(ImageSource.asset("squirrel.jpg"));
    imageView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return gestureDetector.onTouchEvent(motionEvent);
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) PointF(android.graphics.PointF) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) GestureDetector(android.view.GestureDetector) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) TextView(android.widget.TextView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Aggregations

GestureDetector (android.view.GestureDetector)221 MotionEvent (android.view.MotionEvent)91 View (android.view.View)52 ScaleGestureDetector (android.view.ScaleGestureDetector)42 Paint (android.graphics.Paint)31 TextView (android.widget.TextView)28 Handler (android.os.Handler)21 ImageView (android.widget.ImageView)20 Matrix (android.graphics.Matrix)18 SuppressLint (android.annotation.SuppressLint)16 Scroller (android.widget.Scroller)16 WindowManager (android.view.WindowManager)15 TypedArray (android.content.res.TypedArray)12 SimpleOnGestureListener (android.view.GestureDetector.SimpleOnGestureListener)11 PointF (android.graphics.PointF)10 SharedPreferences (android.content.SharedPreferences)9 AdapterView (android.widget.AdapterView)9 OverScroller (android.widget.OverScroller)9 Intent (android.content.Intent)8 LayoutInflater (android.view.LayoutInflater)8