类android.widget.EdgeEffect源码实例Demo

下面列出了怎么用android.widget.EdgeEffect的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: KrGallery   文件: AndroidUtilities.java
public static void setListViewEdgeEffectColor(AbsListView listView, int color) {
    if (Build.VERSION.SDK_INT >= 21) {
        try {
            Field field = AbsListView.class.getDeclaredField("mEdgeGlowTop");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(listView);
            if (mEdgeGlowTop != null) {
                mEdgeGlowTop.setColor(color);
            }

            field = AbsListView.class.getDeclaredField("mEdgeGlowBottom");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(listView);
            if (mEdgeGlowBottom != null) {
                mEdgeGlowBottom.setColor(color);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
源代码2 项目: microMathematics   文件: TwoDScrollView.java
private void prepare(AttributeSet attrs)
{
    setFocusable(true);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setWillNotDraw(false);
    mScroller = new Scroller(getContext());
    mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener);
    mGestureDetector = new GestureDetectorCompat(getContext(), mGestureListener);
    if (attrs != null)
    {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustomViewExtension, 0, 0);
        autoScrollMargins = a.getDimensionPixelSize(R.styleable.CustomViewExtension_autoScrollMargins, 0);
        a.recycle();
    }
    mEdgeGlowLeft = new EdgeEffect(getContext());
    mEdgeGlowTop = new EdgeEffect(getContext());
    mEdgeGlowRight = new EdgeEffect(getContext());
    mEdgeGlowBottom = new EdgeEffect(getContext());
    setWillNotDraw(false);
}
 
源代码3 项目: andela-crypto-app   文件: Easel.java
/**
 * Tint the edge effect when you reach the end of a scroll view. API 21+ only
 *
 * @param scrollableView the scrollable view, such as a {@link android.widget.ScrollView}
 * @param color          the color
 * @return true if it worked, false if it did not
 */
@TargetApi(21)
public static boolean tintEdgeEffect(@NonNull View scrollableView, @ColorInt int color) {
    //http://stackoverflow.com/questions/27104521/android-lollipop-scrollview-edge-effect-color
    boolean outcome = false;
    final String[] edgeGlows = {"mEdgeGlowTop", "mEdgeGlowBottom", "mEdgeGlowLeft", "mEdgeGlowRight"};
    for (String edgeGlow : edgeGlows) {
        Class<?> clazz = scrollableView.getClass();
        while (clazz != null) {
            try {
                final Field edgeGlowField = clazz.getDeclaredField(edgeGlow);
                edgeGlowField.setAccessible(true);
                final EdgeEffect edgeEffect = (EdgeEffect) edgeGlowField.get(scrollableView);
                edgeEffect.setColor(color);
                outcome = true;
                break;
            } catch (Exception e) {
                clazz = clazz.getSuperclass();
            }
        }
    }
    return outcome;
}
 
源代码4 项目: support   文件: ViewCompat.java
public static void setEdgeEffectColor(final EdgeEffect edgeEffect, @ColorRes final int color) {
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            edgeEffect.setColor(color);
            return;
        }
        final Field edgeField = EdgeEffect.class.getDeclaredField("mEdge");
        final Field glowField = EdgeEffect.class.getDeclaredField("mGlow");
        edgeField.setAccessible(true);
        glowField.setAccessible(true);
        final Drawable edge = (Drawable) edgeField.get(edgeEffect);
        final Drawable glow = (Drawable) glowField.get(edgeEffect);
        edge.setColorFilter(color, PorterDuff.Mode.SRC_IN);
        glow.setColorFilter(color, PorterDuff.Mode.SRC_IN);
        edge.setCallback(null); // free up any references
        glow.setCallback(null); // free up any references
    } catch (final Exception ignored) {
        ignored.printStackTrace();
    }
}
 
