Example usage for android.support.v4.widget EdgeEffectCompat EdgeEffectCompat

List of usage examples for android.support.v4.widget EdgeEffectCompat EdgeEffectCompat

Introduction

In this page you can find the example usage for android.support.v4.widget EdgeEffectCompat EdgeEffectCompat.

Prototype

public EdgeEffectCompat(Context context) 

Source Link

Document

Construct a new EdgeEffect themed using the given context.

Usage

From source file:com.suning.boxcontroller.control.ExViewPager.java

void initViewPager() {
    setWillNotDraw(false);/*w  w  w. jav  a  2s.c  o m*/
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new PageScroller(context, null);
    mScroller.setSrollFinishListener(new OnScrollFinishListener() {

        @Override
        public void OnScrollFinish() {
            // to-do Auto-generated method stub
            Log.d(TAG, "setSrollFinishListener is OnScrollFinish");
            if (null != mPageScrollListener) {
                mPageScrollListener.onPageScrollEnd(getCurrentItem());
            }
        }
    });
    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);
    }
}

From source file:com.av.remusic.widget.RoundViewPager.java

void initViewPager() {
    setWillNotDraw(false);/*from   w ww  .j a va2 s. c o m*/
    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);
    }

    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);
        }
    });
    isRotating = false;
}

From source file:com.example.myronlg.cardviewpagerdemo.MultiCardViewPager.java

void initViewPager() {

    getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
        @Override/*from ww w. j a va2 s .  com*/
        public void onGlobalLayout() {
            itemScrollOffset = (int) (getClientWidth() * mAdapter.getPageWidth(0));
            //                int maxScrollX = (int) (2*getClientWidth()*mAdapter.getPageWidth(0) + (mAdapter.getCount() - 2) * getClientWidth() * mAdapter.getPageWidth(1) - getWidth() + getClientWidth()*0.5F);
            maxScrollX = (int) (getClientWidth() * (2 * mAdapter.getPageWidth(0)
                    + (mAdapter.getCount() - 2) * mAdapter.getPageWidth(1) - 1 + 0.0F));
            minScrollX = (int) (-getClientWidth() * 0.0F);
            //                itemScrollOffset = 0;
            getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });

    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);

    myScroller = new Scroller(context, new AccelerateInterpolator());
    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);
    }
}

From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java

public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = new OverScrollerSGV(context);

    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);//from  ww  w. j  a va2  s . c om
    setClipToPadding(false);

    SgvAnimationHelper.initialize(context);

    mDragState = ReorderUtils.DRAG_STATE_NONE;
    mIsDragReorderingEnabled = true;
    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mOverscrollDistance = configuration.getScaledOverflingDistance();
    // Disable splitting event. Only one of the children can handle motion event.
    setMotionEventSplittingEnabled(false);
}

From source file:com.example.sky.test.view.ViewPager.java

void initViewPager() {
    setWillNotDraw(false);/*w ww .  ja  va  2 s .  c o m*/
    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 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 ViewPager.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);
        }
    });
}

From source file:com.pdftron.pdf.tools.Tool.java

/**
 * Constructor.//from  w  w w  . ja v a  2 s .c  om
 */
public Tool(PDFViewCtrl ctrl) {
    mPDFView = ctrl;
    mNextToolMode = ToolManager.e_pan;
    mCurrentDefaultToolMode = ToolManager.e_pan;
    mAnnot = null;
    mAnnotBBox = new RectF();
    mJustSwitchedFromAnotherTool = false;
    mForceSameNextToolMode = false;
    mAvoidLongPressAttempt = false;
    mAnnotPushedBack = false;
    mMenuShown = false;
    mPageNumPosAdjust = 0;
    mShowPageNum = false;
    mTempPageDrawingRectF = new RectF();

    mTextSize = convDp2Pix(15);
    mTextVOffset = convDp2Pix(50);
    mPaint4PageNum = new Paint();
    mPaint4PageNum.setAntiAlias(true);
    mPaint4PageNum.setTextSize(mTextSize);
    mPaint4PageNum.setStyle(Paint.Style.FILL);

    mTempMtx1 = new Matrix();
    mTempMtx2 = new Matrix();

    mPageNumberIndicatorVisible = true;

    mAllowTwoFingerScroll = false;
    mAllowOneFingerScrollWithStylus = false;
    mAllowZoom = true;

    // Disable page turning (in non-continuous page presentation mode);
    // it is only turned on in Pan tool.
    mPDFView.setBuiltInPageSlidingEnabled(false);

    // Sets up edge effects
    mEdgeEffectLeft = new EdgeEffectCompat(ctrl.getContext());
    mEdgeEffectRight = new EdgeEffectCompat(ctrl.getContext());
}

