Search in sources :

Example 31 with GestureDetectorCompat

use of android.support.v4.view.GestureDetectorCompat in project LanSoEditor_advance by LanSoSdk.

the class CameraProgressBar method init.

private void init(Context context, AttributeSet attrs) {
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CameraProgressBar);
        innerColor = a.getColor(R.styleable.CameraProgressBar_innerColor, innerColor);
        outerColor = a.getColor(R.styleable.CameraProgressBar_outerColor, outerColor);
        progressColor = a.getColor(R.styleable.CameraProgressBar_progressColor, progressColor);
        innerRadio = a.getDimensionPixelOffset(R.styleable.CameraProgressBar_innerRadio, innerRadio);
        progressWidth = a.getDimensionPixelOffset(R.styleable.CameraProgressBar_progressWidth, progressWidth);
        progress = a.getInt(R.styleable.CameraProgressBar_progress, progress);
        scale = a.getFloat(R.styleable.CameraProgressBar_scale, scale);
        isLongScale = a.getBoolean(R.styleable.CameraProgressBar_isLongScale, isLongScale);
        maxProgress = a.getInt(R.styleable.CameraProgressBar_maxProgress, maxProgress);
        a.recycle();
    }
    backgroundPaint = new Paint();
    backgroundPaint.setAntiAlias(true);
    backgroundPaint.setColor(backgroundColor);
    progressPaint = new Paint();
    progressPaint.setAntiAlias(true);
    progressPaint.setStrokeWidth(progressWidth);
    progressPaint.setStyle(Paint.Style.STROKE);
    innerPaint = new Paint();
    innerPaint.setAntiAlias(true);
    innerPaint.setStrokeWidth(innerRadio);
    innerPaint.setStyle(Paint.Style.STROKE);
    sweepAngle = ((float) progress / maxProgress) * 360;
    mDetector = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            isLongClick = false;
            if (CameraProgressBar.this.listener != null) {
                CameraProgressBar.this.listener.onClick(CameraProgressBar.this);
            }
            return super.onSingleTapConfirmed(e);
        }

        @Override
        public void onLongPress(MotionEvent e) {
            isLongClick = true;
            postInvalidate();
            mLastY = e.getY();
        // if (CameraProgressBar.this.listener != null) {
        // CameraProgressBar.this.listener.onLongClick(CameraProgressBar.this);
        // }
        }
    });
    mDetector.setIsLongpressEnabled(true);
}
Also used : TypedArray(android.content.res.TypedArray) Paint(android.graphics.Paint) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) MotionEvent(android.view.MotionEvent)

Example 32 with GestureDetectorCompat

use of android.support.v4.view.GestureDetectorCompat in project EffectiveAndroid by rallat.

the class TopArticleListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    layoutManager.scrollToPosition(0);
    recyclerView.setLayoutManager(layoutManager);
    // allows for optimizations if all items are of the same size:
    recyclerView.setHasFixedSize(true);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addOnItemTouchListener(this);
    gestureDetector = new GestureDetectorCompat(this, new RecyclerViewDemoOnGestureListener());
    presenter = createPresenter();
    presenter.create();
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 33 with GestureDetectorCompat

use of android.support.v4.view.GestureDetectorCompat in project EffectiveAndroid by rallat.

the class TopImagesListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addOnItemTouchListener(this);
    gestureDetector = new GestureDetectorCompat(this, new RecyclerViewDemoOnGestureListener());
    presenter = createPresenter();
    presenter.create();
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

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