Search in sources :

Example 16 with GestureDetectorCompat

use of android.support.v4.view.GestureDetectorCompat in project UltimateAndroid by cymcsg.

the class WeekView method init.

private void init() {
    // Get the date today.
    mToday = Calendar.getInstance();
    mToday.set(Calendar.HOUR_OF_DAY, 0);
    mToday.set(Calendar.MINUTE, 0);
    mToday.set(Calendar.SECOND, 0);
    // Scrolling initialization.
    mGestureDetector = new GestureDetectorCompat(mContext, mGestureListener);
    mScroller = new OverScroller(mContext);
    mStickyScroller = new Scroller(mContext);
    // Measure settings for time column.
    mTimeTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTimeTextPaint.setTextAlign(Paint.Align.RIGHT);
    mTimeTextPaint.setTextSize(mTextSize);
    mTimeTextPaint.setColor(mHeaderColumnTextColor);
    Rect rect = new Rect();
    mTimeTextPaint.getTextBounds("00 PM", 0, "00 PM".length(), rect);
    mTimeTextWidth = mTimeTextPaint.measureText("00 PM");
    mTimeTextHeight = rect.height();
    mHeaderMarginBottom = mTimeTextHeight / 2;
    // Measure settings for header row.
    mHeaderTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mHeaderTextPaint.setColor(mHeaderColumnTextColor);
    mHeaderTextPaint.setTextAlign(Paint.Align.CENTER);
    mHeaderTextPaint.setTextSize(mTextSize);
    mHeaderTextPaint.getTextBounds("00 PM", 0, "00 PM".length(), rect);
    mHeaderTextHeight = rect.height();
    mHeaderTextPaint.setTypeface(Typeface.DEFAULT_BOLD);
    // Prepare header background paint.
    mHeaderBackgroundPaint = new Paint();
    mHeaderBackgroundPaint.setColor(mHeaderRowBackgroundColor);
    // Prepare day background color paint.
    mDayBackgroundPaint = new Paint();
    mDayBackgroundPaint.setColor(mDayBackgroundColor);
    // Prepare hour separator color paint.
    mHourSeparatorPaint = new Paint();
    mHourSeparatorPaint.setStyle(Paint.Style.STROKE);
    mHourSeparatorPaint.setStrokeWidth(mHourSeparatorHeight);
    mHourSeparatorPaint.setColor(mHourSeparatorColor);
    // Prepare today background color paint.
    mTodayBackgroundPaint = new Paint();
    mTodayBackgroundPaint.setColor(mTodayBackgroundColor);
    // Prepare today header text color paint.
    mTodayHeaderTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTodayHeaderTextPaint.setTextAlign(Paint.Align.CENTER);
    mTodayHeaderTextPaint.setTextSize(mTextSize);
    mTodayHeaderTextPaint.setTypeface(Typeface.DEFAULT_BOLD);
    mTodayHeaderTextPaint.setColor(mTodayHeaderTextColor);
    // Prepare event background color.
    mEventBackgroundPaint = new Paint();
    mEventBackgroundPaint.setColor(Color.rgb(174, 208, 238));
    // Prepare header column background color.
    mHeaderColumnBackgroundPaint = new Paint();
    mHeaderColumnBackgroundPaint.setColor(mHeaderColumnBackgroundColor);
    // Prepare event text size and color.
    mEventTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
    mEventTextPaint.setStyle(Paint.Style.FILL);
    mEventTextPaint.setColor(mEventTextColor);
    mEventTextPaint.setTextSize(mEventTextSize);
    mStartDate = (Calendar) mToday.clone();
    // Set default event color.
    mDefaultEventColor = Color.parseColor("#9fc6e7");
}
Also used : Rect(android.graphics.Rect) OverScroller(android.widget.OverScroller) Scroller(android.widget.Scroller) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) OverScroller(android.widget.OverScroller) TextPaint(android.text.TextPaint)

Example 17 with GestureDetectorCompat

use of android.support.v4.view.GestureDetectorCompat in project RxTools by vondear.

the class RxRulerWheelView method init.