源代码5 项目: Dashchan   文件: PhotoViewPager.java
public PhotoViewPager(Context context, Adapter adapter) {
	super(context);
	setWillNotDraw(false);
	float density = ResourceUtils.obtainDensity(context);
	flingDistance = (int) (24 * density);
	ViewConfiguration configuration = ViewConfiguration.get(context);
	minimumVelocity = (int) (MIN_FLING_VELOCITY * density);
	maximumVelocity = configuration.getScaledMaximumFlingVelocity();
	touchSlop = configuration.getScaledTouchSlop();
	scroller = new OverScroller(context);
	edgeEffect = new EdgeEffect(context);
	this.adapter = adapter;
	for (int i = 0; i < 3; i++) {
		View view = adapter.onCreateView(this);
		super.addView(view, -1, generateDefaultLayoutParams());
		photoViews.add(adapter.getPhotoView(view));
	}
}
 
源代码6 项目: Telegram-FOSS   文件: AndroidUtilities.java
public static void setViewPagerEdgeEffectColor(ViewPager viewPager, int color) {
    if (Build.VERSION.SDK_INT >= 21) {
        try {
            Field field = ViewPager.class.getDeclaredField("mLeftEdge");
            field.setAccessible(true);
            EdgeEffect mLeftEdge = (EdgeEffect) field.get(viewPager);
            if (mLeftEdge != null) {
                mLeftEdge.setColor(color);
            }

            field = ViewPager.class.getDeclaredField("mRightEdge");
            field.setAccessible(true);
            EdgeEffect mRightEdge = (EdgeEffect) field.get(viewPager);
            if (mRightEdge != null) {
                mRightEdge.setColor(color);
            }
        } catch (Exception ignore) {

        }
    }
}
 
源代码7 项目: Telegram-FOSS   文件: AndroidUtilities.java
public static void setScrollViewEdgeEffectColor(HorizontalScrollView scrollView, int color) {
    if (Build.VERSION.SDK_INT >= 21) {
        try {
            Field field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowLeft");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowTop != null) {
                mEdgeGlowTop.setColor(color);
            }

            field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowRight");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowBottom != null) {
                mEdgeGlowBottom.setColor(color);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
}
 
源代码8 项目: Telegram-FOSS   文件: AndroidUtilities.java
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color) {
    if (Build.VERSION.SDK_INT >= 21) {
        try {
            Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowTop != null) {
                mEdgeGlowTop.setColor(color);
            }

            field = ScrollView.class.getDeclaredField("mEdgeGlowBottom");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowBottom != null) {
                mEdgeGlowBottom.setColor(color);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
}
 
源代码9 项目: Telegram   文件: AndroidUtilities.java
public static void setViewPagerEdgeEffectColor(ViewPager viewPager, int color) {
    if (Build.VERSION.SDK_INT >= 21) {
        try {
            Field field = ViewPager.class.getDeclaredField("mLeftEdge");
            field.setAccessible(true);
            EdgeEffect mLeftEdge = (EdgeEffect) field.get(viewPager);
            if (mLeftEdge != null) {
                mLeftEdge.setColor(color);
            }

            field = ViewPager.class.getDeclaredField("mRightEdge");
            field.setAccessible(true);
            EdgeEffect mRightEdge = (EdgeEffect) field.get(viewPager);
            if (mRightEdge != null) {
                mRightEdge.setColor(color);
            }
        } catch (Exception ignore) {

        }
    }
}
 
源代码10 项目: Telegram   文件: AndroidUtilities.java
public static void setScrollViewEdgeEffectColor(HorizontalScrollView scrollView, int color) {
    if (Build.VERSION.SDK_INT >= 21) {
        try {
            Field field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowLeft");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowTop != null) {
                mEdgeGlowTop.setColor(color);
            }

            field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowRight");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowBottom != null) {
                mEdgeGlowBottom.setColor(color);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
}
 
源代码11 项目: Telegram   文件: AndroidUtilities.java
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color) {
    if (Build.VERSION.SDK_INT >= 21) {
        try {
            Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowTop != null) {
                mEdgeGlowTop.setColor(color);
            }

            field = ScrollView.class.getDeclaredField("mEdgeGlowBottom");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowBottom != null) {
                mEdgeGlowBottom.setColor(color);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
}
 
源代码12 项目: TelePlus-Android   文件: AndroidUtilities.java
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color)
{
    if (Build.VERSION.SDK_INT >= 21)
    {
        try
        {
            Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowTop != null)
            {
                mEdgeGlowTop.setColor(color);
            }

            field = ScrollView.class.getDeclaredField("mEdgeGlowBottom");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowBottom != null)
            {
                mEdgeGlowBottom.setColor(color);
            }
        }
        catch (Exception e)
        {
            FileLog.e(e);
        }
    }
}
 