From source file:com.mediatek.galleryfeature.stereo.segment.ImageShow.java

private void setupImageShow(Context context) {
    Resources res = context.getResources();
    res.getColor(R.color.background_screen);
    mGestureDetector = new GestureDetector(context, this);
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    mActivity = (Activity) context;//w w  w  . j a v a2 s . c o m
    mEdgeEffect = new EdgeEffectCompat(context);
    mEdgeSize = res.getDimensionPixelSize(R.dimen.edge_glow_size);
}

From source file:example.luojing.androidsourceanalysis.ViewPager.java

/**
 * ??//w ww  .j a v a  2 s.  co  m
 */
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 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);
    }

    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);
        }
    });
}

From source file:com.jjoe64.graphview.Viewport.java

/**
 * creates the viewport/*w  ww.  j a  v  a  2s .co  m*/
 *
 * @param graphView graphview
 */
Viewport(GraphView graphView) {
    mScroller = new OverScroller(graphView.getContext());
    mEdgeEffectTop = new EdgeEffectCompat(graphView.getContext());
    mEdgeEffectBottom = new EdgeEffectCompat(graphView.getContext());
    mEdgeEffectLeft = new EdgeEffectCompat(graphView.getContext());
    mEdgeEffectRight = new EdgeEffectCompat(graphView.getContext());
    mGestureDetector = new GestureDetector(graphView.getContext(), mGestureListener);
    mScaleGestureDetector = new ScaleGestureDetector(graphView.getContext(), mScaleGestureListener);

    mGraphView = graphView;
    mXAxisBoundsStatus = AxisBoundsStatus.INITIAL;
    mYAxisBoundsStatus = AxisBoundsStatus.INITIAL;
    mBackgroundColor = Color.TRANSPARENT;
    mPaint = new Paint();
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

public DayView(Context context, CalendarController controller, ViewSwitcher viewSwitcher,
        EventLoader eventLoader, int numDays) {
    super(context);
    mContext = context;/*from  w w  w .  ja  v  a 2  s.  c o  m*/

    mResources = context.getResources();
    mNumDays = numDays;

    DATE_HEADER_FONT_SIZE = (int) mResources.getDimension(R.dimen.date_header_text_size);
    DAY_HEADER_FONT_SIZE = (int) mResources.getDimension(R.dimen.day_label_text_size);
    DAY_HEADER_HEIGHT = (int) mResources.getDimension(R.dimen.day_header_height);
    DAY_HEADER_BOTTOM_MARGIN = (int) mResources.getDimension(R.dimen.day_header_bottom_margin);
    HOURS_TEXT_SIZE = (int) mResources.getDimension(R.dimen.hours_text_size);
    AMPM_TEXT_SIZE = (int) mResources.getDimension(R.dimen.ampm_text_size);
    MIN_HOURS_WIDTH = (int) mResources.getDimension(R.dimen.min_hours_width);
    HOURS_LEFT_MARGIN = (int) mResources.getDimension(R.dimen.hours_left_margin);
    HOURS_RIGHT_MARGIN = (int) mResources.getDimension(R.dimen.hours_right_margin);
    int eventTextSizeId;
    if (mNumDays == 1) {
        eventTextSizeId = R.dimen.day_view_event_text_size;
    } else {
        eventTextSizeId = R.dimen.week_view_event_text_size;
    }
    EVENT_TEXT_FONT_SIZE = (int) mResources.getDimension(eventTextSizeId);
    MIN_EVENT_HEIGHT = mResources.getDimension(R.dimen.event_min_height);
    EVENT_TEXT_TOP_MARGIN = (int) mResources.getDimension(R.dimen.event_text_vertical_margin);
    EVENT_TEXT_BOTTOM_MARGIN = EVENT_TEXT_TOP_MARGIN;

    EVENT_TEXT_LEFT_MARGIN = (int) mResources.getDimension(R.dimen.event_text_horizontal_margin);
    EVENT_TEXT_RIGHT_MARGIN = EVENT_TEXT_LEFT_MARGIN;

    if (mScale == 0) {

        mScale = mResources.getDisplayMetrics().density;
        if (mScale != 1) {

            GRID_LINE_LEFT_MARGIN *= mScale;
            HOURS_TOP_MARGIN *= mScale;
            MIN_CELL_WIDTH_FOR_TEXT *= mScale;

            CURRENT_TIME_LINE_SIDE_BUFFER *= mScale;
            CURRENT_TIME_LINE_TOP_OFFSET *= mScale;

            MIN_Y_SPAN *= mScale;
            MAX_CELL_HEIGHT *= mScale;
            DEFAULT_CELL_HEIGHT *= mScale;
            DAY_HEADER_RIGHT_MARGIN *= mScale;
            DAY_HEADER_ONE_DAY_LEFT_MARGIN *= mScale;
            DAY_HEADER_ONE_DAY_RIGHT_MARGIN *= mScale;
            DAY_HEADER_ONE_DAY_BOTTOM_MARGIN *= mScale;
            EVENT_RECT_TOP_MARGIN *= mScale;
            EVENT_RECT_BOTTOM_MARGIN *= mScale;
            EVENT_RECT_LEFT_MARGIN *= mScale;
            EVENT_RECT_RIGHT_MARGIN *= mScale;
            EVENT_RECT_STROKE_WIDTH *= mScale;
        }
    }
    HOURS_MARGIN = HOURS_LEFT_MARGIN + HOURS_RIGHT_MARGIN;

    mCurrentTimeLine = mResources.getDrawable(R.drawable.timeline_indicator_holo_light);
    mCurrentTimeAnimateLine = mResources.getDrawable(R.drawable.timeline_indicator_activated_holo_light);
    mTodayHeaderDrawable = mResources.getDrawable(R.drawable.today_blue_week_holo_light);
    mAcceptedOrTentativeEventBoxDrawable = mResources.getDrawable(R.drawable.panel_month_event_holo_light);

    mEventLoader = eventLoader;
    mEventGeometry = new EventGeometry();
    mEventGeometry.setMinEventHeight(MIN_EVENT_HEIGHT);
    mEventGeometry.setHourGap(HOUR_GAP);
    mEventGeometry.setCellMargin(DAY_GAP);
    mController = controller;
    mViewSwitcher = viewSwitcher;
    mGestureDetector = new GestureDetector(context, new CalendarGestureListener());
    mScaleGestureDetector = new ScaleGestureDetector(getContext(), this);
    if (mCellHeight == 0) {
        mCellHeight = DEFAULT_CELL_HEIGHT;
    }
    mScroller = new OverScroller(context);
    mHScrollInterpolator = new ScrollInterpolator();
    mEdgeEffectTop = new EdgeEffectCompat(context);
    mEdgeEffectBottom = new EdgeEffectCompat(context);
    ViewConfiguration vc = ViewConfiguration.get(context);
    mScaledPagingTouchSlop = vc.getScaledPagingTouchSlop();
    mOnDownDelay = ViewConfiguration.getTapTimeout();
    OVERFLING_DISTANCE = vc.getScaledOverflingDistance();

    init(context);
}