protected void init(AttributeSet attrs) {
    float density = getResources().getDisplayMetrics().density;
    mCenterMarkWidth = (int) (density * 1.5f + 0.5f);
    mMarkWidth = density;
    mHighlightColor = 0xFFF74C39;
    mMarkTextColor = 0xFF666666;
    mMarkColor = 0xFFEEEEEE;
    mCursorSize = density * 18;
    mCenterTextSize = density * 22;
    mNormalTextSize = density * 18;
    mBottomSpace = density * 6;
    TypedArray ta = attrs == null ? null : getContext().obtainStyledAttributes(attrs, R.styleable.lwvWheelView);
    if (ta != null) {
        mHighlightColor = ta.getColor(R.styleable.lwvWheelView_lwvHighlightColor, mHighlightColor);
        mMarkTextColor = ta.getColor(R.styleable.lwvWheelView_lwvMarkTextColor, mMarkTextColor);
        mMarkColor = ta.getColor(R.styleable.lwvWheelView_lwvMarkColor, mMarkColor);
        mIntervalFactor = ta.getFloat(R.styleable.lwvWheelView_lwvIntervalFactor, mIntervalFactor);
        mMarkRatio = ta.getFloat(R.styleable.lwvWheelView_lwvMarkRatio, mMarkRatio);
        mAdditionCenterMark = ta.getString(R.styleable.lwvWheelView_lwvAdditionalCenterMark);
        mCenterTextSize = ta.getDimension(R.styleable.lwvWheelView_lwvCenterMarkTextSize, mCenterTextSize);
        mNormalTextSize = ta.getDimension(R.styleable.lwvWheelView_lwvMarkTextSize, mNormalTextSize);
        mCursorSize = ta.getDimension(R.styleable.lwvWheelView_lwvCursorSize, mCursorSize);
    }
    mFadeMarkColor = mHighlightColor & 0xAAFFFFFF;
    mIntervalFactor = Math.max(1, mIntervalFactor);
    mMarkRatio = Math.min(1, mMarkRatio);
    mTopSpace = mCursorSize + density * 2;
    mMarkPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mMarkTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mMarkTextPaint.setTextAlign(Paint.Align.CENTER);
    mMarkTextPaint.setColor(mHighlightColor);
    mMarkPaint.setColor(mMarkColor);
    mMarkPaint.setStrokeWidth(mCenterMarkWidth);
    mMarkTextPaint.setTextSize(mCenterTextSize);
    calcIntervalDis();
    mScroller = new OverScroller(getContext());
    mContentRectF = new RectF();
    mGestureDetectorCompat = new GestureDetectorCompat(getContext(), this);
    selectIndex(0);
}
Also used : RectF(android.graphics.RectF) TypedArray(android.content.res.TypedArray) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) TextPaint(android.text.TextPaint) OverScroller(android.widget.OverScroller)

Example 18 with GestureDetectorCompat

use of android.support.v4.view.GestureDetectorCompat in project vlc-android by videolan.

the class PopupManager method showPopup.

public void showPopup() {
    mService.addCallback(this);
    LayoutInflater li = (LayoutInflater) VLCApplication.getAppContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mRootView = (PopupLayout) li.inflate(R.layout.video_popup, null);
    if (mAlwaysOn)
        mRootView.setKeepScreenOn(true);
    mPlayPauseButton = mRootView.findViewById(R.id.video_play_pause);
    mCloseButton = mRootView.findViewById(R.id.popup_close);
    mExpandButton = mRootView.findViewById(R.id.popup_expand);
    mPlayPauseButton.setOnClickListener(this);
    mCloseButton.setOnClickListener(this);
    mExpandButton.setOnClickListener(this);
    GestureDetectorCompat gestureDetector = new GestureDetectorCompat(mService, this);
    gestureDetector.setOnDoubleTapListener(this);
    mRootView.setGestureDetector(gestureDetector);
    final IVLCVout vlcVout = mService.getVLCVout();
    vlcVout.setVideoView((SurfaceView) mRootView.findViewById(R.id.player_surface));
    vlcVout.addCallback(this);
    vlcVout.attachViews(this);
    mRootView.setVLCVOut(vlcVout);
}
Also used : LayoutInflater(android.view.LayoutInflater) IVLCVout(org.videolan.libvlc.IVLCVout) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat)

Example 19 with GestureDetectorCompat

use of android.support.v4.view.GestureDetectorCompat in project Rocket by mozilla-tw.

the class TabTrayFragment method setupTapBackgroundToExpand.

private void setupTapBackgroundToExpand() {
    final GestureDetectorCompat detector = new GestureDetectorCompat(getContext(), new SimpleOnGestureListener() {

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            setBottomSheetState(BottomSheetBehavior.STATE_EXPANDED);
            return true;
        }

        @Override
        public boolean onDown(MotionEvent e) {
            return true;
        }
    });
    backgroundView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            boolean result = detector.onTouchEvent(event);
            if (result) {
                v.performClick();
            }
            return result;
        }
    });
}
Also used : SimpleOnGestureListener(android.view.GestureDetector.SimpleOnGestureListener) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) View(android.view.View) WebView(android.webkit.WebView) TabView(org.mozilla.focus.tabs.TabView) RecyclerView(android.support.v7.widget.RecyclerView) MotionEvent(android.view.MotionEvent)

Example 20 with GestureDetectorCompat

use of android.support.v4.view.GestureDetectorCompat in project vlc-android by GeoffreyMetais.

the class VideoPlayerActivity method onTouchEvent.

