Example usage for android.view View getRight

List of usage examples for android.view View getRight

Introduction

In this page you can find the example usage for android.view View getRight.

Prototype

@ViewDebug.CapturedViewProperty
public final int getRight() 

Source Link

Document

Right position of this view relative to its parent.

Usage

From source file:com.chromium.fontinstaller.util.ViewUtils.java

public static void reveal(Activity activity, View view, View sourceView, int colorRes) {
    if (activity == null || view == null || sourceView == null)
        return;/*from   w  w  w .  j  a va  2  s .  c  o m*/
    if (isLollipop()) {
        final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView()
                .getOverlay();

        final Rect displayRect = new Rect();
        view.getGlobalVisibleRect(displayRect);

        // Make reveal cover the display and status bar.
        final View revealView = new View(activity);
        revealView.setTop(displayRect.top);
        revealView.setBottom(displayRect.bottom);
        revealView.setLeft(displayRect.left);
        revealView.setRight(displayRect.right);
        revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes));
        groupOverlay.add(revealView);

        final int[] clearLocation = new int[2];
        sourceView.getLocationInWindow(clearLocation);
        clearLocation[0] += sourceView.getWidth() / 2;
        clearLocation[1] += sourceView.getHeight() / 2;

        final int revealCenterX = clearLocation[0] - revealView.getLeft();
        final int revealCenterY = clearLocation[1] - revealView.getTop();

        final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
        final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
        final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
        final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

        try {
            final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX,
                    revealCenterY, 0.0f, revealRadius);
            revealAnimator
                    .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime));

            final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
            alphaAnimator
                    .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime));
            alphaAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in));
                    view.setVisibility(View.VISIBLE);
                }
            });

            final AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.play(revealAnimator).before(alphaAnimator);
            animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
            animatorSet.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    groupOverlay.remove(revealView);
                }
            });

            animatorSet.start();
        } catch (IllegalStateException e) {
            Timber.i("View is detached - not animating");
        }
    } else {
        view.setVisibility(View.VISIBLE);
    }
}

From source file:com.jtechme.apphub.privileged.views.TabsAdapter.java

@Override
public void onPageSelected(int position) {
    // Unfortunately when TabHost changes the current tab, it kindly
    // also takes care of putting focus on it when not in touch mode.
    // The jerk./*from   w ww  .  j av a  2 s  .co m*/
    // This hack tries to prevent this from pulling focus out of our
    // ViewPager.
    TabWidget widget = mTabHost.getTabWidget();
    int oldFocusability = widget.getDescendantFocusability();
    widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    mTabHost.setCurrentTab(position);
    widget.setDescendantFocusability(oldFocusability);

    // Scroll the current tab into visibility if needed.
    View tab = widget.getChildTabViewAt(position);
    mTempRect.set(tab.getLeft(), tab.getTop(), tab.getRight(), tab.getBottom());
    widget.requestRectangleOnScreen(mTempRect, false);

    // Make sure the scrollbars are visible for a moment after selection
    final View contentView = mTabs.get(position);
    if (contentView instanceof CaffeinatedScrollView) {
        ((CaffeinatedScrollView) contentView).awakenScrollBars();
    }
}

From source file:com.android.packageinstaller.TabsAdapter.java

@Override
public void onPageSelected(int position) {
    // Unfortunately when TabHost changes the current tab, it kindly
    // also takes care of putting focus on it when not in touch mode.
    // The jerk./*ww  w.j a v a  2  s .c o m*/
    // This hack tries to prevent this from pulling focus out of our
    // ViewPager.
    TabWidget widget = mTabHost.getTabWidget();
    int oldFocusability = widget.getDescendantFocusability();
    widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    mTabHost.setCurrentTab(position);
    widget.setDescendantFocusability(oldFocusability);

    // Scroll the current tab into visibility if needed.
    View tab = widget.getChildTabViewAt(position);
    mTempRect.set(tab.getLeft(), tab.getTop(), tab.getRight(), tab.getBottom());
    widget.requestRectangleOnScreen(mTempRect, false);

    // Make sure the scrollbars are visible for a moment after selection
    final View contentView = mTabs.get(position).view;
    if (contentView instanceof CaffeinatedScrollView) {
        ((CaffeinatedScrollView) contentView).awakenScrollBars();
    }
}

From source file:com.fluidminds.android.studiosity.utils.DividerItemDecoration.java

public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin + Math.round(ViewCompat.getTranslationX(child));
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);// w w w . j a va  2 s  .c  o m
    }
}

From source file:com.android.calculator2.CalculatorPadViewPager.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    boolean shouldIntercept = super.onInterceptTouchEvent(ev);

    // Only allow the current item to receive touch events.
    if (!shouldIntercept && ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
        final int x = (int) ev.getX() + getScrollX();
        final int y = (int) ev.getY() + getScrollY();

        final int childCount = getChildCount();
        for (int i = childCount - 1; i >= 0; --i) {
            final int childIndex = getChildDrawingOrder(childCount, i);
            final View child = getChildAt(childIndex);
            if (child.getVisibility() == View.VISIBLE && x >= child.getLeft() && x < child.getRight()
                    && y >= child.getTop() && y < child.getBottom()) {
                shouldIntercept = (childIndex != getCurrentItem());
                break;
            }//from   ww  w. ja v a 2  s.  c o m
        }
    }

    return shouldIntercept;
}

From source file:app.iamin.iamin.ui.recyclerview.DividerItemDecoration.java

public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);/*  ww  w  .j a va  2  s .  co m*/
    }
}

From source file:com.crucentralcoast.app.presentation.util.DividerItemDecoration.java

public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin + Math.round(ViewCompat.getTranslationX(child));
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top + mPadding, right, bottom);
        mDivider.draw(c);//w  w  w  .  j  av  a  2  s .com
    }
}

From source file:ciriti.retrofitmockserver.widget.DividerItemDecoration.java

public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin + Math.round(ViewCompat.getTranslationX(child));
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);/*  ww w  . j av a 2s  .c o m*/
    }
}

From source file:com.cocarechina.pullrefreshview.layout.PullRefreshLayout.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    int height = getHeight();
    if (mHeader != null) {
        View mHeaderView = (View) mHeader;
        mHeaderView.layout(mHeaderView.getLeft(), -mHeaderView.getMeasuredHeight(), mHeaderView.getRight(), 0);
    }/* w  w w  .j  a v  a 2s.c  om*/
    if (mFooter != null) {
        View mFooterView = (View) mFooter;
        mFooterView.layout(mFooterView.getLeft(), height, mFooterView.getRight(),
                height + mFooterView.getMeasuredHeight());
    }
}

From source file:com.kodisoft.waiter.tools.DividerItemDecoration.java

public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDividerFull.getIntrinsicHeight();
        mDividerFull.setBounds(left, top, right, bottom);
        mDividerFull.draw(c);/* w  ww.ja  v a2 s .c o  m*/
    }
}