源代码13 项目: dynamic-support   文件: DynamicScrollUtils.java
/**
 * Set color of the supplied edge effect object.
 *
 * @param edgeEffect The edge effect object to set the color.
 * @param color The edge effect color to be set.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setEdgeEffectColor(@Nullable Object edgeEffect, @ColorInt int color) {
    initializeEdgeEffectFields();

    if (edgeEffect instanceof EdgeEffectCompat) {
        try {
            F_EDGE_EFFECT_COMPAT_EDGE_EFFECT.setAccessible(true);
            edgeEffect = F_EDGE_EFFECT_COMPAT_EDGE_EFFECT.get(edgeEffect);
        } catch (IllegalAccessException illegalAccessException) {
            return;
        }
    }

    if (edgeEffect == null) {
        return;
    }

    if (DynamicSdkUtils.is21()) {
        ((EdgeEffect) edgeEffect).setColor(color);
    } else {
        try {
            F_EDGE_EFFECT_EDGE.setAccessible(true);
            final Drawable mEdge = (Drawable) F_EDGE_EFFECT_EDGE.get(edgeEffect);
            F_EDGE_EFFECT_GLOW.setAccessible(true);
            final Drawable mGlow = (Drawable) F_EDGE_EFFECT_GLOW.get(edgeEffect);
            if (mGlow != null) {
                mGlow.setColorFilter(color, PorterDuff.Mode.SRC_IN);
                mGlow.setCallback(null);
            }

            if (mEdge != null) {
                mEdge.setColorFilter(color, PorterDuff.Mode.SRC_IN);
                mEdge.setCallback(null);
            }
        } catch (Exception ignored) {
        }
    }
}
 
源代码14 项目: TelePlus-Android   文件: AndroidUtilities.java
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color)
{
    if (Build.VERSION.SDK_INT >= 21)
    {
        try
        {
            Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowTop != null)
            {
                mEdgeGlowTop.setColor(color);
            }

            field = ScrollView.class.getDeclaredField("mEdgeGlowBottom");
            field.setAccessible(true);
            EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
            if (mEdgeGlowBottom != null)
            {
                mEdgeGlowBottom.setColor(color);
            }
        }
        catch (Exception e)
        {
            FileLog.e(e);
        }
    }
}
 
源代码15 项目: Travel-Mate   文件: FlipViewPager.java
private void init() {
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mScroller = new Scroller(getContext(), new LinearInterpolator());
    mTouchSlop = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdgeEffect = new EdgeEffect(getContext());
    mRightEdgeEffect = new EdgeEffect(getContext());
    mShadePaint.setColor(Color.BLACK);
    mShinePaint.setColor(Color.WHITE);
}
 
源代码16 项目: Android-SDK-Demo   文件: SdkCenteredViewPager.java
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 = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = (int) ( MIN_FLING_VELOCITY * density );
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffect( context );
    mRightEdge = new EdgeEffect( context );

    mFlingDistance = (int) ( MIN_DISTANCE_FOR_FLING * density );
    mCloseEnough = (int) ( CLOSE_ENOUGH * density );
    mDefaultGutterSize = (int) ( DEFAULT_GUTTER_SIZE * density );

    setAccessibilityDelegate( new MyAccessibilityDelegate() );

    if ( this.getImportantForAccessibility()
            == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO )
    {
        setImportantForAccessibility( View.IMPORTANT_FOR_ACCESSIBILITY_YES );
    }
}
 
源代码17 项目: Android-SDK-Demo   文件: SdkCenteredViewPager.java
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 = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = (int) ( MIN_FLING_VELOCITY * density );
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffect( context );
    mRightEdge = new EdgeEffect( context );

    mFlingDistance = (int) ( MIN_DISTANCE_FOR_FLING * density );
    mCloseEnough = (int) ( CLOSE_ENOUGH * density );
    mDefaultGutterSize = (int) ( DEFAULT_GUTTER_SIZE * density );

    setAccessibilityDelegate( new MyAccessibilityDelegate() );

    if ( this.getImportantForAccessibility()
            == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO )
    {
        setImportantForAccessibility( View.IMPORTANT_FOR_ACCESSIBILITY_YES );
    }
}
 
源代码18 项目: UltimateAndroid   文件: FreeFlowContainer.java
/**
 * Controls whether the edge glows are enabled or not
 */