/**
 * show/hide the overlay
 */
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mService == null)
        return false;
    if (mDetector == null) {
        mDetector = new GestureDetectorCompat(this, mGestureListener);
        mDetector.setOnDoubleTapListener(mGestureListener);
    }
    if (mFov != 0f && mScaleGestureDetector == null)
        mScaleGestureDetector = new ScaleGestureDetector(this, this);
    if (mPlaybackSetting != DelayState.OFF) {
        if (event.getAction() == MotionEvent.ACTION_UP)
            endPlaybackSetting();
        return true;
    } else if (mPlaylist.getVisibility() == View.VISIBLE) {
        togglePlaylist();
        return true;
    }
    if (mTouchControls == 0 || mIsLocked) {
        // locked or swipe disabled, only handle show/hide & ignore all actions
        if (event.getAction() == MotionEvent.ACTION_UP) {
            if (!mShowing) {
                showOverlay();
            } else {
                hideOverlay(true);
            }
        }
        return false;
    }
    if (mFov != 0f && mScaleGestureDetector != null)
        mScaleGestureDetector.onTouchEvent(event);
    if ((mScaleGestureDetector != null && mScaleGestureDetector.isInProgress()) || (mDetector != null && mDetector.onTouchEvent(event)))
        return true;
    final float x_changed = mTouchX != -1f && mTouchY != -1f ? event.getRawX() - mTouchX : 0f;
    final float y_changed = x_changed != 0f ? event.getRawY() - mTouchY : 0f;
    // coef is the gradient's move to determine a neutral zone
    final float coef = Math.abs(y_changed / x_changed);
    final float xgesturesize = ((x_changed / mScreen.xdpi) * 2.54f);
    final float delta_y = Math.max(1f, (Math.abs(mInitTouchY - event.getRawY()) / mScreen.xdpi + 0.5f) * 2f);
    final int xTouch = Math.round(event.getRawX());
    final int yTouch = Math.round(event.getRawY());
    switch(event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            // Audio
            mTouchY = mInitTouchY = event.getRawY();
            if (mService.getVolume() <= 100) {
                mVol = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
                mOriginalVol = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
            } else {
                mVol = ((float) mService.getVolume()) * mAudioMax / 100;
            }
            mTouchAction = TOUCH_NONE;
            // Seek
            mTouchX = event.getRawX();
            // Mouse events for the core
            sendMouseEvent(MotionEvent.ACTION_DOWN, xTouch, yTouch);
            break;
        case MotionEvent.ACTION_MOVE:
            // Mouse events for the core
            sendMouseEvent(MotionEvent.ACTION_MOVE, xTouch, yTouch);
            if (mFov == 0f) {
                // TODO : Volume action when a secondary display is connected
                if (mTouchAction != TOUCH_SEEK && coef > 2 && mDisplayManager.isPrimary()) {
                    if (Math.abs(y_changed / mSurfaceYDisplayRange) < 0.05)
                        return false;
                    mTouchY = event.getRawY();
                    mTouchX = event.getRawX();
                    doVerticalTouchAction(y_changed);
                } else {
                    // Seek (Right or Left move)
                    doSeekTouch(Math.round(delta_y), mIsRtl ? -xgesturesize : xgesturesize, false);
                }
            } else {
                mTouchY = event.getRawY();
                mTouchX = event.getRawX();
                mTouchAction = TOUCH_MOVE;
                final float yaw = mFov * -x_changed / (float) mSurfaceXDisplayRange;
                final float pitch = mFov * -y_changed / (float) mSurfaceXDisplayRange;
                mService.updateViewpoint(yaw, pitch, 0, 0, false);
            }
            break;
        case MotionEvent.ACTION_UP:
            // Mouse events for the core
            sendMouseEvent(MotionEvent.ACTION_UP, xTouch, yTouch);
            // Seek
            if (mTouchAction == TOUCH_SEEK)
                doSeekTouch(Math.round(delta_y), mIsRtl ? -xgesturesize : xgesturesize, true);
            mTouchX = -1f;
            mTouchY = -1f;
            break;
    }
    return mTouchAction != TOUCH_NONE;
}
Also used : ScaleGestureDetector(android.view.ScaleGestureDetector) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) SuppressLint(android.annotation.SuppressLint)

Aggregations

GestureDetectorCompat (android.support.v4.view.GestureDetectorCompat)33 MotionEvent (android.view.MotionEvent)12 ScaleGestureDetector (android.view.ScaleGestureDetector)8 Paint (android.graphics.Paint)6 Intent (android.content.Intent)5 View (android.view.View)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 RecyclerView (android.support.v7.widget.RecyclerView)4 GestureDetector (android.view.GestureDetector)4 LayoutInflater (android.view.LayoutInflater)4 OverScroller (android.widget.OverScroller)4 Context (android.content.Context)3 Bundle (android.os.Bundle)3 TextPaint (android.text.TextPaint)3 ViewGroup (android.view.ViewGroup)3 ImageView (android.widget.ImageView)3 Link (com.winsonchiu.reader.data.reddit.Link)3 Sort (com.winsonchiu.reader.data.reddit.Sort)3 AdapterLink (com.winsonchiu.reader.links.AdapterLink)3 Activity (android.app.Activity)2