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.evilduck.piano.views.instrument.PianoView.java

public PianoView(Context context, AttributeSet attrs) {
    super(context, attrs);

    init();//from  w ww. j  a  v a2 s.  co  m

    leftEdgeEffect = new EdgeEffectCompat(getContext());
    rightEdgeEffect = new EdgeEffectCompat(getContext());

    setVerticalScrollBarEnabled(false);
    setHorizontalScrollBarEnabled(true);

    TypedArray a = context.obtainStyledAttributes(R.styleable.View);
    initializeScrollbars(a);
    a.recycle();

    TypedArray pianoAttrs = context.obtainStyledAttributes(attrs, R.styleable.PianoView);

    boolean asBitmaps;
    int circleColor;
    float circleRadius;
    float circleTextSize;
    try {
        asBitmaps = pianoAttrs.getBoolean(R.styleable.PianoView_overlay_bitmaps, true);
        circleColor = pianoAttrs.getColor(R.styleable.PianoView_overlay_color, Color.GREEN);
        circleRadius = pianoAttrs.getDimension(R.styleable.PianoView_overlay_circle_radius, TypedValue
                .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, context.getResources().getDisplayMetrics()));
        circleTextSize = pianoAttrs.getDimension(R.styleable.PianoView_overlay_circle_text_size, TypedValue
                .applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, context.getResources().getDisplayMetrics()));
    } finally {
        pianoAttrs.recycle();
    }

    keyboard = new Keyboard(getContext(), asBitmaps, circleColor, circleRadius, circleTextSize);
}

From source file:com.h6ah4i.android.widget.advrecyclerview.draggable.EdgeEffectDecorator.java

private void ensureTopGlow(RecyclerView rv) {
    if (mTopGlow != null) {
        return;/*from  w ww  .  jav  a  2s. c  om*/
    }
    mTopGlow = new EdgeEffectCompat(rv.getContext());
    if (getClipToPadding(rv)) {
        mTopGlow.setSize(rv.getMeasuredWidth() - rv.getPaddingLeft() - rv.getPaddingRight(),
                rv.getMeasuredHeight() - rv.getPaddingTop() - rv.getPaddingBottom());
    } else {
        mTopGlow.setSize(rv.getMeasuredWidth(), rv.getMeasuredHeight());
    }
}

From source file:com.h6ah4i.android.widget.advrecyclerview.draggable.EdgeEffectDecorator.java

private void ensureBottomGlow(RecyclerView rv) {
    if (mBottomGlow != null) {
        return;/*from   w ww  .  j a  v  a2  s.  c  o m*/
    }
    mBottomGlow = new EdgeEffectCompat(rv.getContext());
    if (getClipToPadding(rv)) {
        mBottomGlow.setSize(rv.getMeasuredWidth() - rv.getPaddingLeft() - rv.getPaddingRight(),
                rv.getMeasuredHeight() - rv.getPaddingTop() - rv.getPaddingBottom());
    } else {
        mBottomGlow.setSize(rv.getMeasuredWidth(), rv.getMeasuredHeight());
    }
}

From source file:com.android.photos.views.GalleryThumbnailView.java

public GalleryThumbnailView(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 OverScroller(context);

    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);//  w  ww  .  j a v  a2  s  . c  o m
    setClipToPadding(false);
}

From source file:com.acbelter.scheduleview.ScheduleView.java