public void setEdgeEffectsEnabled(boolean val) {
	mEdgeEffectsEnabled = val;
	if (val) {
		Context context = getContext();
		setWillNotDraw(false);
		mLeftEdge = new EdgeEffect(context);
		mRightEdge = new EdgeEffect(context);
		mTopEdge = new EdgeEffect(context);
		mBottomEdge = new EdgeEffect(context);
	} else {
		setWillNotDraw(true);
		mLeftEdge = mRightEdge = mTopEdge = mBottomEdge = null;
	}
}
 
源代码19 项目: UltimateAndroid   文件: FreeFlowContainer.java
/**
 * Controls whether the edge glows are enabled or not
 */
public void setEdgeEffectsEnabled(boolean val) {
	mEdgeEffectsEnabled = val;
	if (val) {
		Context context = getContext();
		setWillNotDraw(false);
		mLeftEdge = new EdgeEffect(context);
		mRightEdge = new EdgeEffect(context);
		mTopEdge = new EdgeEffect(context);
		mBottomEdge = new EdgeEffect(context);
	} else {
		setWillNotDraw(true);
		mLeftEdge = mRightEdge = mTopEdge = mBottomEdge = null;
	}
}
 
源代码20 项目: wear-notify-for-reddit   文件: PanView.java
public PanView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Sets up interactions
    mGestureDetector = new GestureDetector(context, new ScrollFlingGestureListener());
    mScroller = new OverScroller(context);
    mEdgeEffectLeft = new EdgeEffect(context);
    mEdgeEffectTop = new EdgeEffect(context);
    mEdgeEffectRight = new EdgeEffect(context);
    mEdgeEffectBottom = new EdgeEffect(context);

    mDrawBlurredPaint = new Paint();
    mDrawBlurredPaint.setDither(true);
}
 
源代码21 项目: android-chromium   文件: OverScrollGlow.java
public OverScrollGlow(View host) {
    mHostView = host;
    Context context = host.getContext();
    mEdgeGlowTop = new EdgeEffect(context);
    mEdgeGlowBottom = new EdgeEffect(context);
    mEdgeGlowLeft = new EdgeEffect(context);
    mEdgeGlowRight = new EdgeEffect(context);
}
 
源代码22 项目: android-chromium   文件: OverScrollGlow.java
public OverScrollGlow(View host) {
    mHostView = host;
    Context context = host.getContext();
    mEdgeGlowTop = new EdgeEffect(context);
    mEdgeGlowBottom = new EdgeEffect(context);
    mEdgeGlowLeft = new EdgeEffect(context);
    mEdgeGlowRight = new EdgeEffect(context);
}
 
