Search in sources :

Example 21 with EdgeEffectCompat

use of android.support.v4.widget.EdgeEffectCompat in project UltimateAndroid by cymcsg.

the class ViewPagerEx method initViewPager.

void initViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);
    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());
    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}
Also used : Context(android.content.Context) ViewConfiguration(android.view.ViewConfiguration) EdgeEffectCompat(android.support.v4.widget.EdgeEffectCompat) Scroller(android.widget.Scroller)

Example 22 with EdgeEffectCompat

use of android.support.v4.widget.EdgeEffectCompat in project MiMangaNu by raulhaag.

the class VerticalViewPager method initViewPager.

void initViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);
    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());
    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}
Also used : Context(android.content.Context) ViewConfiguration(android.view.ViewConfiguration) EdgeEffectCompat(android.support.v4.widget.EdgeEffectCompat) Scroller(android.widget.Scroller)

Example 23 with EdgeEffectCompat

use of android.support.v4.widget.EdgeEffectCompat in project android_packages_apps_Gallery2 by LineageOS.

the class GalleryThumbnailView method trackMotionScroll.

/**
 * @param deltaX Pixels that content should move by
 * @return true if the movement completed, false if it was stopped prematurely.
 */
private boolean trackMotionScroll(int deltaX, boolean allowOverScroll) {
    final boolean contentFits = contentFits();
    final int allowOverhang = Math.abs(deltaX);
    final int overScrolledBy;
    final int movedBy;
    if (!contentFits) {
        final int overhang;
        final boolean up;
        mPopulating = true;
        if (deltaX > 0) {
            overhang = fillLeft(mFirstPosition - 1, allowOverhang);
            up = true;
        } else {
            overhang = fillRight(mFirstPosition + getChildCount(), allowOverhang);
            up = false;
        }
        movedBy = Math.min(overhang, allowOverhang);
        offsetChildren(up ? movedBy : -movedBy);
        recycleOffscreenViews();
        mPopulating = false;
        overScrolledBy = allowOverhang - overhang;
    } else {
        overScrolledBy = allowOverhang;
        movedBy = 0;
    }
    if (allowOverScroll) {
        final int overScrollMode = ViewCompat.getOverScrollMode(this);
        if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) {
            if (overScrolledBy > 0) {
                EdgeEffectCompat edge = deltaX > 0 ? mLeftEdge : mRightEdge;
                edge.onPull((float) Math.abs(deltaX) / getWidth());
                ViewCompat.postInvalidateOnAnimation(this);
            }
        }
    }
    return deltaX == 0 || movedBy != 0;
}
Also used : EdgeEffectCompat(android.support.v4.widget.EdgeEffectCompat)

Example 24 with EdgeEffectCompat

use of android.support.v4.widget.EdgeEffectCompat in project android_packages_apps_Gallery2 by LineageOS.

the class GalleryThumbnailView method computeScroll.

@Override
public void computeScroll() {
    if (mScroller.computeScrollOffset()) {
        final int x = mScroller.getCurrX();
        final int dx = (int) (x - mLastTouchX);
        mLastTouchX = x;
        final boolean stopped = !trackMotionScroll(dx, false);
        if (!stopped && !mScroller.isFinished()) {
            ViewCompat.postInvalidateOnAnimation(this);
        } else {
            if (stopped) {
                final int overScrollMode = ViewCompat.getOverScrollMode(this);
                if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) {
                    final EdgeEffectCompat edge;
                    if (dx > 0) {
                        edge = mLeftEdge;
                    } else {
                        edge = mRightEdge;
                    }
                    edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity()));
                    ViewCompat.postInvalidateOnAnimation(this);
                }
                mScroller.abortAnimation();
            }
            mTouchMode = TOUCH_MODE_IDLE;
        }
    }
}
Also used : EdgeEffectCompat(android.support.v4.widget.EdgeEffectCompat)

Example 25 with EdgeEffectCompat

use of android.support.v4.widget.EdgeEffectCompat in project android_packages_apps_Gallery2 by LineageOS.

the class ImageShow method setupImageShow.

private void setupImageShow(Context context) {
    Resources res = context.getResources();
    mTextSize = res.getDimensionPixelSize(R.dimen.photoeditor_text_size);
    mTextPadding = res.getDimensionPixelSize(R.dimen.photoeditor_text_padding);
    mBackgroundColor = res.getColor(R.color.background_screen);
    mShadow = (NinePatchDrawable) res.getDrawable(R.drawable.geometry_shadow);
    setupGestureDetector(context);
    mActivity = (FilterShowActivity) context;
    if (sMask == null) {
        Bitmap mask = BitmapFactory.decodeResource(res, R.drawable.spot_mask);
        sMask = convertToAlphaMask(mask);
    }
    mEdgeEffect = new EdgeEffectCompat(context);
    mEdgeSize = res.getDimensionPixelSize(R.dimen.edge_glow_size);
}
Also used : Bitmap(android.graphics.Bitmap) EdgeEffectCompat(android.support.v4.widget.EdgeEffectCompat) Resources(android.content.res.Resources)

Aggregations

EdgeEffectCompat (android.support.v4.widget.EdgeEffectCompat)33 Context (android.content.Context)18 ViewConfiguration (android.view.ViewConfiguration)18 Scroller (android.widget.Scroller)17 View (android.view.View)5 Rect (android.graphics.Rect)4 WindowInsetsCompat (android.support.v4.view.WindowInsetsCompat)3 SuppressLint (android.annotation.SuppressLint)2 Point (android.graphics.Point)2 EdgeEffect (android.widget.EdgeEffect)2 TargetApi (android.annotation.TargetApi)1 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 Drawable (android.graphics.drawable.Drawable)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1 Field (java.lang.reflect.Field)1