public ScheduleView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    mClipRect = new Rect();
    mClickedViewBounds = new Rect();
    mSelectedIds = new HashSet<Long>();
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mTopEdgeEffect = new EdgeEffectCompat(context);
    mBottomEdgeEffect = new EdgeEffectCompat(context);

    mDataSetObserver = new DataSetObserver() {
        @Override// w  ww  .j  ava2s . c  o  m
        public void onChanged() {
            super.onChanged();
            removeAllViewsInLayout();
            requestLayout();
        }

        @Override
        public void onInvalidated() {
            super.onInvalidated();
            removeAllViewsInLayout();
            requestLayout();
        }
    };

    init(context);

    setVerticalScrollBarEnabled(true);
    setHorizontalScrollBarEnabled(false);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScheduleView, defStyle, 0);
    try {
        if (a != null) {
            DisplayMetrics dm = context.getResources().getDisplayMetrics();
            mInternalPaddingTop = (int) a.getDimension(R.styleable.ScheduleView_internalPaddingTop,
                    TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm));
            mInternalPaddingBottom = (int) a.getDimension(R.styleable.ScheduleView_internalPaddingBottom,
                    TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm));
            mTimeMarksDistance = (int) a.getDimension(R.styleable.ScheduleView_timeMarksDistance,
                    TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 40, dm));
            mItemPaddingLeft = (int) a.getDimension(R.styleable.ScheduleView_itemPaddingLeft,
                    TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm));
            mItemPaddingRight = (int) a.getDimension(R.styleable.ScheduleView_itemPaddingRight,
                    TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm));
            initializeScrollbars(a);
        }
    } finally {
        if (a != null) {
            a.recycle();
        }
    }

    // Draw the background even if no items to display
    setWillNotDraw(false);

    mActionModeCallback = new ActionMode.Callback() {
        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            mode.getMenuInflater().inflate(R.menu.menu_context, menu);
            mIsActionMode = true;
            return true;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            if (item.getItemId() == R.id.delete_items) {
                deleteSelectedItems();
            }
            return false;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
            clearSelection();
            mIsActionMode = false;
            mActionMode = null;
            invalidate();
        }
    };
}

From source file:me.oriley.vista.VistaEdgeEffectHelper.java

@CheckResult
private boolean replaceEdgeEffectCompat(@NonNull Context context, @NonNull Field field,
        @NonNull VistaEdgeEffect edgeEffect) {
    if (EDGE_EFFECT_COMPAT_DELEGATE == null) {
        Log.e(TAG, "Unable to find edge effect delegate field");
        return false;
    }/*from w ww .  j a v  a2 s .c o m*/

    try {
        EdgeEffectCompat edgeEffectCompat = new EdgeEffectCompat(context);
        EDGE_EFFECT_COMPAT_DELEGATE.set(edgeEffectCompat, edgeEffect);

        field.set(mHost, edgeEffectCompat);
        edgeEffectCompat.setSize(mHost.getMeasuredWidth(), mHost.getMeasuredHeight());
        Log.d(TAG, "Replaced edge effect " + field + " in " + mHost);
        return true;
    } catch (Exception e) {
        Log.e(TAG, "Error replacing edge effect " + field + " in " + mHost);
        e.printStackTrace();
        return false;
    }
}

From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.draggable.BaseEdgeEffectDecorator.java

private void ensureGlow1(RecyclerView rv) {
    if (mGlow1 == null) {
        mGlow1 = new EdgeEffectCompat(rv.getContext());
    }//from  w w w  .ja  v a  2  s.  c om

    updateGlowSize(rv, mGlow1, mGlow1Dir);
}

From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.draggable.BaseEdgeEffectDecorator.java

private void ensureGlow2(RecyclerView rv) {
    if (mGlow2 == null) {
        mGlow2 = new EdgeEffectCompat(rv.getContext());
    }//from   w w w  . ja va2 s.  c  o  m
    updateGlowSize(rv, mGlow2, mGlow2Dir);
}

From source file:com.aviary.android.feather.sdk.widget.AviaryWorkspace.java

public void setOverScroll(int mode) {
    if (mode != OVER_SCROLL_NEVER) {
        if (mEdgeGlowLeft == null) {
            mEdgeGlowLeft = new EdgeEffectCompat(getContext());
            mEdgeGlowRight = new EdgeEffectCompat(getContext());
        }/*from w w  w.  j a v  a2s .co m*/
    } else {
        mEdgeGlowLeft = null;
        mEdgeGlowRight = null;
    }
    mOverScrollMode = mode;
}

From source file:com.android.gallery3d.filtershow.imageshow.ImageShow.java

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);
    mOriginalTextMargin = res.getDimensionPixelSize(R.dimen.photoeditor_original_text_margin);
    mOriginalTextSize = res.getDimensionPixelSize(R.dimen.photoeditor_original_text_size);
    mBackgroundColor = res.getColor(R.color.background_screen);
    mOriginalText = res.getString(R.string.original_picture_text);
    mShadow = (NinePatchDrawable) res.getDrawable(R.drawable.geometry_shadow);
    setupGestureDetector(context);//from w  ww .j av a 2  s .c  o m
    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);
}