源代码23 项目: FreeFlow   文件: FreeFlowContainer.java
/**
 * Controls whether the edge glows are enabled or not
 */
public void setEdgeEffectsEnabled(boolean val) {
	mEdgeEffectsEnabled = val;
	if (val) {
		Context context = getContext();
		setWillNotDraw(false);
		mLeftEdge = new EdgeEffect(context);
		mRightEdge = new EdgeEffect(context);
		mTopEdge = new EdgeEffect(context);
		mBottomEdge = new EdgeEffect(context);
	} else {
		setWillNotDraw(true);
		mLeftEdge = mRightEdge = mTopEdge = mBottomEdge = null;
	}
}
 
源代码24 项目: CoolViewPager   文件: CoolViewPager.java
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 = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffect(context);
    mRightEdge = new EdgeEffect(context);
    //添加顶部及底部的边缘效果
    mTopEdge = new EdgeEffect(context);
    mBottomEdge = new EdgeEffect(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new CoolViewPager.MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this)
            == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this,
                ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4.view.OnApplyWindowInsetsListener() {
                private final Rect mTempRect = new Rect();

                @Override
                public WindowInsetsCompat onApplyWindowInsets(final View v,
                                                              final WindowInsetsCompat originalInsets) {
                    // First let the ViewPager itself try and consume them...
                    final WindowInsetsCompat applied =
                            ViewCompat.onApplyWindowInsets(v, originalInsets);
                    if (applied.isConsumed()) {
                        // If the ViewPager consumed all insets, return now
                        return applied;
                    }

                    // Now we'll manually dispatch the insets to our children. Since ViewPager
                    // children are always full-height, we do not want to use the standard
                    // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
                    // the rest of the children will not receive any insets. To workaround this
                    // we manually dispatch the applied insets, not allowing children to
                    // consume them from each other. We do however keep track of any insets
                    // which are consumed, returning the union of our children's consumption
                    final Rect res = mTempRect;
                    res.left = applied.getSystemWindowInsetLeft();
                    res.top = applied.getSystemWindowInsetTop();
                    res.right = applied.getSystemWindowInsetRight();
                    res.bottom = applied.getSystemWindowInsetBottom();

                    for (int i = 0, count = getChildCount(); i < count; i++) {
                        final WindowInsetsCompat childInsets = ViewCompat
                                .dispatchApplyWindowInsets(getChildAt(i), applied);
                        // Now keep track of any consumed by tracking each dimension's min
                        // value
                        res.left = Math.min(childInsets.getSystemWindowInsetLeft(),
                                res.left);
                        res.top = Math.min(childInsets.getSystemWindowInsetTop(),
                                res.top);
                        res.right = Math.min(childInsets.getSystemWindowInsetRight(),
                                res.right);
                        res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(),
                                res.bottom);
                    }

                    // Now return a new WindowInsets, using the consumed window insets
                    return applied.replaceSystemWindowInsets(
                            res.left, res.top, res.right, res.bottom);
                }
            });
}
 
