Search in sources :

Example 71 with GestureDetector

use of android.view.GestureDetector in project UltimateAndroid by cymcsg.

the class FoldingLayout method init.

public void init(Context context, AttributeSet attrs) {
    mScrollGestureDetector = new GestureDetector(context, new ScrollGestureDetector());
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    setAnchorFactor(0);
    super.init(context, attrs);
}
Also used : GestureDetector(android.view.GestureDetector)

Example 72 with GestureDetector

use of android.view.GestureDetector in project EazeGraph by blackfizz.

the class PieChart method initializeGraph.

/**
     * This is the main entry point after the graph has been inflated. Used to initialize the graph
     * and its corresponding members.
     */
@Override
protected void initializeGraph() {
    super.initializeGraph();
    Utils.setLayerToSW(this);
    mPieData = new ArrayList<PieModel>();
    mTotalValue = 0;
    mGraphPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLegendPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLegendPaint.setTextSize(mLegendTextSize);
    mLegendPaint.setColor(mLegendColor);
    mLegendPaint.setStyle(Paint.Style.FILL);
    mValuePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mValuePaint.setTextSize(mValueTextSize);
    mValuePaint.setColor(mValueTextColor);
    mValuePaint.setStyle(Paint.Style.FILL);
    mGraph.rotateTo(mPieRotation);
    mGraph.decelerate();
    mRevealAnimator = ValueAnimator.ofFloat(0, 1);
    mRevealAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mRevealValue = animation.getAnimatedFraction();
            invalidateGlobal();
        }
    });
    mRevealAnimator.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mStartedAnimation = false;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    if (mUsePieRotation) {
        // Set up an animator to animate the PieRotation property. This is used to
        // correct the pie's orientation after the user lets go of it.
        mAutoCenterAnimator = ObjectAnimator.ofInt(PieChart.this, "PieRotation", 0);
        // Add a listener to hook the onAnimationEnd event so that we can do
        // some cleanup when the pie stops moving.
        mAutoCenterAnimator.addListener(new Animator.AnimatorListener() {

            public void onAnimationStart(Animator animator) {
            }

            public void onAnimationEnd(Animator animator) {
                mGraph.decelerate();
            }

            public void onAnimationCancel(Animator animator) {
            }

            public void onAnimationRepeat(Animator animator) {
            }
        });
        // Create a Scroller to handle the fling gesture.
        if (Build.VERSION.SDK_INT < 11) {
            mScroller = new Scroller(getContext());
        } else {
            mScroller = new Scroller(getContext(), null, true);
        }
        // The scroller doesn't have any built-in animation functions--it just supplies
        // values when we ask it to. So we have to have a way to call it every frame
        // until the fling ends. This code (ab)uses a ValueAnimator object to generate
        // a callback on every animation frame. We don't use the animated value at all.
        mScrollAnimator = ValueAnimator.ofFloat(0, 1);
        mScrollAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                tickScrollAnimation();
            }
        });
        // Create a gesture detector to handle onTouch messages
        mDetector = new GestureDetector(PieChart.this.getContext(), new GestureListener());
        // Turn off long press--this control doesn't use it, and if long press is enabled,
        // you can't scroll for a bit, pause, then scroll some more (the pause is interpreted
        // as a long press, apparently)
        mDetector.setIsLongpressEnabled(false);
    }
    if (this.isInEditMode()) {
        addPieSlice(new PieModel("Breakfast", 15, Color.parseColor("#FE6DA8")));
        addPieSlice(new PieModel("Lunch", 25, Color.parseColor("#56B7F1")));
        addPieSlice(new PieModel("Dinner", 35, Color.parseColor("#CDA67F")));
        addPieSlice(new PieModel("Snack", 25, Color.parseColor("#FED70E")));
    }
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) GestureDetector(android.view.GestureDetector) PieModel(org.eazegraph.lib.models.PieModel) Paint(android.graphics.Paint) Scroller(android.widget.Scroller) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 73 with GestureDetector

use of android.view.GestureDetector in project EazeGraph by blackfizz.

the class ValueLineChart method initializeGraph.

/**
     * This is the main entry point after the graph has been inflated. Used to initialize the graph
     * and its corresponding members.
     */