源代码25 项目: Android-Image-Slider   文件: SliderPager.java
void initSliderPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new OwnScroller(context, DEFAULT_SCROLL_DURATION, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffect(context);
    mRightEdge = new EdgeEffect(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);
    }

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new androidx.core.view.OnApplyWindowInsetsListener() {
                private final Rect mTempRect = new Rect();

                @Override
                public WindowInsetsCompat onApplyWindowInsets(final View v,
                                                              final WindowInsetsCompat originalInsets) {
                    // First let the SliderPager itself try and consume them...
                    final WindowInsetsCompat applied =
                            ViewCompat.onApplyWindowInsets(v, originalInsets);
                    if (applied.isConsumed()) {
                        // If the SliderPager consumed all insets, return now
                        return applied;
                    }

                    // Now we'll manually dispatch the insets to our children. Since SliderPager
                    // children are always full-height, we do not want to use the standard
                    // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
                    // the rest of the children will not receive any insets. To workaround this
                    // we manually dispatch the applied insets, not allowing children to
                    // consume them from each other. We do however keep track of any insets
                    // which are consumed, returning the union of our children's consumption
                    final Rect res = mTempRect;
                    res.left = applied.getSystemWindowInsetLeft();
                    res.top = applied.getSystemWindowInsetTop();
                    res.right = applied.getSystemWindowInsetRight();
                    res.bottom = applied.getSystemWindowInsetBottom();

                    for (int i = 0, count = getChildCount(); i < count; i++) {
                        final WindowInsetsCompat childInsets = ViewCompat
                                .dispatchApplyWindowInsets(getChildAt(i), applied);
                        // Now keep track of any consumed by tracking each dimension's min
                        // value
                        res.left = Math.min(childInsets.getSystemWindowInsetLeft(),
                                res.left);
                        res.top = Math.min(childInsets.getSystemWindowInsetTop(),
                                res.top);
                        res.right = Math.min(childInsets.getSystemWindowInsetRight(),
                                res.right);
                        res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(),
                                res.bottom);
                    }

                    // Now return a new WindowInsets, using the consumed window insets
                    return applied.replaceSystemWindowInsets(
                            res.left, res.top, res.right, res.bottom);
                }
            });
}
 
源代码26 项目: dynamic-support   文件: DynamicScrollUtils.java
/**
 * Initialize edge effect or glow fields so that we can access them via reflection.
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private static void initializeEdgeEffectFields() {
    if (F_EDGE_EFFECT_EDGE != null
            && F_EDGE_EFFECT_GLOW != null
            && F_EDGE_EFFECT_COMPAT_EDGE_EFFECT != null) {
        F_EDGE_EFFECT_EDGE.setAccessible(true);
        F_EDGE_EFFECT_GLOW.setAccessible(true);
        F_EDGE_EFFECT_COMPAT_EDGE_EFFECT.setAccessible(true);

        return;
    }

    if (DynamicSdkUtils.is21()) {
        F_EDGE_EFFECT_EDGE = null;
        F_EDGE_EFFECT_GLOW = null;
    } else if (DynamicSdkUtils.is14()) {
        Field edge = null;
        Field glow = null;
        for (Field field : EdgeEffect.class.getDeclaredFields()) {
            switch (field.getName()) {
                case "mEdge":
                    field.setAccessible(true);
                    edge = field;
                    break;
                case "mGlow":
                    field.setAccessible(true);
                    glow = field;
                    break;
            }
        }

        F_EDGE_EFFECT_EDGE = edge;
        F_EDGE_EFFECT_GLOW = glow;
    }

    Field edgeEffectCompat = null;
    try {
        edgeEffectCompat = EdgeEffectCompat.class.getDeclaredField("mEdgeEffect");
    } catch (NoSuchFieldException ignored) {
    }
    F_EDGE_EFFECT_COMPAT_EDGE_EFFECT = edgeEffectCompat;
}
 
源代码27 项目: JZAndroidChart   文件: Chart.java
protected void setupEdgeEffect(Context context) {

        // Sets up edge effects
        mEdgeEffectLeft = new EdgeEffect(context);
        mEdgeEffectRight = new EdgeEffect(context);
    }
 
源代码28 项目: JZAndroidChart   文件: Chart.java
protected void setupEdgeEffect(Context context) {

        // Sets up edge effects
        mEdgeEffectLeft = new EdgeEffect(context);
        mEdgeEffectRight = new EdgeEffect(context);
    }
 
源代码29 项目: MiBandDecompiled   文件: m.java
public static Object a(Context context)
{
    return new EdgeEffect(context);
}
 
源代码30 项目: MiBandDecompiled   文件: m.java
public static void a(Object obj, int i, int j)
{
    ((EdgeEffect)obj).setSize(i, j);
}
 
 类所在包
 同包方法