@Override
protected void initializeGraph() {
    super.initializeGraph();
    mDrawMatrix.setValues(mDrawMatrixValues);
    mGraphOverlay.decelerate();
    mSeries = new ArrayList<ValueLineSeries>();
    mLegendList = new ArrayList<LegendModel>();
    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setStrokeWidth(mLineStroke);
    mLegendPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLegendPaint.setColor(mLegendColor);
    mLegendPaint.setTextSize(mLegendTextSize);
    mLegendPaint.setStrokeWidth(2);
    mLegendPaint.setStyle(Paint.Style.FILL);
    mMaxFontHeight = Utils.calculateMaxTextHeight(mLegendPaint, null);
    mIndicatorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mIndicatorPaint.setColor(mIndicatorLineColor);
    mIndicatorPaint.setTextSize(mIndicatorTextSize);
    mIndicatorPaint.setStrokeWidth(mIndicatorWidth);
    mIndicatorPaint.setStyle(Paint.Style.FILL);
    mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleGestureListener);
    mGestureDetector = new GestureDetector(getContext(), mGestureListener);
    mScroller = new Scroller(getContext());
    mRevealAnimator = ValueAnimator.ofFloat(0, 1);
    mRevealAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mRevealValue = animation.getAnimatedFraction();
            mDrawMatrix.reset();
            mDrawMatrix.setScale(1, 1.f * mRevealValue, 0, mGraphHeight - mNegativeOffset);
            mGraph.invalidate();
        }
    });
    mRevealAnimator.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mStartedAnimation = false;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    // The scroller doesn't have any built-in animation functions--it just supplies
    // values when we ask it to. So we have to have a way to call it every frame
    // until the fling ends. This code (ab)uses a ValueAnimator object to generate
    // a callback on every animation frame. We don't use the animated value at all.
    mScrollAnimator = ValueAnimator.ofFloat(0, 1);
    mScrollAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            tickScrollAnimation();
            invalidateGlobal();
        }
    });
    if (this.isInEditMode()) {
        ValueLineSeries series1 = new ValueLineSeries();
        series1.setColor(0xFF63CBB0);
        series1.addPoint(new ValueLinePoint(1.4f));
        series1.addPoint(new ValueLinePoint(4.4f));
        series1.addPoint(new ValueLinePoint(2.4f));
        series1.addPoint(new ValueLinePoint(3.2f));
        series1.addPoint(new ValueLinePoint(2.6f));
        series1.addPoint(new ValueLinePoint(5.0f));
        series1.addPoint(new ValueLinePoint(3.5f));
        series1.addPoint(new ValueLinePoint(2.4f));
        series1.addPoint(new ValueLinePoint(0.4f));
        series1.addPoint(new ValueLinePoint(3.4f));
        series1.addPoint(new ValueLinePoint(2.5f));
        series1.addPoint(new ValueLinePoint(1.0f));
        series1.addPoint(new ValueLinePoint(4.2f));
        series1.addPoint(new ValueLinePoint(2.4f));
        series1.addPoint(new ValueLinePoint(3.6f));
        series1.addPoint(new ValueLinePoint(1.0f));
        series1.addPoint(new ValueLinePoint(2.5f));
        series1.addPoint(new ValueLinePoint(1.4f));
        addSeries(series1);
    }
}
Also used : GestureDetector(android.view.GestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) Paint(android.graphics.Paint) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) ValueLinePoint(org.eazegraph.lib.models.ValueLinePoint) ValueLineSeries(org.eazegraph.lib.models.ValueLineSeries) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) ScaleGestureDetector(android.view.ScaleGestureDetector) Scroller(android.widget.Scroller) LegendModel(org.eazegraph.lib.models.LegendModel)

Example 74 with GestureDetector

use of android.view.GestureDetector in project android-vision by googlesamples.

the class BarcodeCaptureActivity method onCreate.

/**
     * Initializes the UI and creates the detector pipeline.
     */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.barcode_capture);
    mPreview = (CameraSourcePreview) findViewById(R.id.preview);
    mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) findViewById(R.id.graphicOverlay);
    // read parameters from the intent used to launch the activity.
    boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false);
    boolean useFlash = getIntent().getBooleanExtra(UseFlash, false);
    // Check for the camera permission before accessing the camera.  If the
    // permission is not granted yet, request permission.
    int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    if (rc == PackageManager.PERMISSION_GRANTED) {
        createCameraSource(autoFocus, useFlash);
    } else {
        requestCameraPermission();
    }
    gestureDetector = new GestureDetector(this, new CaptureGestureListener());
    scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());
    Snackbar.make(mGraphicOverlay, "Tap to capture. Pinch/Stretch to zoom", Snackbar.LENGTH_LONG).show();
}
Also used : GestureDetector(android.view.GestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) SuppressLint(android.annotation.SuppressLint)

Example 75 with GestureDetector

use of android.view.GestureDetector in project Android-Terminal-Emulator by jackpal.

the class EmulatorView method attachSession.

/**
     * Attach a {@link TermSession} to this view.
     *
     * @param session The {@link TermSession} this view will be displaying.
     */
public void attachSession(TermSession session) {
    mTextRenderer = null;
    mForegroundPaint = new Paint();
    mBackgroundPaint = new Paint();
    mTopRow = 0;
    mLeftColumn = 0;
    mGestureDetector = new GestureDetector(this);
    // mGestureDetector.setIsLongpressEnabled(false);
    setVerticalScrollBarEnabled(true);
    setFocusable(true);
    setFocusableInTouchMode(true);
    mTermSession = session;
    mKeyListener = new TermKeyListener(session);
    session.setKeyListener(mKeyListener);
    // Do init now if it was deferred until a TermSession was attached
    if (mDeferInit) {
        mDeferInit = false;
        mKnownSize = true;
        initialize();
    }
}
Also used : GestureDetector(android.view.GestureDetector) Paint(android.graphics.Paint)

Aggregations

GestureDetector (android.view.GestureDetector)133 MotionEvent (android.view.MotionEvent)46 ScaleGestureDetector (android.view.ScaleGestureDetector)23 Paint (android.graphics.Paint)22 View (android.view.View)22 Scroller (android.widget.Scroller)13 WindowManager (android.view.WindowManager)11 Handler (android.os.Handler)9 TextView (android.widget.TextView)9 SimpleOnGestureListener (android.view.GestureDetector.SimpleOnGestureListener)8 LayoutInflater (android.view.LayoutInflater)8 TypedArray (android.content.res.TypedArray)7 ImageView (android.widget.ImageView)7 ViewConfiguration (android.view.ViewConfiguration)6 OverScroller (android.widget.OverScroller)6 Matrix (android.graphics.Matrix)5 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)5 FlingAnimationUtils (com.android.systemui.statusbar.FlingAnimationUtils)5 SuppressLint (android.annotation.SuppressLint)4 Resources (android.content.res.Resources)4